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.
216 lines
9.5 KiB
216 lines
9.5 KiB
4 years ago
|
using AX.MessageSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class SnowConnonSkillPanelController : MonoBehaviour {
|
||
|
|
||
|
[Rename("出水")]
|
||
|
public ToggleRecordByAC SprayWater;
|
||
|
[Rename("出泡沫")]
|
||
|
public ToggleRecordByAC SprayFoam;
|
||
|
|
||
|
public GameObject SelectSnowConnon;
|
||
|
private static SnowConnonSkillPanelController instance;
|
||
|
private LayWaterPanel laywaterpanel;
|
||
|
public static SnowConnonSkillPanelController Instance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return instance;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Use this for initialization
|
||
|
void Start()
|
||
|
{
|
||
|
instance = this;
|
||
|
laywaterpanel = GetComponent<LayWaterPanel>();
|
||
|
SprayWater.OutInterFaceToggle = SprayToggleChange;
|
||
|
SprayFoam.OutInterFaceToggle = SprayFoamChange;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 选中移动水泡时的UI显示
|
||
|
/// </summary>
|
||
|
/// <param name="select"></param>
|
||
|
public void SetSnowConnon(GameObject select)
|
||
|
{
|
||
|
SelectSnowConnon = select;
|
||
|
if (select.GetComponent<SnowConnonController>().hasWaterConnect)
|
||
|
{
|
||
|
SprayWater.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SprayWater.GetComponent<Toggle>().interactable = false;
|
||
|
}
|
||
|
if (select.GetComponent<SnowConnonController>().hasFoamConnect)
|
||
|
{
|
||
|
SprayFoam.GetComponent<Toggle>().interactable = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SprayFoam.GetComponent<Toggle>().interactable = false;
|
||
|
}
|
||
|
switch (select.GetComponent<SnowConnonController>().skill)
|
||
|
{
|
||
|
case SnowCannonSkill.喷水:
|
||
|
SprayWater.GetComponent<Toggle>().isOn = true;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(true);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
break;
|
||
|
case SnowCannonSkill.喷泡沫:
|
||
|
SprayFoam.GetComponent<Toggle>().isOn = true;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(true);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
break;
|
||
|
case SnowCannonSkill.None:
|
||
|
//ResertUI();
|
||
|
SprayWater.GetComponent<Toggle>().isOn = false;
|
||
|
SprayFoam.GetComponent<Toggle>().isOn = false;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(false);
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private void SprayToggleChange(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
if (SelectSnowConnon.GetComponent<SnowConnonController>().skill == SnowCannonSkill.喷水)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
float remian= SelectSnowConnon.GetComponent<SnowConnonController>().CheckWaterRemain(SelectSnowConnon.GetComponent<SnowConnonController>().WaterSourceLine);
|
||
|
if (!(remian>0||remian==-100))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足",1f);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().skill = SnowCannonSkill.喷水;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(true);
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Spray(SnowCannonSkill.喷水);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
//连接水源流量设置
|
||
|
// MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
//出水同步
|
||
|
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.spraytype = SprayParticleType.WaterStraight;
|
||
|
spraysync.IsOn = true;
|
||
|
spraysync.size = SelectSnowConnon.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue();
|
||
|
spraysync.gameObjID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
// spraysync.UserID = selectMoveWaterConnon.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
// spraysync.gameObjType = selectMoveWaterConnon.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Spray(SnowCannonSkill.None);
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().skill = SnowCannonSkill.None;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(false);
|
||
|
//连接水源流量设置
|
||
|
//MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
|
||
|
if (SelectSnowConnon.GetComponent<SnowConnonController>().Flow != 0)
|
||
|
{
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Flow = 0;
|
||
|
}
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.spraytype = SprayParticleType.WaterStraight;
|
||
|
spraysync.IsOn = false;
|
||
|
spraysync.size = SelectSnowConnon.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue();
|
||
|
spraysync.gameObjID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
//spraysync.UserID = selectMoveWaterConnon.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
//spraysync.gameObjType = selectMoveWaterConnon.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
}
|
||
|
private void SprayFoamChange(bool value)
|
||
|
{
|
||
|
if (value)
|
||
|
{
|
||
|
if (SelectSnowConnon.GetComponent<SnowConnonController>().skill == SnowCannonSkill.喷泡沫)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
float remian = SelectSnowConnon.GetComponent<SnowConnonController>().CheckWaterRemain(SelectSnowConnon.GetComponent<SnowConnonController>().WaterSourceLine);
|
||
|
if (!(remian > 0 || remian == -100))
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足", 1f);
|
||
|
return;
|
||
|
}
|
||
|
float remianfoam = SelectSnowConnon.GetComponent<SnowConnonController>().CheckFoamRemain();
|
||
|
if (!(remianfoam==-100||remianfoam>0))
|
||
|
{//没泡沫
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("剩余泡沫量不足", 1f);
|
||
|
return;
|
||
|
}
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().skill = SnowCannonSkill.喷泡沫;
|
||
|
laywaterpanel.laywater.gameObject.SetActive(true);
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Spray(SnowCannonSkill.喷泡沫);
|
||
|
GetComponent<LayWaterPanel>().SetShowEnable();
|
||
|
//连接水源流量设置
|
||
|
// MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
|
||
|
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.spraytype = SprayParticleType.Froth;
|
||
|
spraysync.IsOn = true;
|
||
|
spraysync.size = SelectSnowConnon.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue();
|
||
|
spraysync.gameObjID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
spraysync.UserID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
spraysync.gameObjType = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Spray(SnowCannonSkill.None);
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().skill = SnowCannonSkill.None;
|
||
|
if (SelectSnowConnon.GetComponent<SnowConnonController>().Flow!=0)
|
||
|
{
|
||
|
SelectSnowConnon.GetComponent<SnowConnonController>().Flow = 0;
|
||
|
}
|
||
|
laywaterpanel.laywater.gameObject.SetActive(false);
|
||
|
//连接水源流量设置
|
||
|
// MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID });
|
||
|
|
||
|
|
||
|
SpraySyncData spraysync = new SpraySyncData();
|
||
|
spraysync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
spraysync.spraytype = SprayParticleType.WaterStraight;
|
||
|
spraysync.IsOn = false;
|
||
|
spraysync.size = SelectSnowConnon.GetComponentInChildren<ParticleControlOfType>(true).GetScaleValue();
|
||
|
spraysync.gameObjID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
spraysync.UserID = SelectSnowConnon.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
spraysync.gameObjType = SelectSnowConnon.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync);
|
||
|
}
|
||
|
}
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
private void ResertUI()
|
||
|
{
|
||
|
Toggle[] all = transform.GetComponentsInChildren<Toggle>(true);
|
||
|
for (int i = 0; i < all.Length; i++)
|
||
|
{
|
||
|
all[i].isOn = false;
|
||
|
}
|
||
|
}
|
||
|
}
|