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.
95 lines
3.7 KiB
95 lines
3.7 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class CloneBoilover : CloneSingleObj
|
||
|
{
|
||
|
|
||
|
private GameObject ClonedObj;
|
||
|
private float dis = 0;
|
||
|
void Start()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
protected override void Clone()
|
||
|
{
|
||
|
var hitPoint = data.hitPos;
|
||
|
Vector3 clonedObjPos = new Vector3(hitPoint.x, hitPoint.y + Height, hitPoint.z);
|
||
|
ClonedObj = EntitiesManager.Instance.CreateObj(clonePrefab, clonedObjPos, transform, gameObjID);
|
||
|
//ClonedObj.name = cloneObjType.ToString() + number++;
|
||
|
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);
|
||
|
CloneGameObjInfo floorMsg = hitObj.GetComponent<CloneGameObjInfo>();
|
||
|
CloneGameObjInfo objMsg = ClonedObj.GetComponent<CloneGameObjInfo>();
|
||
|
objMsg.gameObjType = cloneObjType;
|
||
|
objMsg.buildNum = floorMsg.buildNum;
|
||
|
objMsg.floorNum = floorMsg.floorNum;
|
||
|
objMsg.interlayerNum = floorMsg.interlayerNum;
|
||
|
|
||
|
RaycastHit[] AllHit = Physics.RaycastAll(hitPoint, Vector3.down, 100f, LayerMask.NameToLayer("SoliderRoad"));
|
||
|
foreach (RaycastHit hit in AllHit)
|
||
|
{
|
||
|
//if (hit.transform.name.ToUpper().Contains("DIMIAN"))
|
||
|
{
|
||
|
dis = Vector3.Distance(hit.point, hitPoint);
|
||
|
Debug.Log(dis);
|
||
|
}
|
||
|
}
|
||
|
//调节大小
|
||
|
ClonedObj.transform.localScale = new Vector3(1, dis / 9.2f, 1);
|
||
|
ClonedObj.transform.Translate(Vector3.down * (dis / 2 - 0.4f));
|
||
|
Vector3 hitobjVec = hitObj.transform./*.parent.*/position;
|
||
|
//Debug.Log(hitObj.transform.parent.name);
|
||
|
ClonedObj.transform.LookAt(new Vector3(hitobjVec.x, ClonedObj.transform.position.y, hitobjVec.z));
|
||
|
|
||
|
SetCloneGameObject(ClonedObj);
|
||
|
AddRecordEventClone(ClonedObj.transform);//测试
|
||
|
}
|
||
|
public override void AddRecordEventClone(Transform obj)
|
||
|
{
|
||
|
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.Clone;
|
||
|
var data = new BoiloverData();
|
||
|
obj.GetComponent<BoiloverControl>().GetBoiloverData(data);
|
||
|
SetBaseData(data, obj);
|
||
|
string json = JsonUtility.ToJson(data);
|
||
|
eventData.json = json;
|
||
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData);
|
||
|
}
|
||
|
}
|
||
|
public override void AddRecordFrame(List<ObjectData> list)
|
||
|
{
|
||
|
foreach (Transform child in transform)
|
||
|
{
|
||
|
BoiloverData data = new BoiloverData();
|
||
|
child.GetComponent<BoiloverControl>().GetBoiloverData(data);
|
||
|
SetBaseData(data, child);
|
||
|
string json = JsonUtility.ToJson(data);
|
||
|
var objectJson = new ObjectData();
|
||
|
objectJson.cloneObjType = cloneObjType;
|
||
|
objectJson.json = json;
|
||
|
list.Add(objectJson);
|
||
|
}
|
||
|
}
|
||
|
public override void SetCloneGameObject(GameObject obj)
|
||
|
{
|
||
|
obj.AddComponent<ObjSelectCtrl>();
|
||
|
obj.AddComponent<ObjDelete>();
|
||
|
}
|
||
|
}
|