void Start() { //devRoomPrefab.SetActive(false); _gameCanvas = gameCanvasObject.GetComponent <GameCanvas>(); player = Camera.main.GetComponent <PlayerBehavior>(); _waveManager = FindObjectOfType <WaveManager>(); _scoreManager = GetComponent <ScoreManager>(); _streaksManager = GetComponent <StreaksManager>(); LineObjects = new List <GameObject>(); ZombieHitLines = new List <DoubleVector>(); ZombieMissLines = new List <DoubleVector>(); _scoreManager.ResetScore(); if (usedevRoom && (devRoomPrefab != null)) { // devRoomPrefab.SetActive(true); devRoomObj = Instantiate(devRoomPrefab, devRoomPosition.transform); devRoomManager = devRoomObj.GetComponent <DevRoomManager>(); if (useOneSpawn) { spawnPoints.Add(devRoomManager.devSpawnPoint7); } else { spawnPoints.Add(devRoomManager.devSpawnPoint1); spawnPoints.Add(devRoomManager.devSpawnPoint2); spawnPoints.Add(devRoomManager.devSpawnPoint3); spawnPoints.Add(devRoomManager.devSpawnPoint4); spawnPoints.Add(devRoomManager.devSpawnPoint5); spawnPoints.Add(devRoomManager.devSpawnPoint6); } hotspots.Add(devRoomManager.devHotspot1); hotspots.Add(devRoomManager.devHotspot2); hotspots.Add(devRoomManager.devHotspot3); Locate_Lines_ANC_Pivot(devRoomManager.devPAthfinder); TargCTRL = devRoomManager.devtarget.GetComponent <TargetControle>(); StartCTRL = devRoomManager.devButton.GetComponent <StartButtonControle>(); LevelLoaded(); } }
void LoadObjects() { if (_waveManager.GetWave() == null) { TimerBehavior t = gameObject.AddComponent <TimerBehavior>(); t.StartTimer(0.5f, LoadObjects); return; } if (!IsInDevRoom()) { // gather all stored anchors string[] ids = anchorStore.GetAllIds(); for (int index = 0; index < ids.Length; index++) { if (ids[index] == AnchorName_StemBase) { if (curgamemode != ARZGameModes.GameNoStem) { reticle.gameObject.SetActive(false); // if anchor is stem system // instantiate stem system prefab it should have been set to left or right on start GameObject obj = Instantiate(stemSystemKit) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } _stmKitMngr = obj.GetComponent <StemKitMNGR>(); } } else if (ids[index] == AnchorName_ConsoleObject) { // if anchor is console object // instantiate console prefab GameObject obj = Instantiate(consoleObject) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } else if (ids[index] == AnchorName_ScoreBoard) { // if anchor is scoreboard // instantiate scoreboard from anchor data GameObject obj = Instantiate(scoreboard) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } //-------------------------------------------------------------------- else if (ids[index] == AnchorName_Target) { // if anchor is scoreboard // instantiate scoreboard from anchor data GameObject obj = Instantiate(target) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } TargCTRL = obj.GetComponent <TargetControle>(); } //-------------------------------------------------------------------- else if (ids[index] == AnchorName_StartButton) { GameObject obj = Instantiate(startButton) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } StartCTRL = obj.GetComponent <StartButtonControle>(); } //-------------------------------------------------------------------- AnchorName_StartButton else if (ids[index] == AnchorName_metalBarrel) { // if anchor is weapons rack // instantiate weapons rack from anchor data GameObject obj = Instantiate(metalBarrel) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } // obj.transform.Rotate(Vector3.up, 180.0f); or not // rack = obj.GetComponent<WeaponRack>(); } else if (ids[index] == AnchorName_roomModel) { // if anchor is weapons rack // instantiate weapons rack from anchor data GameObject obj = Instantiate(roomModel) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } // obj.transform.Rotate(Vector3.up, 180.0f); or not // rack = obj.GetComponent<WeaponRack>(); } else if (ids[index].Contains(AnchorName_AmmoBoxInfinite)) { // if anchor is infinite ammo box // instantiate infinite ammo box from anchor data GameObject obj = Instantiate(infiniteAmmoBox) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } else if (ids[index] == AnchorName_PathFinder) { // if anchor is pathfinder // instantiate pathfinder from anchor data GameObject obj = Instantiate(gridMap) as GameObject; anchorStore.Load(ids[index], obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } Locate_Lines_ANC_Pivot(obj); } else if (ids[index].Contains(AnchorName_SpawnPoint)) { // if anchor is a spawn point // instantiate spawn point from anchor data GameObject obj = Instantiate(spawnPoint) as GameObject; anchorStore.Load(ids[index], obj); // add spawn point to collection spawnPoints.Add(obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } else if (ids[index].Contains(AnchorName_HotSpot)) { // if anchor is a hotspot // instantiate hotspot from anchor data GameObject obj = Instantiate(hotspot) as GameObject; anchorStore.Load(ids[index], obj); // add spawn point to collection hotspots.Add(obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } else if (ids[index].Contains(AnchorName_MistEmitter)) { // if anchor is mist // instantiate mist from anchor data GameObject obj = Instantiate(mist) as GameObject; anchorStore.Load(ids[index], obj); mists.Add(obj); // delete anchor component WorldAnchor attachedAnchor = obj.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } } else if (ids[index].Contains(AnchorName_MistEnd)) { //MistMover MistMoverScript = FindObjectOfType<MistMover>(); //// if none exist then instantiate one //if (MistMoverScript == null) //{ // GameObject obj = Instantiate(mist) as GameObject; // MistMoverScript = obj.GetComponent<MistMover>(); //} // instantiate placeholder at world anchor position _placeHolderMistTarget = Instantiate(placeholder) as GameObject; anchorStore.Load(ids[index], _placeHolderMistTarget); // delete anchor component WorldAnchor attachedAnchor = _placeHolderMistTarget.GetComponent <WorldAnchor>(); if (attachedAnchor != null) { DestroyImmediate(attachedAnchor); } // add placeholder to airstrike object as air strike end //MistMoverScript.SetMistEnd(placeholderObject); } } } if (_placeHolderMistTarget == null) { DebugConsole.print("mist target is NULL!"); } LevelLoaded(); }