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.
166 lines
6.3 KiB
166 lines
6.3 KiB
using AX.Network.Protocols; |
|
using AX.Serialization; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using System; |
|
|
|
public class SPRAY_WATER_SYNC : NetworkMessageBehaviour |
|
{ |
|
private SprayParticleType NowType = SprayParticleType.WaterStraight; |
|
//public GameObject FrothPrefabs; |
|
//public GameObject WaterFlowerPrefabs; |
|
//public GameObject WaterFogPrefabs; |
|
//public GameObject WaterStraightPrefabs; |
|
private GameObject CurrentParticle; |
|
private Transform Hose; |
|
void Start() |
|
{ |
|
//NowType = SprayParticleType.WaterStraight; |
|
//{ |
|
// FrothPrefabs = Resources.Load<GameObject>("Particle/Froth"); |
|
//} |
|
//if (WaterFlowerPrefabs == null) |
|
// WaterFlowerPrefabs = Resources.Load<GameObject>("Particle/WaterFlower"); |
|
//if (WaterFogPrefabs == null) |
|
// WaterFogPrefabs = Resources.Load<GameObject>("Particle/WaterFog"); |
|
//if (WaterStraightPrefabs == null) |
|
// WaterStraightPrefabs = Resources.Load<GameObject>("Particle/WaterStraight"); |
|
} |
|
protected override void Execute(BinaryMessage message) |
|
{ |
|
InputHistory.Instance.RegisterInputHistory(message); |
|
|
|
//var sender = message.ID; |
|
var info = message.Body.Deserialize<SpraySyncData>(); |
|
if (InputManager.Instance) |
|
{ |
|
if (CurrentUserInfo.mySelf.Id != info.SendUserID) |
|
{ |
|
if (info.gameObjID == GetComponent<BaseGameObjInfo>().gameObjID) |
|
{ |
|
if (info.IsOn) |
|
{ |
|
Spraywater(info); |
|
} |
|
else |
|
{ |
|
GameObject Sprayobj = EntitiesManager.Instance.GetEntityByID(info.gameObjID); |
|
Hose = TransformHelper.FindChild(Sprayobj.transform, "Hose"); |
|
//消防员 |
|
if (Sprayobj.GetComponent<FireManControl>()) |
|
{ |
|
Sprayobj.GetComponent<LayWaterHose>().IsselfCurrent = false; |
|
Sprayobj.GetComponent<LayWaterHose>().EndLay(); |
|
Sprayobj.GetComponent<Animator>().SetBool("isInSitu", false); |
|
Hose.parent.gameObject.SetActive(false); |
|
} |
|
//消防车 |
|
if (Sprayobj.GetComponent<TruckMessage>()) |
|
{ |
|
Hose.gameObject.SetActive(false); |
|
} |
|
//移动水泡 |
|
if(Sprayobj.GetComponent<WaterConnonController>()) |
|
{ |
|
for (int i = 0; i < Hose.childCount; i++) |
|
{ |
|
Hose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
} |
|
//暴风雪炮 |
|
if (Sprayobj.GetComponent<SnowConnonController>()) |
|
{ |
|
for (int i = 0; i < Hose.childCount; i++) |
|
{ |
|
Hose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
} |
|
if (Sprayobj.GetComponent<FireRobotController>()) |
|
{//机器人 |
|
GetComponent<AgentController>().pathFindEnable = false; |
|
for (int i = 0; i < Hose.childCount; i++) |
|
{ |
|
Hose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
GetComponent<FireRobotLayWaterHose>().JugeLenght(); |
|
} |
|
} |
|
} |
|
|
|
} |
|
} |
|
//else |
|
//{ |
|
// NetworkSyncHelper.AddSyncData(info); |
|
//} |
|
|
|
} |
|
|
|
private void Spraywater(SpraySyncData data) |
|
{ |
|
GameObject sprayObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID); |
|
Hose = TransformHelper.FindChild(sprayObj.transform, "Hose"); |
|
if (sprayObj.GetComponent<FireManControl>()) |
|
{ |
|
sprayObj.GetComponent<LayWaterHose>().IsselfCurrent = false; |
|
sprayObj.GetComponent<LayWaterHose>().StartSprayingLay(); |
|
sprayObj.GetComponent<Animator>().SetBool("isInSitu", true); |
|
Hose.parent.gameObject.SetActive(true); |
|
} |
|
if (sprayObj.GetComponent<TruckMessage>()) |
|
{ |
|
Hose.gameObject.SetActive(true); |
|
} |
|
if (sprayObj.GetComponent<FireRobotController>()) |
|
{ |
|
sprayObj.GetComponent<FireRobotLayWaterHose>().StartSprayingLay(); |
|
sprayObj.GetComponent<FireRobotLayWaterHose>().IsselfCurrent = false; |
|
} |
|
SprayParticleType type = data.spraytype; |
|
switch (type) |
|
{ |
|
case SprayParticleType.Froth: |
|
setShowParticle(type, data.size); |
|
NowType = SprayParticleType.Froth; |
|
break; |
|
case SprayParticleType.WaterFlower: |
|
setShowParticle(type, data.size); |
|
NowType = SprayParticleType.WaterFlower; |
|
break; |
|
case SprayParticleType.WaterFog: |
|
setShowParticle(type, data.size); |
|
NowType = SprayParticleType.WaterFog; |
|
break; |
|
case SprayParticleType.WaterStraight: |
|
setShowParticle(type, data.size); |
|
NowType = SprayParticleType.WaterStraight; |
|
break; |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
private void setShowParticle(SprayParticleType type, float size) |
|
{ |
|
for (int i = 0; i < Hose.childCount; i++) |
|
{ |
|
// Destroy(Hose.GetChild(i).gameObject); |
|
if (Hose.GetChild(i).name == type.ToString()) |
|
{ |
|
Hose.GetChild(i).gameObject.SetActive(true); |
|
//CurrentParticle = Hose.GetChild(i).gameObject; |
|
} |
|
else |
|
{ |
|
Hose.GetChild(i).gameObject.SetActive(false); |
|
} |
|
} |
|
//Instantiate(prefabs, Hose); |
|
if (size != 0) |
|
{ |
|
Hose.GetComponentInChildren<ParticleControlOfType>().SetScaleValue(size); |
|
} |
|
} |
|
}
|
|
|