private void PlaceSnakes() { // Reset state to level start since the player is respawning. Managers.GameState.LevelState = LevelState.LevelStart; // For a subsequent level, in case playersnake has been cleared, reattach it. FindPlayerSnake(); // Remove one extra snake on initial placement Managers.GameState.ExtraSnakes--; this.mazeController.PlaceSnake(this.playerSnake, true); PlayerSnakeController psc = this.playerSnake.Controller as PlayerSnakeController; psc.PlayerControlled = false; // Every time we place the player snake, create an initial egg-laying event this.eggManager.CreateEggLayingEvent(Side.Player, true); List <Snake> enemySnakes = GetEnemySnakes(); for (int i = 0; i < enemySnakes.Count; ++i) { Snake enemySnake = enemySnakes[i]; Managers.GameClock.RegisterEvent(4.0f * i, () => this.mazeController.PlaceSnake(enemySnake, false) ); } }
private Snake CreatePlayerSnake(int length) { // Player snake is added to array and also assigned to direct pointer. Snake s = CreateSnake(this.playerSnakeConf, length); s.SetSpriteDepth(10); s.CreatureDied += PlayerSnakeDied; this.snakes.Add(s); this.playerSnake = s; PlayerSnakeController psc = s.Controller as PlayerSnakeController; psc.SnakeReturnedToStart += PlayerReturnedToStart; psc.SnakeExitedStart += PlayerExitedStart; return(this.playerSnake); }
private void EndLevel() { Managers.GameState.LevelState = LevelState.LevelEnd; // Remove any unlaid player egg (because it might hatch in the start zone!) and // put the player under AI control so it can zoom back to the start zone. this.eggManager.RemoveUnlaidPlayerEgg(); // Remove all events like future player egg laying. Managers.GameClock.Reset(); PlayerSnakeController psc = this.playerSnake.Controller as PlayerSnakeController; if (psc == null) { return; } psc.PlayerControlled = false; this.playerSnake.UpdateSpeed(); }