107 lines
3.0 KiB
C#
107 lines
3.0 KiB
C#
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 UIFuBenItem : UIBaseItem
|
|
{
|
|
public InputField txtOrder; //怪物波次
|
|
public InputField txtID; //怪物ID
|
|
public InputField txtPos; //中心点坐标
|
|
public InputField txtRadius; //半径
|
|
public InputField txtNum; //刷怪数量
|
|
public InputField txtTime; //刷怪时间(毫秒)
|
|
|
|
|
|
public Button btnDel; //删除
|
|
public int itemIdx;
|
|
|
|
// Start is called before the first frame update
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
AddInputNameClickEvent(txtPos);
|
|
btnDel.onClick.AddListener(RemoveSelf);
|
|
itemIdx = 0;
|
|
}
|
|
|
|
private void AddInputNameClickEvent(InputField input) //可以在Awake中调用
|
|
{
|
|
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(txtNum.text))
|
|
return;
|
|
|
|
UIWindow.Instance.uiFuBensPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
|
MapManager.Instance.SetCurFuBenCenterPoint(itemIdx, Convert.ToInt32(txtRadius.text), Convert.ToInt32(txtID.text), Convert.ToInt32(txtNum.text));
|
|
MapManager.Instance.SetEditCellType(MapManager.EditCellType.FuBenArea);
|
|
}
|
|
|
|
private void RemoveSelf()
|
|
{
|
|
DestroyImmediate(gameObject);
|
|
MapManager.Instance.RemoveMonsterPoint(itemIdx);
|
|
}
|
|
|
|
public bool CheckValid()
|
|
{
|
|
if (string.IsNullOrEmpty(txtID.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("请填写怪物ID");
|
|
return false;
|
|
}
|
|
if (string.IsNullOrEmpty(txtPos.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("请填写刷怪坐标");
|
|
return false;
|
|
}
|
|
if (string.IsNullOrEmpty(txtRadius.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("请填写刷怪半径");
|
|
return false;
|
|
}
|
|
if (string.IsNullOrEmpty(txtNum.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("请填写刷怪数量");
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(txtTime.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("请填写刷怪时间");
|
|
return false;
|
|
}
|
|
|
|
|
|
if(!APIs.IsUInt(txtTime.text))
|
|
{
|
|
UIWindow.Instance.ShowMessage("刷怪时间请输入正整数");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|