// Update is called once per frame void Update() { if (reachedExit && CurrentObjective.IsAchieved()) { ScoreManager.SaveScore(); EndLevel(true); } if (PlayersDead) { ScoreManager.SaveScore(); if (CurrentObjective.GetComponent <Endless>() != null) { EndLevel(true); } EndLevel(false); } }
private void setObjective() { // Create an Objective based on the type provided by the TileMap switch (GameTileMapReference.ObjectiveType) { case Objectives.Type.KillAll: CurrentObjective = gameObject.AddComponent <Kill_Enemy>(); CurrentObjective.Manager = this; break; case Objectives.Type.CollectCoins: CurrentObjective = gameObject.AddComponent <Collect_Coins>(); CurrentObjective.Manager = this; break; case Objectives.Type.NoDamage: CurrentObjective = gameObject.AddComponent <No_Dmg_Taken>(); CurrentObjective.Manager = this; break; case Objectives.Type.Endless: CurrentObjective = gameObject.AddComponent <Endless>(); Endless mode = CurrentObjective.GetComponent <Endless>(); mode.RefPlayer1 = PlayerList[0]; mode.RefPlayer2 = PlayerList[1]; mode.RefEnemyManager = EnemiesManager; mode.RefWaypointManager = GetComponentInChildren <WaypointManager>(); CurrentObjective.Manager = this; break; default: throw new ArgumentOutOfRangeException(); } // Initialize the Objective with the string provided if (CurrentObjective.ParseParamString(GameTileMapReference.ObjectiveParams) == false) { throw new UnityException("Failed to load Objective parameters!"); } // Tie the Objective with this GameManager CurrentObjective.Manager = this; }
private void setObjective() { // Create an Objective based on the type provided by the TileMap switch (GameTileMapReference.ObjectiveType) { case Objectives.Type.KillAll: CurrentObjective = gameObject.AddComponent<Kill_Enemy>(); CurrentObjective.Manager = this; break; case Objectives.Type.CollectCoins: CurrentObjective = gameObject.AddComponent<Collect_Coins>(); CurrentObjective.Manager = this; break; case Objectives.Type.NoDamage: CurrentObjective = gameObject.AddComponent<No_Dmg_Taken>(); CurrentObjective.Manager = this; break; case Objectives.Type.Endless: CurrentObjective = gameObject.AddComponent<Endless>(); Endless mode = CurrentObjective.GetComponent<Endless>(); mode.RefPlayer1 = PlayerList[0]; mode.RefPlayer2 = PlayerList[1]; mode.RefEnemyManager = EnemiesManager; mode.RefWaypointManager = GetComponentInChildren<WaypointManager>(); CurrentObjective.Manager = this; break; default: throw new ArgumentOutOfRangeException(); } // Initialize the Objective with the string provided if (CurrentObjective.ParseParamString(GameTileMapReference.ObjectiveParams) == false) { throw new UnityException("Failed to load Objective parameters!"); } // Tie the Objective with this GameManager CurrentObjective.Manager = this; }