Exemplo n.º 1
0
        private PlayerSpaceShip SpawnPlayerUnit()
        {
            GameObject      spawnedPlayerObject = _playerSpawner.Spawn();
            PlayerSpaceShip playerShip          = spawnedPlayerObject.GetComponent <PlayerSpaceShip>();

            return(playerShip);
        }
Exemplo n.º 2
0
        public PlayerSpaceShip Spawn()
        {
            GameObject      spawnedObject  = Instantiate(_prefabToSpawn, transform.position, transform.rotation);
            PlayerSpaceShip _spawnedPlayer = spawnedObject.GetComponent <PlayerSpaceShip> ();

            _spawnedPlayer.Spawner = this;

            return(_spawnedPlayer);
        }
Exemplo n.º 3
0
        protected virtual void OnTriggerEnter2D(Collider2D other)
        {
            PlayerSpaceShip player = other.GetComponent <PlayerSpaceShip>();

            if (player != null)
            {
                // Destroys the power-up item
                Destroy(gameObject);
            }
        }
Exemplo n.º 4
0
        protected void OnTriggerEnter2D(Collider2D other)
        {
            PlayerSpaceShip player = other.GetComponent <PlayerSpaceShip>();

            if (player != null)
            {
                player.GivePowerup(gameObject, duration);
            }

            Destroy(gameObject);
        }
 private void Update()
 {
     if (player == null)
     {
         player = GameObject.Find("PlayerUnit(Clone)").GetComponent <PlayerSpaceShip>();
     }
     else
     {
         text.text = "Weapon Timer: " + player.PowerUpTimer + "\nPlayer Life: " + player.Health.CurrentHealth;
     }
 }
Exemplo n.º 6
0
        protected override void OnTriggerEnter2D(Collider2D other)
        {
            PlayerSpaceShip player = other.GetComponent <PlayerSpaceShip>();

            if (player != null)
            {
                player.CollectHealthPowerUp(healthBoost);

                // Destroys the health item
                Destroy(gameObject);
            }
        }
Exemplo n.º 7
0
        protected override void OnTriggerEnter2D(Collider2D other)
        {
            PlayerSpaceShip player = other.GetComponent <PlayerSpaceShip>();

            if (player != null)
            {
                player.CollectExtraWeaponPowerUp(powerUpDuration);

                // Destroys the power-up item
                Destroy(gameObject);
            }
        }
Exemplo n.º 8
0
        public PlayerSpaceShip SpawnPlayer()
        {
            PlayerSpaceShip player       = null;
            GameObject      playerObject = _playerSpawner.Spawn();

            if (playerObject != null)
            {
                player = playerObject.GetComponent <PlayerSpaceShip>();
            }

            player.BecomeImmortal();

            return(player);
        }
Exemplo n.º 9
0
 private void Update()
 {
     // In the case of just starting the game or the
     // player ship dying, the player ship is retrieved
     if (player == null)
     {
         player = LevelController.Current.Player;
     }
     else
     {
         UpdateExtraWeaponTime();
         UpdateExtraWeaponTimeText();
     }
 }
Exemplo n.º 10
0
        private PlayerSpaceShip SpawnPlayer()
        {
            PlayerSpaceShip playerShip   = null;
            GameObject      playerObject = playerSpawner.Spawn();

            if (playerObject != null)
            {
                playerShip = playerObject.GetComponent <PlayerSpaceShip>();
            }

            playerShip.BecomeInvincible();

            this.playerShip = playerShip;

            return(playerShip);
        }
Exemplo n.º 11
0
        public void LifeLost(bool outOfLives)
        {
            // If the player runs out of lives,
            // the game over screen is displayed
            if (outOfLives)
            {
                playerShip = null;
                GameManager.Instance.GameWon = false;
                GoToState(GameStateType.GameOver);
            }
            else
            {
                // Lowers score
                GameManager.Instance.CurrentScore += scorePenaltyFromDeath;

                SpawnPlayer();
            }
        }
Exemplo n.º 12
0
        protected void Start()
        {
            _playerObject = _playerSpawner.Spawn();

            _player = _playerObject.GetComponent <PlayerSpaceShip>();

            StartCoroutine(SpawnEnemies());

            int moveTargetCount = transform.Find("MoveTargets").transform.childCount;

            _enemyMoveTargets = new GameObject[moveTargetCount];

            for (int i = 0; i < _enemyMoveTargets.Length; i++)
            {
                _enemyMoveTargets[i] = transform.Find("MoveTargets").transform.GetChild(i).gameObject;
            }

            _scoreText.text = "" + GameManager.Instance.CurrentScore;
        }
        protected override void Die()
        {
            // Destroys the gameobject. Otherwise Unity will see two player ships.
            base.Die();

            // Respawn if lives left.
            if (_lives > 0)
            {
                // Spawn new ship.
                PlayerSpaceShip newShip = Spawner.Spawn();

                // The new ship has one life less;
                newShip.Lives = Lives - 1;
                Debug.Log("Respawn with " + (Lives - 1).ToString() + " lives left.");

                // Make new ship immortal!
                newShip.MakeImmortal();
            }
            else
            {
                Debug.Log("Player died");
            }
        }
Exemplo n.º 14
0
        protected override void PowerUpPlayer(GameObject player)
        {
            PlayerSpaceShip _player = player.GetComponent <PlayerSpaceShip>();

            _player.AddPowerUpTimer(5);
        }
Exemplo n.º 15
0
 protected void Start()
 {
     // Starts a new coroutine.
     StartCoroutine(SpawnRoutine());
     PlayerSpaceShip player = SpawnPlayerUnit();
 }