コード例 #1
0
ファイル: EnemySpawner.cs プロジェクト: emedmaria/_Asteroids
 protected void OnShot(object sender, CollisionDetectedEventArgs e)
 {
     if (Shot != null)
     {
         Shot(sender, e);
     }
 }
コード例 #2
0
 protected virtual void OnPlayerGetsShot(object sender, CollisionDetectedEventArgs e)
 {
     if (PlayerGetsShot != null)
     {
         PlayerGetsShot(this, e);
     }
 }
コード例 #3
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);*/
        }
コード例 #4
0
        //	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);
            }
        }
コード例 #5
0
 protected void OnScored(object sender, CollisionDetectedEventArgs e)
 {
     if (Scored != null)
     {
         Scored(sender, e);
     }
 }
コード例 #6
0
 protected virtual void OnUnitShot(object sender, CollisionDetectedEventArgs e)
 {
     if (UnitShot != null)
     {
         UnitShot(this, e);
     }
 }
コード例 #7
0
 protected virtual void OnCollided(object sender, CollisionDetectedEventArgs e)
 {
     if (Collided != null)
     {
         Collided(sender, e);
     }
 }
コード例 #8
0
        void OnCollisionEnter(Collision colision)
        {
            //Debug.Log(this.name + " -Collided with: " + colision.gameObject.name);

            CollisionDetectedEventArgs e = new CollisionDetectedEventArgs();

            e.SourceEntity = gameObject.GetComponent <EntityBehaviour>();
            e.EnemyUnit    = colision.gameObject.GetComponentInParent <EnemyUnit>();
            OnCollided(this, e);
        }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: emedmaria/_Asteroids
        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);
        }
コード例 #10
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
        }
コード例 #11
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();
        }
コード例 #12
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);
        }