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.
92 lines
2.7 KiB
92 lines
2.7 KiB
using UnityEngine; |
|
using System; |
|
using UnityEngine.EventSystems; |
|
|
|
public enum TaskType { none, Character, Car, Text, WaterMonitor } |
|
public class PowerController : MonoBehaviour |
|
{ |
|
public CreationMode PowerMode; |
|
public TaskType taskType; |
|
public string PrefabName; |
|
public string Remarks; |
|
public GameObject RemarksObj; |
|
|
|
DateTime t1, t2; |
|
|
|
private void Start() |
|
{ |
|
if (transform.Find("Info") != null) |
|
{ |
|
GameObject info = transform.Find("Info").gameObject; |
|
info.SetChildrenActive(!PowerManager.Instance.isHideName); |
|
|
|
RemarksObj = info.transform.Find("Remarks").gameObject; |
|
|
|
if (!string.IsNullOrEmpty(Remarks)) |
|
RemarksObj.SetActive(true); |
|
else |
|
RemarksObj.SetActive(false); |
|
} |
|
} |
|
void OnMouseDown() |
|
{ |
|
if (!EventSystem.current.IsPointerOverGameObject()) |
|
{ |
|
//if (GetComponent<GaoPenCheController>()) |
|
//{ |
|
// AssetManager.GaoPenChe = this.gameObject; |
|
// UIPanel.Show<GaoPenCheControlPanel>(); |
|
//} |
|
//if (GetComponent<DengGaoCheController>()) |
|
//{ |
|
// AssetManager.DengGaoChe = this.gameObject; |
|
// UIPanel.Show<DengGaoCheControlPanel>(); |
|
//} |
|
//if (GetComponent<YunTiCheController>()) |
|
//{ |
|
// AssetManager.YunTiChe = this.gameObject; |
|
// UIPanel.Show<YunTiCheControlPanel>(); |
|
//} |
|
PowerManager.Instance.taskType = taskType; |
|
t2 = DateTime.Now; |
|
if (t2 - t1 < new TimeSpan(0, 0, 0, 0, 500)) |
|
{ |
|
OnPowerAttribute(); |
|
} |
|
t1 = t2; |
|
} |
|
|
|
} |
|
|
|
void OnPowerAttribute() |
|
{ |
|
|
|
if (taskType != TaskType.none) |
|
{ |
|
UIManager.Instance.Show<PowerAttributePanel>(SetInfo); |
|
} |
|
} |
|
|
|
private void SetInfo() |
|
{ |
|
var PA = UIManager.Instance.GetView<PowerAttributePanel>(); |
|
if (this.transform.Find("Info/Name")) |
|
{ |
|
var name = this.transform.Find("Info/Name").GetComponent<TextMesh>().text; |
|
if (name.Contains("-")) |
|
{ |
|
string[] texts = name.Split('-'); |
|
PA.UnitInput.text = texts[0]; |
|
PA.NumberInput.text = texts[1]; |
|
} |
|
else |
|
{ |
|
PA.UnitInput.text = name; |
|
PA.NumberInput.text = "0"; |
|
} |
|
} |
|
var task = this.transform.Find("Info/Task").GetComponent<TextMesh>().text; |
|
PA.TaskInput.text = task; |
|
PA.RemarksInput.text = Remarks; |
|
} |
|
}
|
|
|