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.
79 lines
3.3 KiB
79 lines
3.3 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.MessageSystem;
|
||
|
using UnityEngine;
|
||
|
using AX.InputSystem;
|
||
|
using AX.NetworkSystem;
|
||
|
|
||
|
public class CloneWaterCannon : CloneBase
|
||
|
{
|
||
|
[SerializeField]
|
||
|
[Tooltip("距离地面距离")]
|
||
|
protected float Height = 0;
|
||
|
private MoveWaterCannonTool movetool;
|
||
|
|
||
|
public override void Execute(IMessage obj)
|
||
|
{
|
||
|
var gameObjID = (long)obj.Sender;
|
||
|
var data = ((CloneCmdArgs)obj.Data);
|
||
|
if (data.cloneObjType == cloneObjType)
|
||
|
{
|
||
|
if (SkillTollPanel.Instance)
|
||
|
{
|
||
|
if (SkillTollPanel.Instance.GetComponent<MoveWaterCannonTool>())
|
||
|
{
|
||
|
movetool = SkillTollPanel.Instance.GetComponent<MoveWaterCannonTool>();
|
||
|
}
|
||
|
}
|
||
|
if (int.Parse(movetool.moveCannonnumtext.text)<=0)
|
||
|
{
|
||
|
LoadPromptWin.Instance.LoadTextPromptWindow("移动水炮数量不足",1f);
|
||
|
return;
|
||
|
}
|
||
|
var hitPoint = data.hitPos;
|
||
|
|
||
|
Vector3 clonedObjPos = new Vector3(hitPoint.x, hitPoint.y + Height, hitPoint.z);
|
||
|
|
||
|
var clonedObj = EntitiesManager.Instance.CreateObj(clonePrefab, clonedObjPos, transform, gameObjID);
|
||
|
|
||
|
clonedObj.name = CloneObjNameTool.Instance().GetCloneObjectName(cloneObjType);
|
||
|
|
||
|
SelectedObjs.gameObjs.Add(clonedObj);
|
||
|
|
||
|
//设置克隆物体所在楼层等基本属性,属性从点击的对象上获取
|
||
|
var hitObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID);
|
||
|
CloneGameObjInfo hitObjInfo = hitObj.GetComponent<CloneGameObjInfo>();
|
||
|
CloneGameObjInfo cloneObjInfo = clonedObj.GetComponent<CloneGameObjInfo>();
|
||
|
cloneObjInfo.gameObjType = cloneObjType;
|
||
|
cloneObjInfo.UserID = CurrentUserInfo.mySelf.Id;
|
||
|
cloneObjInfo.buildNum = hitObjInfo.buildNum;
|
||
|
cloneObjInfo.floorNum = hitObjInfo.floorNum;
|
||
|
cloneObjInfo.interlayerNum = hitObjInfo.interlayerNum;
|
||
|
|
||
|
if (data.cloneObjType == CloneObjType.WaterCannon)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("CreatExpendToolNum", cloneObjType);
|
||
|
}
|
||
|
|
||
|
//克隆同步
|
||
|
CloneDisasterSyncData clonesync = new CloneDisasterSyncData();
|
||
|
clonesync.ClonePosition = clonedObjPos;
|
||
|
clonesync.SendUserID = CurrentUserInfo.mySelf.Id;
|
||
|
//clonesync.parentUID =GetComponent<UIdSystem>().Id;
|
||
|
clonesync.name = clonedObj.name;
|
||
|
//clonesync.PrefabsPath = PrefabsPath + cloneObjType.ToString();
|
||
|
clonesync.floorNum = hitObjInfo.floorNum;
|
||
|
clonesync.buildNum = hitObjInfo.buildNum;
|
||
|
clonesync.interlayerNum = hitObjInfo.interlayerNum;
|
||
|
clonesync.gameObjID = clonedObj.GetComponent<BaseGameObjInfo>().gameObjID;
|
||
|
clonesync.gameObjType = clonedObj.GetComponent<BaseGameObjInfo>().gameObjType;
|
||
|
clonesync.UserID = clonedObj.GetComponent<BaseGameObjInfo>().UserID;
|
||
|
clonesync.HitObjID = hitObjInfo.gameObjID;
|
||
|
//NetworkManager.Default.SendAsync(CurrentUserInfo.mySelf.Id,"CLONE_SINGLE_DISASTER_SYNC", clonesync);
|
||
|
NetworkManager.Default.SendAsync("CLONE_WATER_CANNON_SYNC", clonesync);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|