void SetPlatform(PlatformInfo platformInfo) { ModularPlatform console = platformInfo.platformGameObject.GetComponentInChildren <ModularPlatform>(); console.ChangeSpeed(platformInfo.speed); console.ChangeMaxHeight(platformInfo.maxHeight); console.ControllableToggle(platformInfo.controllable); console.transform.position = platformInfo.consolePosition; console.transform.rotation = platformInfo.consoleRotation; console.currentTarget = platformInfo.currentTarget; console.gameObject.AddComponent <BulldozerObject>(); platformInfo.platformGameObject.GetComponentInChildren <ModularPlatformUnderCollision>().transform.position = platformInfo.platformPosition; for (int i = 0; i < platformInfo.waypoints.Count; ++i) { GameObject TempTarget = new GameObject(); TempTarget.transform.Rotate(new Vector3(-90, 0, 0)); TempTarget.transform.position = platformInfo.waypoints[i]; Transform newTarget = console.PlaceTarget(TempTarget.transform); newTarget.gameObject.AddComponent <PlatformWaypoint>().indexInList = i; newTarget.gameObject.AddComponent <BulldozerObject>(); Destroy(TempTarget); } for (int i = 0; i < platformInfo.platformTops.Count; ++i) { console.SpawnPlatformTop(platformInfo.platformTops[i]); } platformInfo.platformGameObject.GetComponentInChildren <UndoSystem_ModularPlatform>().enabled = false; }
public PlatformInfo FillPlatformInfo(GameObject from) { ModularPlatform console = from.GetComponentInChildren <ModularPlatform>(); PlatformInfo platformInfo = new PlatformInfo() { platformGameObject = from.gameObject, speed = console.GetSpeed(), maxHeight = console.GetMaxHeight(), currentTarget = console.currentTarget, controllable = !console.autoPilot, consolePosition = console.gameObject.transform.position, consoleRotation = console.gameObject.transform.rotation, platformPosition = from.GetComponentInChildren <ModularPlatformUnderCollision>().transform.position }; for (int i = 0; i < console.target.Count; ++i) { platformInfo.waypoints.Add(console.target[i].position); } RemovePlatformExpand[] expands = from.GetComponentsInChildren <RemovePlatformExpand>(); for (int i = 0; i < expands.Length; ++i) { for (int j = 0; j < expands[i].transform.childCount; ++j) { PlatformTopInfo platformTop = new PlatformTopInfo() { serializedTransform = new PlatformTopTransform() { position = expands[i].transform.GetChild(j).transform.position, rotation = expands[i].transform.GetChild(j).transform.rotation }, parent = new PlatformTopTransform() { position = expands[i].transform.position, rotation = expands[i].transform.rotation, } }; platformInfo.platformTops.Add(platformTop); } } return(platformInfo); }