private void Start() { playerControls = FindObjectOfType <PlayerControlsCanvas>(); defeat = FindObjectOfType <DefeatScreen>(); options = FindObjectOfType <InGameOptions>(); camera = Camera.main; attackButton = playerControls.AttackButton; jumpButton = playerControls.JumpButton; optionsButton = playerControls.OptionsButton; joystick = playerControls.Joystick; #region Assertions Assert.IsNotNull(rigidbody); Assert.IsNotNull(animator); Assert.IsNotNull(characterSprite); Assert.IsNotNull(joystick); Assert.IsNotNull(jumpButton); Assert.IsNotNull(attackButton); Assert.IsNotNull(optionsButton); Assert.IsNotNull(camera); Assert.IsNotNull(defeat); Assert.IsNotNull(options); Assert.IsNotNull(playerControls); #endregion optionsButton.onClick.AddListener(GoToOptions); jumpButton.onClick.AddListener(Jump); attackButton.onClick.AddListener(Attack); isDead = false; }
void defeat() { if (lives <= 0 || TimeRemaining <= 0) { stop(); DefeatScreen.SetActive(true); } }
public void GameOver(EndCondition endCondition) { Time.timeScale = 0f; if (endCondition == EndCondition.Victory) { Text[] info = VictoryScreen.GetComponentsInChildren <Text>(); info[0].text = string.Format("{0:00}:{1:00}", totalTime / 60, totalTime % 60); info[1].text = totalGameOvers.ToString(); totalTime = 0f; totalGameOvers = 0; VictoryScreen.SetActive(true); } else if (endCondition == EndCondition.Defeat) { DefeatScreen.SetActive(true); } }
public PlayerView(GameLogic game) { this.Game = game; this.EventManager = game.EventManager; menuClock = new GameClock(); menuClock.Start(); /** * Initialize Graphics Subsystem **/ RenderForm = new Form(); RenderForm.ClientSize = new Size(Game.World.Width, Game.World.Height); RenderForm.Text = "Alien Invasion v1.0"; RenderForm.BackColor = Color.Empty; RenderForm.KeyPreview = true; RenderForm.FormBorderStyle = FormBorderStyle.FixedSingle; // Disable resizing of window RenderForm.MaximizeBox = false; // Disable maximizing RenderForm.Leave += (s, e) => { this.RenderForm.Focus(); // When RenderForm loses focus player input won't be processed correctly }; extractor = new Extractor(game); Renderer = new Graphics.Renderer(RenderForm, extractor); Renderer.StartRender(); rendererLoaders.Add(new TextureLoader(Renderer)); rendererLoaders.Add(new MeshLoader(Renderer)); rendererLoaders.Add(new EffectLoader(Renderer)); foreach (var rendererLoader in rendererLoaders) { game.ResourceManager.AddLoader(rendererLoader); } game.ResourceManager.AddLoader(new MaterialLoader(game.ResourceManager)); /** * Initialize Input Subsystem **/ gameController = new GameController(EventManager, game); RenderForm.KeyDown += new KeyEventHandler(gameController.OnKeyDown); RenderForm.KeyUp += new KeyEventHandler(gameController.OnKeyUp); /** * Initialize Audio Subsystem **/ audioPlayer = new FmodAudioPlayer(@"./data/audio/"); audioPlayer.LoadFile("audio.fev"); audioPlayer.IsPaused = false; /** * Initialize GUI **/ mainMenuControl = new GameMainMenu(EventManager); mainMenuControl.Location = new Point( (RenderForm.ClientSize.Width - mainMenuControl.Width) / 2, (RenderForm.ClientSize.Height - mainMenuControl.Height) / 2); RenderForm.Controls.Add(mainMenuControl); highscoreControl = new HighscoreScreen(EventManager); highscoreControl.Location = new Point( (RenderForm.ClientSize.Width - highscoreControl.Width) / 2, (RenderForm.ClientSize.Height - highscoreControl.Height) / 2); RenderForm.Controls.Add(highscoreControl); creditsControl = new Credits(EventManager); creditsControl.Location = new Point( (RenderForm.ClientSize.Width - creditsControl.Width) / 2, (RenderForm.ClientSize.Height - creditsControl.Height) / 2); RenderForm.Controls.Add(creditsControl); pauseControl = new PauseScreen(); pauseControl.Location = new Point( (RenderForm.ClientSize.Width - pauseControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - pauseControl.Height); RenderForm.Controls.Add(pauseControl); victoryControl = new VictoryScreen(EventManager); victoryControl.Location = new Point( (RenderForm.ClientSize.Width - victoryControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - (victoryControl.Height / 2)); RenderForm.Controls.Add(victoryControl); gameOverControl = new DefeatScreen(EventManager); gameOverControl.Location = new Point( (RenderForm.ClientSize.Width - gameOverControl.Width) / 2, (RenderForm.ClientSize.Height / 2) - (gameOverControl.Height / 2)); RenderForm.Controls.Add(gameOverControl); hud = new Hud(EventManager); hud.Location = new Point(RenderForm.ClientSize.Width - hud.Width, 0); RenderForm.Controls.Add(hud); numOfGcCollectedObjects = new int[GC.MaxGeneration]; registerGameEventListeners(); }