第一次提交
This commit is contained in:
116
Assets/Scripts/UI/UIJuBaoItem.cs
Normal file
116
Assets/Scripts/UI/UIJuBaoItem.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
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 UIJuBaoItem : MonoBehaviour
|
||||
{
|
||||
public InputField txtID; //<2F><><EFBFBD><EFBFBD>ID
|
||||
public InputField txtKillCount; //<2F><>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>
|
||||
public InputField txtInterval; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
public InputField txtCurCount; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
||||
public InputField txtRefreshCount; //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtRadius; //<2F>뾶
|
||||
|
||||
|
||||
|
||||
public Button btnDel; //ɾ<><C9BE>
|
||||
public int itemIdx;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
AddInputNameClickEvent(txtPos);
|
||||
btnDel.onClick.AddListener(RemoveSelf);
|
||||
itemIdx = 0;
|
||||
}
|
||||
|
||||
private void AddInputNameClickEvent(InputField input) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Awake<6B>е<EFBFBD><D0B5><EFBFBD>
|
||||
{
|
||||
var eventTrigger = input.gameObject.AddComponent<EventTrigger>();
|
||||
UnityAction<BaseEventData> selectEvent = null;
|
||||
|
||||
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(txtKillCount.text))
|
||||
return;
|
||||
if (string.IsNullOrEmpty(txtInterval.text))
|
||||
return;
|
||||
if (string.IsNullOrEmpty(txtCurCount.text))
|
||||
return;
|
||||
if (string.IsNullOrEmpty(txtRefreshCount.text))
|
||||
return;
|
||||
|
||||
UIWindow.Instance.uiJuBaosPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
MapManager.Instance.SetCurJuBaoCenterPoint(itemIdx, Convert.ToInt32(txtRadius.text), Convert.ToInt32(txtID.text));
|
||||
MapManager.Instance.SetEditCellType(MapManager.EditCellType.JuBaoArea);
|
||||
}
|
||||
|
||||
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(txtKillCount.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(txtInterval.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtCurCount.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtRefreshCount.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>дˢ<D0B4><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user