第一次提交
This commit is contained in:
158
Assets/Scripts/UI/UIMonsterItem_old.cs
Normal file
158
Assets/Scripts/UI/UIMonsterItem_old.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using HxGame.Data;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIMonsterItem_old : MonoBehaviour
|
||||
{
|
||||
public InputField txtID; //<2F><><EFBFBD><EFBFBD>ID
|
||||
public Dropdown dropType; //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtRadius; //<2F>뾶
|
||||
public InputField txtNum; //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtTime; //ˢ<><CBA2>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8><EFBFBD>룩
|
||||
public Dropdown dropPatrol; //Ѳ<><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtPath; //NPC·<43><C2B7>
|
||||
|
||||
public Button btnDel; //ɾ<><C9BE>
|
||||
public List<string> paths;
|
||||
public int itemIdx;
|
||||
public int pathIdx;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
AddInputNameClickEvent(txtPos);
|
||||
AddInputNameClickEvent(txtPath, true);
|
||||
btnDel.onClick.AddListener(RemoveSelf);
|
||||
itemIdx = 0;
|
||||
paths = new List<string>();
|
||||
}
|
||||
|
||||
private void AddInputNameClickEvent(InputField input, bool isPath = false) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Awake<6B>е<EFBFBD><D0B5><EFBFBD>
|
||||
{
|
||||
var eventTrigger = input.gameObject.AddComponent<EventTrigger>();
|
||||
UnityAction<BaseEventData> selectEvent = null;
|
||||
if (isPath)
|
||||
selectEvent = OnPathInputFieldClicked;
|
||||
else
|
||||
selectEvent = OnInputFieldClicked;
|
||||
|
||||
EventTrigger.Entry onClick = new EventTrigger.Entry()
|
||||
{
|
||||
eventID = EventTriggerType.PointerClick
|
||||
};
|
||||
|
||||
onClick.callback.AddListener(selectEvent);
|
||||
eventTrigger.triggers.Add(onClick);
|
||||
}
|
||||
|
||||
private void OnInputFieldClicked(BaseEventData data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtID.text))
|
||||
return;
|
||||
if (string.IsNullOrEmpty(txtRadius.text))
|
||||
return;
|
||||
if (string.IsNullOrEmpty(txtNum.text))
|
||||
return;
|
||||
|
||||
//UIWindow.Instance.uiMonstersPanel_old.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
MapManager.Instance.SetMonsterPoint(itemIdx, Convert.ToInt32(txtRadius.text), Convert.ToInt32(txtID.text), Convert.ToInt32(txtNum.text));
|
||||
MapManager.Instance.SetEditCellType(MapManager.EditCellType.MonsterArea);
|
||||
}
|
||||
|
||||
private void OnPathInputFieldClicked(BaseEventData data)
|
||||
{
|
||||
//UIWindow.Instance.uiMonstersPanel_old.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
//UIWindow.Instance.uiMonstersPanel_old.curActiveList = paths;
|
||||
MapManager.Instance.SetCurMonsterPathIdx(pathIdx);
|
||||
MapManager.Instance.SetEditCellType(MapManager.EditCellType.MonsterPath);
|
||||
}
|
||||
|
||||
private void RemoveSelf()
|
||||
{
|
||||
DestroyImmediate(gameObject);
|
||||
MapManager.Instance.RemoveMonsterPoint(itemIdx);
|
||||
}
|
||||
|
||||
public bool CheckValid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtID.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ID");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtPos.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtRadius.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4>ְ뾶");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtNum.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(txtTime.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4><CBA2>ʱ<EFBFBD><CAB1>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dropType.value == (int)CreateMonsterMode.Death)
|
||||
{
|
||||
if(!APIs.IsUInt(txtTime.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("ˢ<><CBA2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(dropType.value == (int)CreateMonsterMode.FixedTime)
|
||||
{
|
||||
string[] tmp = txtTime.text.Split(',');
|
||||
if (tmp.Length != 2)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("ˢ<><CBA2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!APIs.IsUInt(tmp[0]))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("ˢ<><CBA2>ʱ<EFBFBD><CAB1>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
string[] strTime = tmp[1].Split(':');
|
||||
if (strTime.Length != 2)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("ˢ<><CBA2>ʱ<EFBFBD><CAB1>-ʱ<><CAB1><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < strTime.Length; i++)
|
||||
{
|
||||
if (!APIs.IsUInt(strTime[i]))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("ˢ<><CBA2>ʱ<EFBFBD><CAB1>-ʱ<><CAB1><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user