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.
162 lines
5.2 KiB
162 lines
5.2 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class ForciblePanel : BaseAttributeSet
|
||
|
{
|
||
|
private SliderRecordByAC SliderHight;
|
||
|
private SliderRecordByAC SliderWidth;
|
||
|
private ButtonRecordByAC Sure;
|
||
|
private ButtonRecordByAC Cancel;
|
||
|
private GameObject selectObjLast;
|
||
|
|
||
|
|
||
|
private static ForciblePanel instance;
|
||
|
|
||
|
public static ForciblePanel Instance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (instance == null)
|
||
|
{
|
||
|
GameObject obj = Resources.Load<GameObject>("Common/ForciblePanel");
|
||
|
GameObject clone = Instantiate(obj, GameObject.Find("Canvas").transform);
|
||
|
clone.transform.SetAsLastSibling();
|
||
|
clone.name = "ForciblePanel";
|
||
|
clone.transform.position = Vector3.zero;
|
||
|
instance = clone.GetComponent<ForciblePanel>();
|
||
|
instance.Init();
|
||
|
}
|
||
|
return instance;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void Init()
|
||
|
{
|
||
|
SliderHight = transform.Find("SliderHight").GetComponent<SliderRecordByAC>();
|
||
|
SliderWidth = transform.Find("SliderWidth").GetComponent<SliderRecordByAC>();
|
||
|
Sure = transform.Find("SureButton").GetComponent<ButtonRecordByAC>();
|
||
|
Cancel = transform.Find("CancelButton").GetComponent<ButtonRecordByAC>();
|
||
|
SliderHight.OutInterFaceSlider = SliderHightChange;
|
||
|
SliderWidth.OutInterFaceSlider = SliderWidthChange;
|
||
|
Sure.OutInterFaceButton = SureClick;
|
||
|
Cancel.OutInterFaceButton = CancelClick;
|
||
|
}
|
||
|
|
||
|
public override void OnDisable()
|
||
|
{
|
||
|
base.OnDisable();
|
||
|
Close();
|
||
|
}
|
||
|
|
||
|
public override void OpenPanel()
|
||
|
{
|
||
|
base.OpenPanel();
|
||
|
LoadUIDisaster();
|
||
|
gameObject.SetActive(true);
|
||
|
}
|
||
|
|
||
|
private void LoadUIDisaster()
|
||
|
{
|
||
|
if (GameSettings.othersSettings.isSelectedDisaster)
|
||
|
{
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{//若是练习或演习模式进入导调组界面,则不可以修改
|
||
|
//Minput.GetComponent<InputField>().interactable = false;
|
||
|
//Sinput.GetComponent<InputField>().interactable = false;
|
||
|
//Sure.GetComponent<Button>().interactable = false;
|
||
|
|
||
|
|
||
|
|
||
|
//Cancel.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (!GameSettings.disasterSetting.isEdit)
|
||
|
{//若是灾情库设置模式的查看,则不可以修改
|
||
|
SliderHight.GetComponent<Slider>().interactable = false;
|
||
|
SliderWidth.GetComponent<Slider>().interactable = false;
|
||
|
Sure.GetComponent<Button>().interactable = false;
|
||
|
//Cancel.GetComponent<Button>().interactable = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//若是灾情库设置模式的编辑,则可以修改
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void CancelClick()
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("CANCEL_OBJ_SELECTED");
|
||
|
Close();
|
||
|
}
|
||
|
|
||
|
private void SureClick()
|
||
|
{
|
||
|
if (chooseObj && chooseObj.GetComponent<ForcibleCtrl>())
|
||
|
{
|
||
|
|
||
|
chooseObj.GetComponent<ForcibleCtrl>().Set(SliderHight.GetComponent<Slider>().value, SliderWidth.GetComponent<Slider>().value);
|
||
|
// MessageDispatcher.SendMessage("CANCEL_OBJ_SELECTED");
|
||
|
|
||
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
||
|
{
|
||
|
ForcibleSyncData data = new ForcibleSyncData()
|
||
|
{
|
||
|
gameObjID = chooseObj.GetComponent<CloneGameObjInfo>().gameObjID,
|
||
|
Hight= SliderHight.GetComponent<Slider>().value,
|
||
|
Width= SliderWidth.GetComponent<Slider>().value
|
||
|
};
|
||
|
|
||
|
data.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
NetworkManager.Default.SendAsync("FORCIBLE_SCALE_SYNC", data);
|
||
|
}
|
||
|
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("设置成功", 1f);
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public void Close(bool IsNotSuerClose = true)
|
||
|
{
|
||
|
if (chooseObj&& chooseObj.GetComponent<ForcibleCtrl>())
|
||
|
{
|
||
|
chooseObj.GetComponent<ForcibleCtrl>().ResertAtOpenData();
|
||
|
|
||
|
gameObject.SetActive(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SliderHightChange( float value)
|
||
|
{
|
||
|
chooseObj.GetComponent<ForcibleCtrl>().Hight = value;
|
||
|
}
|
||
|
|
||
|
private void SliderWidthChange( float value)
|
||
|
{
|
||
|
chooseObj.GetComponent<ForcibleCtrl>().Width = value;
|
||
|
}
|
||
|
|
||
|
public override void LoadObjData()
|
||
|
{
|
||
|
if (chooseObj && chooseObj.GetComponent<ForcibleCtrl>())
|
||
|
{
|
||
|
chooseObj.GetComponent<ForcibleCtrl>().RecordOpenData();
|
||
|
}
|
||
|
SliderHight.GetComponent<Slider>().value = chooseObj.GetComponent<ForcibleCtrl>().hightOpen;
|
||
|
SliderWidth.GetComponent<Slider>().value = chooseObj.GetComponent<ForcibleCtrl>().widthOpen;
|
||
|
}
|
||
|
public override void ResetData(GameObject dataObj)
|
||
|
{
|
||
|
Close();
|
||
|
}
|
||
|
}
|