Exemple #1
0
        void OnTriggerEnter(Collider trigger)
        {
            IShootable ammu = trigger.gameObject.GetComponent <IShootable>();

            //	Ignore if is not a shot
            if (ammu == null)
            {
                return;
            }

            if (trigger.gameObject.tag != Tags.SaucerAmmu)
            {
                return;
            }

            Debug.Log(this.name + " -Trigger in " + trigger.gameObject.name);

            EnemyUnit sourceEntity       = ammu.Source.gameObject.GetComponentInParent <EnemyUnit>();      // Who Shoots?
            CollisionDetectedEventArgs e = new CollisionDetectedEventArgs();

            e.EnemyUnit = sourceEntity;

            OnPlayerGetsShot(this, e);

            /*CollisionDetectedEventArgs e = new CollisionDetectedEventArgs();
             * e.EnemyUnit = gameObject.GetComponent<EnemyUnit>();
             * OnPlayerGetsShot(this, e);*/
        }
        //	Player Shot

        /*public event EventHandler<CollisionDetectedEventArgs> PlayerShot;
         * protected virtual void OnPlayerShot(object sender, CollisionDetectedEventArgs e)
         * {
         *      if (PlayerShot != null)
         *              PlayerShot(this, e);
         * }*/

        //	Active or Passive Enemy (Asteroids/Saucer) gets shot
        void OnTriggerEnter(Collider trigger)
        {
            IShootable ammu = trigger.gameObject.GetComponent <IShootable>();

            //	Ignore if is not a shot
            if (ammu == null)
            {
                return;
            }

            Transform       ammuSource   = ammu.Source;
            EntityBehaviour sourceEntity = ammuSource.gameObject.GetComponentInParent <EntityBehaviour>();
            EnemyUnit       targetUnit   = gameObject.GetComponentInParent <EnemyUnit>();

            if (targetUnit != null && sourceEntity != null)
            {
                /*if (targetUnit.tag == "Saucer")
                 *      Debug.Log("STOP");
                 *
                 * if (targetUnit.tag == "Player")
                 *      Debug.Log("PLAYER SHOT");
                 */

                // Unit Shot by Player (Asteroid or Saucer)
                CollisionDetectedEventArgs colisionEvent = new CollisionDetectedEventArgs();
                colisionEvent.SourceEntity = sourceEntity;                      //	Player
                colisionEvent.EnemyUnit    = targetUnit;                        //	Enemy Shot - Asteroid/Saucer

                //	Debug.Log(this.name + " -Trigger in " + trigger.gameObject.name);
                OnUnitShot(this, colisionEvent);
            }
        }
Exemple #3
0
        private void OnScored(object sender, CollisionDetectedEventArgs e)
        {
            EnemyUnit unit = e.EnemyUnit;

            //	Todo check points obtained
            gameState.CurrentScore += e.EnemyUnit.DestructionScore;

            //	Update UI
            uiController.UpdateScore(gameState.CurrentScore);
        }
Exemple #4
0
        /// <summary>
        /// A Unit has been shot by the player
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnUnitShot(object sender, CollisionDetectedEventArgs e)
        {
            //	VFX of PassiveEnemy (Asteroid) / ActiveEnemy (Saucer)
            EnemyUnit unit = e.EnemyUnit;

            unit.Collide();

            //	Player scored
            OnScored(sender, e);

            //	TODO Add nice animation with the Points Scored
        }
Exemple #5
0
        private void OnPlayerGetsShot(object sender, CollisionDetectedEventArgs e)
        {
            EnemyUnit activeEnemy = e.EnemyUnit;

            //	Player Collision
            if (player == null)
            {
                return;
            }
            player.Collide(activeEnemy.Damage);

            //	TODO Recicly Unit
            //m_enemySpawner.Reset();
        }
Exemple #6
0
        /// <summary>
        /// An Active/Passive unit has been collided (by the player)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEntityCollided(object sender, CollisionDetectedEventArgs e)
        {
            //	VFX of PassiveEnemy (Asteroid) / ActiveEnemy (UFO)
            EnemyUnit unit = e.EnemyUnit;

            if (unit == null)
            {
                return;                            //	TODO: Recheck, this should not happen...
            }
            unit.Collide();

            //	Player Collision
            e.SourceEntity.Collide(unit.Damage);
        }