Esempio n. 1
0
        void SpawnNewEnemyShip()
        {
            Random    r = new Random();
            Point     newEnemyLocation = new Point(r.Next(0, 180), 0);
            EnemyShip newEnemyShip     = new EnemyShip(gameManager, newEnemyLocation, new Size(10, 10));

            newEnemyShip.colliding      = true;
            newEnemyShip.objectVelocity = new Point(0, r.Next(1, 2));
            gameManager.AddGameObjectToScene(newEnemyShip, 0);
        }
        private void PlayerProjectile_OnCollision(GameObject2D _sender, GameObject2D _other)
        {
            EnemyShip enemyShip = _other as EnemyShip;

            if (enemyShip != null)
            {
                enemyShip.DoDamage(damage);
                this.Destroy();
            }
            else if (_other.objectTag == "wall")
            {
                this.Destroy();
            }
        }
Esempio n. 3
0
        private void ScoreBox_OnCollision(GameObject2D _sender, GameObject2D _other)
        {
            EnemyShip enemy = _other as EnemyShip;

            if (enemy != null)
            {
                playerLife--;
                playerLifeText.text = playerLife.ToString();
                _other.Destroy();

                if (playerLife <= 0)
                {
                    gameManager.ChangeScene(1);
                    gameManager.ChangeUi(1);
                }
            }
        }