public void StartRoundInternal(int index) { Time.timeScale = 1f; SetShotsFired(0); if (GameManager.ActivePlayerController != null) { GameManager.ActivePlayerController.SetCanFire(false); } m_currentRound = ScenarioGenerator.GenerateRound(index, m_preset); m_nextRoundIndex = index + 1; StartRoundRoutine(RoundStartRoutine()); }
public void InitializeScenarioInternal(ScenarioPreset preset) { if (preset == null) { return; } if (m_preset != null) { if (GameManager.ActivePlayerController != null) { Destroy(GameManager.ActivePlayerController.gameObject); } } m_preset = preset; m_currentRound = null; SetupGameArea(); if (m_entities == null) { m_entities = new Dictionary <int, Entity>(); } else { // TODO: Cache entities instead of outright destroying them foreach (Entity e in m_entities.Values) { Destroy(e.gameObject); } m_entities.Clear(); } m_playerScore = 0; m_playerShotsFired = 0; UserInterface.SetScore(m_playerScore); SetHighScore(LoadHighScore()); if (m_preset.m_playerPrefab != null) { Vector3 position = Environment.PlayerSpawn != null ? Environment.PlayerSpawn.position : Vector3.zero; Quaternion rotation = Environment.PlayerSpawn != null ? Environment.PlayerSpawn.rotation : Quaternion.identity; GameObject go = Instantiate <GameObject>(m_preset.m_playerPrefab, position, rotation, Environment.EntityRoot); go.name = m_preset.m_playerPrefab.name; TurretController tc; if (GameManager.State == GameState.Game) { tc = go.GetComponent <PlayerController>(); } else { tc = go.GetComponent <AIController>(); } GameManager.SetActiveTurretController(tc, false); tc.SetCanControl(false); } else { Debug.LogError(DebugUtilities.AddTimestampPrefix("ScenarioPreset doesn't define a player prefab!"), m_preset); } }