You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
202 lines
7.0 KiB
202 lines
7.0 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class PowerAttributePanel : ResourceLoadPanel<PowerAttributePanel> |
|
{ |
|
// public Dropdown TeamNameDropdown; |
|
public DropdownListData DropdownListData; |
|
public InputField TaskInput; |
|
public InputField TypeNameInput; |
|
public Button ConfirmBtn; |
|
public Button CancleBtn; |
|
public Button TaskListBtn; |
|
public GameObject TaskListobj; |
|
public PowerAttribute PowerAttribute; |
|
public PlusMinusCtrl PlusMinusCtrl; |
|
public RectTransform Content; |
|
public GameObject TaskItem; |
|
public GameObject powerattributepanel; |
|
GameObject selectobj; |
|
|
|
void Start() |
|
{ |
|
// Typenametext = transform.Find("TruckAttributePanel/ContainPanel/TypeName/TypeNameText"); |
|
ConfirmBtn.onClick.AddListener(Confirm); |
|
CancleBtn.onClick.AddListener(Cancle); |
|
TaskListBtn.onClick.AddListener(TaskList); |
|
MessageDispatcher.AddListener("SelectChange", RadioSelect); |
|
MessageDispatcher.AddListener("CANCEL_SELECTED_COMMAND", EscCancelSelected); |
|
MessageDispatcher.AddListener("DeleteObj", DeleteObj); |
|
} |
|
|
|
private void DeleteObj(IMessage message) |
|
{ |
|
if (!gameObject.activeSelf) |
|
return; |
|
var obj = message.Data as GameObject; |
|
if (obj == selectobj) |
|
gameObject.SetActive(false); |
|
} |
|
|
|
private void EscCancelSelected(IMessage obj) |
|
{ |
|
powerattributepanel.SetActive(false); |
|
TaskListobj.SetActive(false); |
|
WaterFlowAttribute.GetInstance.gameObject.SetActive(false); |
|
} |
|
|
|
private void RadioSelect(IMessage obj) |
|
{ |
|
GameObject select = (GameObject)obj.Data; |
|
// if (SelectedObjs.selectedObj != selectobj | !SelectedObjs.selectedCharacters.Contains(selectobj)) |
|
// { |
|
// powerattributepanel.SetActive(false); |
|
// WaterFlowAttribute.Instance.gameObject.SetActive(false); |
|
// } |
|
if (select != selectobj) |
|
{ |
|
powerattributepanel.SetActive(false); |
|
WaterFlowAttribute.GetInstance.gameObject.SetActive(false); |
|
} |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("SelectChange", RadioSelect); |
|
MessageDispatcher.RemoveListener("DeleteObj", DeleteObj); |
|
MessageDispatcher.RemoveListener("CANCEL_SELECTED_COMMAND", EscCancelSelected); |
|
} |
|
|
|
private void TaskList() |
|
{ |
|
TaskListobj.SetActive(!TaskListobj.activeSelf); |
|
} |
|
//public void BulkEditing() |
|
//{ |
|
// powerattributepanel.SetActive(true); |
|
// TaskListobj.transform.Find("Staff").gameObject.SetActive(true); |
|
// DropdownListData.SelectText = ""; |
|
// TaskInput.text = ""; |
|
// PlusMinusCtrl.Number = 0; |
|
//} |
|
private void Cancle() |
|
{ |
|
gameObject.SetActive(false); |
|
} |
|
private void Confirm() |
|
{ |
|
if (string.IsNullOrEmpty(TaskInput.text)) |
|
{ |
|
TaskInput.text = "待命"; |
|
} |
|
if (string.IsNullOrEmpty(TypeNameInput.text)) |
|
{ |
|
ResourceLoadWindow.Instance.LoadTextHintWindow("类型名不能为空", 2f); |
|
return; |
|
} |
|
PowerAttribute.Number = PlusMinusCtrl.Number; |
|
PowerAttribute.Affiliation = DropdownListData.SelectText; |
|
PowerAttribute.Task = TaskInput.text; |
|
PowerAttribute.TypeName = TypeNameInput.text; |
|
// MessageDispatcher.SendMessage("TaskChange", (object)TaskInput.text); |
|
if (RecordEvent.IsRecord()) |
|
{ |
|
string json = JsonUtility.ToJson(new PowerAttributeRecordEventData() |
|
{ |
|
GameId = selectobj.GetComponent<CloneGameObjInfo>().GameObjID, |
|
Task = PowerAttribute.Task, |
|
Affiliation = PowerAttribute.Affiliation, |
|
Number = PowerAttribute.Number, |
|
TypeName = PowerAttribute.TypeName |
|
}); |
|
RecordEvent.AddEventData(selectobj.GetComponent<CloneGameObjInfo>().gameObjType, RecordEventType.PowerAttribute, json); |
|
} |
|
TaskListobj.SetActive(false); |
|
powerattributepanel.SetActive(false); |
|
} |
|
public void SetAttribute(GameObject obj) |
|
{ |
|
gameObject.SetActive(true); |
|
powerattributepanel.SetActive(true); |
|
selectobj = obj; |
|
PowerAttribute = obj.GetComponent<PowerAttribute>(); |
|
ShowTaskList(PowerAttribute); |
|
DropdownListData.DataBind(TeamNameSetting.GetInstance.GetTeamNameList()); |
|
if (!TeamNameSetting.GetInstance.GetTeamNameList().Contains(PowerAttribute.Affiliation)) |
|
DropdownListData.AddData(PowerAttribute.Affiliation); |
|
DropdownListData.SelectText = PowerAttribute.Affiliation; |
|
TaskInput.text = PowerAttribute.Task; |
|
PlusMinusCtrl.Number = PowerAttribute.Number; |
|
TypeNameInput.text = PowerAttribute.TypeName; |
|
//if (obj.GetComponent<TruckMessages>()) |
|
//{ |
|
// TruckSkillSPanel.GetInstance.gameObject.SetActive(true); |
|
// MessageDispatcher.SendMessage("TruckSkillsPanelDraw", selectobj); |
|
//} |
|
//else if (obj.GetComponent<CloneGameObjInfo>().gameObjType == CloneObjType.FireMan) |
|
//{ |
|
// FireManSkillsPanel.GetInstance.gameObject.SetActive(true); |
|
// MessageDispatcher.SendMessage("FiremanSkillsPanelDraw", selectobj); |
|
//} |
|
} |
|
void ShowTaskList(PowerAttribute powerattribute) |
|
{ |
|
TaskListobj.SetActive(false); |
|
foreach (Transform item in Content) |
|
{ |
|
Destroy(item.gameObject); |
|
} |
|
if (powerattribute.Tasklist.Length > 0) |
|
{ |
|
for (int i = 0; i < powerattribute.Tasklist.Length; i++) |
|
{ |
|
var item = Instantiate(TaskItem, Content); |
|
item.GetComponent<Toggle>().group = Content.GetComponent<ToggleGroup>(); |
|
item.transform.Find("TaskName").GetComponent<Text>().text = powerattribute.Tasklist[i]; |
|
} |
|
} |
|
else |
|
{ |
|
var item = Instantiate(TaskItem, Content); |
|
item.GetComponent<Toggle>().group = Content.GetComponent<ToggleGroup>(); |
|
} |
|
} |
|
private void OnEnable() |
|
{ |
|
|
|
} |
|
private void OnDisable() |
|
{ |
|
powerattributepanel.SetActive(false); |
|
TaskListobj.SetActive(false); |
|
WaterFlowAttribute.GetInstance.gameObject.SetActive(false); |
|
} |
|
private void SetTypenametext() |
|
{ |
|
CloneObjType type = selectobj.GetComponent<BaseGameObjInfo>().gameObjType; |
|
if (Convert.ToInt32(type) < 19) |
|
{ |
|
TypeNameInput.text = "消防车"; |
|
} |
|
else if (type == CloneObjType.Robot) |
|
{ |
|
TypeNameInput.text = "机器人"; |
|
} |
|
else if (type == CloneObjType.BlizzardCannon) |
|
{ |
|
TypeNameInput.text = "暴风雪炮"; |
|
} |
|
else if (type == CloneObjType.WaterCannon) |
|
{ |
|
TypeNameInput.text = "移动水泡"; |
|
} |
|
else if (type == CloneObjType.FireMan) |
|
{ |
|
TypeNameInput.text = "消防员"; |
|
} |
|
} |
|
}
|
|
|