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.
115 lines
3.2 KiB
115 lines
3.2 KiB
3 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 战术设置内容结构体
|
||
|
/// </summary>
|
||
|
//public struct Tactic
|
||
|
//{
|
||
|
// public string Name { get; set; }
|
||
|
// public List<MobileCFFSInfo.Vector2> Locations { get; set; }
|
||
|
// public string Position { get; set; }
|
||
|
|
||
|
// public string Detail { get; set; }
|
||
|
//}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 战术设置窗口
|
||
|
/// </summary>
|
||
|
public class TacticSetting : MonoBehaviour {
|
||
|
|
||
|
private Text Title;
|
||
|
private InputField PosInputField;
|
||
|
private InputField DetailInputField;
|
||
|
private Button SureButton;
|
||
|
private Button CancelButton;
|
||
|
private Button CloseBtn;
|
||
|
|
||
|
//当前要设置战术内容的战术模型实体
|
||
|
public GameObject tacticGameObj;
|
||
|
|
||
|
// Use this for initialization
|
||
|
void Start () {
|
||
|
|
||
|
Title = transform.Find("Title").GetComponent<Text>();
|
||
|
|
||
|
PosInputField = transform.Find("PosInputField").GetComponent<InputField>();
|
||
|
DetailInputField = transform.Find("DetailInputField").GetComponent<InputField>();
|
||
|
|
||
|
SureButton = transform.Find("SureButton").GetComponent<Button>();
|
||
|
SureButton.onClick.AddListener(Sure);
|
||
|
CancelButton = transform.Find("CancelButton").GetComponent<Button>();
|
||
|
CancelButton.onClick.AddListener(Cancel);
|
||
|
|
||
|
CloseBtn = transform.Find("CloseButton").GetComponent<Button>();
|
||
|
CloseBtn.onClick.AddListener(CloseTacticSettingWin);
|
||
|
|
||
|
//先注册上弹出战术设置窗事件,再设置默认隐藏
|
||
|
MessageDispatcher.AddListener("POPUP_TACTICSETTING_WIN", Popup);
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
private void Sure()
|
||
|
{
|
||
|
//Tactic tactic = new Tactic();
|
||
|
//tactic.Name = Title.text;
|
||
|
//tactic.Position = PosInputField.text;
|
||
|
//tactic.Detail = DetailInputField.text;
|
||
|
|
||
|
//tacticGameObj.GetComponent<TacticMessage>().tactic = tactic;
|
||
|
|
||
|
tacticGameObj.GetComponent<TacticMessage>().tactic.Name = Title.text;
|
||
|
tacticGameObj.GetComponent<TacticMessage>().tactic.Position = PosInputField.text;
|
||
|
tacticGameObj.GetComponent<TacticMessage>().tactic.Detail = DetailInputField.text;
|
||
|
|
||
|
//隐藏设置窗口
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
private void Cancel()
|
||
|
{
|
||
|
//隐藏设置窗口
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
private void CloseTacticSettingWin()
|
||
|
{
|
||
|
//隐藏设置窗口
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
private void Popup(IMessage obj)
|
||
|
{
|
||
|
tacticGameObj = (GameObject)obj.Sender;
|
||
|
|
||
|
MobileCFFSInfo.Tactic info = (MobileCFFSInfo.Tactic)obj.Data;
|
||
|
|
||
|
Title.text = info.Name;
|
||
|
PosInputField.text = info.Position;
|
||
|
DetailInputField.text = info.Detail;
|
||
|
|
||
|
//显示设置窗口
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
SureButton.onClick.RemoveListener(Sure);
|
||
|
|
||
|
CancelButton.onClick.RemoveListener(Cancel);
|
||
|
|
||
|
CloseBtn.onClick.RemoveListener(CloseTacticSettingWin);
|
||
|
|
||
|
MessageDispatcher.RemoveListener("POPUP_TACTICSETTING_WIN", Popup);
|
||
|
}
|
||
|
}
|