public override void InitLevel() { SoundManager.Instance.ResetAudio(); var game = GameManager.Instance; var save = GameManager.Instance.SaveData; // Disable transitions (except for the title card) if(GameOverScreen != null) GameOverScreen.gameObject.SetActive(false); if(TimeOverScreen != null) TimeOverScreen.gameObject.SetActive(false); if(ActClearScreen != null) ActClearScreen.gameObject.SetActive(false); // Spawn the player at the last checkpoint (or the spawn, if there is no checkpoint) if (string.IsNullOrEmpty(save.Checkpoint)) Checkpoint = Spawn.gameObject; else Checkpoint = GameObjectUtility.Find(save.Checkpoint); var player = Spawn.Spawn(game.CharacterData, Checkpoint); var checkpoint = Checkpoint.GetComponent<Checkpoint>(); if(checkpoint != null) checkpoint.ActivateImmediate(); // Add to the game's list of character objects game.ActiveCharacters.Add(game.CharacterData, player); Player = player.GetComponent<HedgehogController>(); // Get all the player's counters ScoreCounter = player.GetComponent<ScoreCounter>(); RingCounter = player.GetComponent<RingCounter>(); LifeCounter = player.GetComponent<LifeCounter>(); // Listen for death so we can do game over/time over sequences Health = player.GetComponent<HedgehogHealth>(); if (Health != null) Health.OnDeath.AddListener(OnDeathBegin); // Get the save data into the components we just stored Lives = save.Lives; Score = save.Score; Rings = save.Rings; TimeSeconds = save.Time; // Set up the camera for the player and level boundaries Camera.Target = Player.transform; Camera.LevelBoundsMin = LevelBoundsMin; Camera.LevelBoundsMax = LevelBoundsMax; // Link with the HUD HudManager.Level = this; // Start the background music if (BGM) SoundManager.Instance.PlayBGM(BGM); // Done! save, show the title card, and start the level when it's done game.SaveProgress(); ShowTitleCard(StartLevel); }
void Start() { bp = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); ring = GameObject.FindGameObjectWithTag("Player").GetComponent <RingCounter>(); coli = GetComponent <CapsuleCollider2D>(); }
protected override void Start() /**/ { base.Start(); main = this; }