海淀天下城电子沙盘单机版
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.

70 lines
2.7 KiB

4 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CloneHeadquater : CloneSingleObj {
public override void Awake()
{
ResourcesName = "Prefab/Tool/Headquarter";
cloneObjType = CloneObjType.Headquarters;
base.Awake();
}
protected override void Clone()
{
var hitPoint = data.hitPos;
Vector3 clonedObjPos = new Vector3(hitPoint.x, hitPoint.y + Height, hitPoint.z);
CheckPos(clonedObjPos);
clonedObj = EntitiesManager.Instance.CreateObj(clonePrefab, clonedObjPos, transform, gameObjID);
clonedObj.name = gameObjID.ToString();//名字即ID
//clonedObj.name = CloneObjectTool.Instance().getCloneObjectName(cloneObjType);
////有需要的类型赋值头顶名
//string topname = CloneObjName.Instance.GetCloneNameByType(cloneObjType);
SelectedObjs.gameObjs.Add(clonedObj);
//设置克隆物体所在楼层属性,属性从点击的对象上获取
var hitObj = EntitiesManager.Instance.GetEntityByID(data.gameObjID);
number++;
CloneGameObjInfo objMsg = clonedObj.GetComponent<CloneGameObjInfo>();
objMsg.gameObjType = cloneObjType;
if (hitObj.GetComponent<CloneGameObjInfo>())
{
CloneGameObjInfo floorMsg = hitObj.GetComponent<CloneGameObjInfo>();
objMsg.buildNum = floorMsg.buildNum;
objMsg.floorNum = floorMsg.floorNum;
objMsg.interlayerNum = floorMsg.interlayerNum;
}
SetCloneGameObject(clonedObj);
AddRecordEventClone(clonedObj.transform);//测试
}
public override void SetCloneGameObject(GameObject obj)
{
obj.AddComponent<ObjSelectCtrl>();
//obj.AddComponent<ObjDrag>();
obj.AddComponent<OnDragAlongWindCheck>();
obj.AddComponent<ObjDelete>();
}
public void CheckPos(Vector3 pos)
{
if (ReplaySetting.PlayStatus != PlayStatus.isReplay)
{
int count = AlongWindCheck.CheckPos(pos);
if (count > 0)
{
ResourceLoadWindow.Instance.LoadTextHintWindow("未设置在上风向或侧风向", 2);
AddRecordAlongWindPosTipEvent();
}
}
}
private void AddRecordAlongWindPosTipEvent()
{
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
{
var eventData = new EventData();
eventData.time = RecordManager.Instance.RecordTimer;
eventData.cloneObjType = cloneObjType;
eventData.eventType = RecordEventType.AlongWindTip;
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
}
}
}