上海苏宁宝丽嘉酒店,2020.11.17 15:30改为单机版本,以后合成单机版本可以以此版本为模板
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.8 KiB

4 years ago
using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReplaySetArea : ReplaySimpleObject {
public GameObject PolygonPlane;
public GameObject PolygonPlaneChild;
public long GameobjID = 0;
private void Awake()
{
GameObject PolygonPlane = GameObject.Find("Canvas/SetAreaPanel/PolygonPlaneBase").gameObject;
GameObject PolygonPlaneChild = PolygonPlane.transform.Find("Plane").gameObject;
}
/// <summary>
/// 回放克隆
/// </summary>
/// <param name="json"></param>
public override void CloneObject(string json)
{
var jsonData = JsonUtility.FromJson<RecordSetArea>(json);
if (jsonData.isEvent)
{
ReplayEventClone(jsonData);
}
else
{
ReplayFrameDataClone(jsonData);
}
}
private void ReplayFrameDataClone(RecordSetArea data)
{
GameObject PolygonPlane = GameObject.Find("Canvas/SetAreaPanel/PolygonPlaneBase").gameObject;
GameObject PolygonPlaneChild = PolygonPlane.transform.Find("Plane").gameObject;
PolygonPlaneChild.SetActive(true);
var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, data.myTransform.getMyPosition(), transform, long.Parse(data.objectName));
clonedObj.name = data.objectName;//名字即ID
SetBaseGameObject(clonedObj, data);
SetAreaData(clonedObj, data);
SetCloneGameObject(clonedObj, "");
PolygonPlaneChild.SetActive(false);
}
private void ReplayEventClone(RecordSetArea data)
{
//PolygonPlaneChild.SetActive(true);
var clonedObj = EntitiesManager.Instance.CreateObj(cloneBase.clonePrefab, data.myTransform.getMyPosition(), transform, long.Parse(data.objectName));
SetBaseGameObject(clonedObj, data);
clonedObj.GetComponent<MeshRenderer>().material.color = new Color(Color.yellow.r, Color.yellow.g, Color.yellow.b, 1f);
clonedObj.GetComponent<PolygonController>().PolyVerticeFather = GameObject.Find("Canvas/SetAreaPanel/PolyVerticeFather").GetComponent<RectTransform>();
}
private void SetAreaData(GameObject clonedObj, RecordSetArea jsonData)
{
var polyController = clonedObj.GetComponent<PolygonController>();
for(int i = 0; i < jsonData.worldPositions.Count; i++)
{
polyController.ReplaySetPolygon(jsonData.worldPositions[i], jsonData.screenPositions[i]);
}
var areaController = clonedObj.GetComponent<SetArea>();
areaController.ReplayFrameData(jsonData);
}
public override void SetCloneGameObject(GameObject obj, string json)
{
obj.AddComponent<ObjSelectCtrl>();
obj.AddComponent<ObjDelete>();
}
}