上海杨浦大连路地铁站单机版电子沙盘
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.
 
 
 
 

105 lines
2.9 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using AX.MessageSystem;
using System;
using UnityEngine.EventSystems;
public class EquipNumSelectPanel : ResourceLoadPanel<EquipNumSelectPanel>
{
private Text select;
private Text selectNumAlready;
private Toggle togglechoose;
private InputField inputField;
private void Awake()
{
select = transform.Find("Select").GetComponent<Text>();
selectNumAlready = transform.Find("SelectNumAlready").GetComponent<Text>();
inputField = transform.Find("InputField").GetComponent<InputField>();
MessageDispatcher.AddListener("EquipItemSelectMore", SelectMore);
}
private void OnEnable()
{
MessageDispatcher.AddListener("EquipItemSelectMore", SelectMore);
}
private void OnDisable()
{
MessageDispatcher.RemoveListener("EquipItemSelectMore", SelectMore);
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("EquipItemSelectMore", SelectMore);
}
private void SelectMore(IMessage obj)
{
Toggle sender = (Toggle)obj.Data;
if (sender.isOn)
{
if (!gameObject.activeInHierarchy)
{
gameObject.SetActive(true);
}
togglechoose = sender;
select.text = sender.name;
Equip eq = EquipSelect.GetInstance.GetEquipFromSelectByName(sender.name);
if (eq == null)
{//之前未加到提交清单中
selectNumAlready.text = "0";
inputField.text = "0";
}
else
{
selectNumAlready.text = eq.Number.ToString();
inputField.text = eq.Number.ToString();
}
}
}
public void Input(string value)
{
if (value.Length == 0)
{
value = "0";
}
}
public void Sure()
{
int tmp;
Equip select = EquipSelect.GetInstance.GetInitEquipByName(togglechoose.name);
select.Number = int.Parse(inputField.text);
MessageDispatcher.SendMessage("EquipAddSubmit", select);
Debug.Log(inputField.text);
Close();
}
public void Add()
{
int inp = int.Parse(inputField.text);
inputField.text = (inp + 1).ToString();
}
public void Minu()
{
int inp = int.Parse(inputField.text);
if (inp > 0)
{
inputField.text = (inp - 1).ToString();
}
}
public void Close( )
{
gameObject.SetActive(false);
togglechoose.isOn = false;
if (int.Parse( inputField.text) > 0)
{
togglechoose.GetComponent<EquipItemSelect>().SetImgShow(int.Parse(inputField.text));
}
else
{
togglechoose.GetComponent<EquipItemSelect>().SetImgHide();
}
}
}