Example #1
0
 protected virtual void OnScoreChanged(ScoreChangedEventArgs e)
 {
     if (ScoreChanged != null)
     {
         ScoreChanged.Invoke(this, e);
     }
 }
Example #2
0
 private void checkWhoShouldBeNotifed(object sender, ScoreChangedEventArgs e)
 {
     foreach (IPlayer player in m_Players)
     {
         if (player.PlayerType == e.PlayerType)
         {
             player.UpdateScore(e);
             break;
         }
     }
 }
Example #3
0
 public void UpdateScore(ScoreChangedEventArgs args)
 {
     if (args.DidHitEnemy)
     {
         EnemySpaceShipDestroyed(args.EnemyPointsWorth);
     }
     else
     {
         PlayerGotHitByBullet();
     }
 }
Example #4
0
        public override void Collided(ICollidable i_Collidable)
        {
            bool                  shouldDie = true;
            Sprite                asSprite  = i_Collidable as Sprite;
            Bullet                asBullet  = i_Collidable as Bullet;
            MotherShip            asMotherShip;
            EnemySpaceShip        asEnemy;
            PlayerSpaceShip       asPlayerSpaceShip;
            ScoreChangedEventArgs scoreChangedEventArgs;

            if (Team != asSprite.Team)
            {
                if (asBullet == null)
                {
                    Game.Components.Remove(this);
                    if (asSprite.Team == eTeam.Enemy)
                    {
                        this.Dispose();
                        asSprite.Dispose();
                    }
                }
                else if (m_BulletOwner is EnemySpaceShip && m_Random.Next(0, 2) == 0)
                {
                    shouldDie = false;
                }

                asEnemy           = i_Collidable as EnemySpaceShip;
                asMotherShip      = i_Collidable as MotherShip;
                asPlayerSpaceShip = this.BulletOwner as PlayerSpaceShip;
                if (asPlayerSpaceShip != null && (asEnemy != null || asMotherShip != null))
                {
                    scoreChangedEventArgs = new ScoreChangedEventArgs();
                    if (asEnemy != null)
                    {
                        scoreChangedEventArgs.EnemyPointsWorth = asEnemy.EnemyPointsWorth;
                    }
                    else
                    {
                        scoreChangedEventArgs.EnemyPointsWorth = asMotherShip.EnemyPointsWorth;
                    }

                    scoreChangedEventArgs.PlayerType  = asPlayerSpaceShip.PlayerType;
                    scoreChangedEventArgs.DidHitEnemy = true;
                    OnScoreChanged(scoreChangedEventArgs);
                }

                if (shouldDie)
                {
                    base.Collided(i_Collidable);
                    OnRemoveMeAsNotifier();
                }
            }
        }
        public override void Collided(ICollidable i_Collidable)
        {
            Bullet asBullet = i_Collidable as Bullet;
            ScoreChangedEventArgs scoreChangedEventArgs;

            if (asBullet != null && Team != asBullet.Team)
            {
                scoreChangedEventArgs             = new ScoreChangedEventArgs();
                scoreChangedEventArgs.DidHitEnemy = false;
                scoreChangedEventArgs.PlayerType  = this.PlayerType;
                OnScoreChanged(scoreChangedEventArgs);
            }
        }
Example #6
0
 private void updatesGameManager_ScoreChanged(object sender, ScoreChangedEventArgs e)
 {
     checkWhoShouldBeNotifed(sender, e);
 }