Beispiel #1
0
        private void Attacker_shotDown(object sender, ShotDownEventArgs e)
        {
            if (sender is Attacker)
            {
                squad.Remove(sender as Attacker);
            }

            if (sender is EnemyAttacker)
            {
                EnemyAttacker          eAttacker = sender as EnemyAttacker;
                TeamDamageEventhandler handler   = teamDamage;
                if (handler != null)
                {
                    handler(this, new TeamDamageEventArgs(eAttacker.enemyType));
                }
            }

            if (squad.Count == 0)
            {
                EventHandler handler = Annihilated;
                if (handler != null)
                {
                    handler(this, EventArgs.Empty);
                }
            }
            else
            {
                electLeader();
                updateSquadBox();
            }
        }
Beispiel #2
0
        public void makeEnemyTemplateSquad(Vector2 leaderPos)
        {
            Vector2 formation = formationWidth * formationVec;
            Vector2 pos       = new Vector2(leaderPos);

            for (int i = 0; i < squadSize; i++)
            {
                int           eType    = (i < 2 ? 0 : (i < 4 ? 1 : 2));
                EnemyAttacker attacker = new EnemyAttacker(pos, eType, i);
                attacker.shotDown += Attacker_shotDown;
                squad.Add(attacker);
                pos += formation;
            }
            squadLeader = squad[0];
            alignByCenter();
            updateSquadBox();
        }
        private void constructByType(GameObject gmObj)
        {
            if (gmObj is PlayerAttacker)
            {
                animateCycle = Def.playerAnimateCycle;
                dyingCycle   = Def.playerDyingCycle;
                // isDyingLoop = true;
                isDyingLoop = false;
                changeImages.Add(Def.bImgP1);
                //dyingAnimation.Add(Def.bImgESD);
                displayImage.Source = changeImages[0];
                displayImage.Width  = Def.playerRange[0];
                displayImage.Height = Def.playerRange[1];
            }
            else if (gmObj is EnemyAttacker)
            {
                EnemyAttacker eAttacker = gmObj as EnemyAttacker;
                int           eType     = eAttacker.enemyType;
                animateCycle = Def.enemyAnimateCycle;
                dyingCycle   = Def.enemyDyingCycle;
                isDyingLoop  = false;
                switch (eType)
                {
                case 0:
                    changeImages.Add(Def.bImgE1_1);
                    changeImages.Add(Def.bImgE1_2);
                    break;

                case 1:
                    changeImages.Add(Def.bImgE2_1);
                    changeImages.Add(Def.bImgE2_2);
                    break;

                case 2:
                    changeImages.Add(Def.bImgE3_1);
                    changeImages.Add(Def.bImgE3_2);
                    break;
                }
                dyingAnimation.Add(Def.bImgESD);
                displayImage.Source = changeImages[0];
                displayImage.Width  = Def.enemyRange[eType, 0];
                displayImage.Height = Def.enemyRange[eType, 1];
            }
            else if (gmObj is Bullet)
            {
                animateCycle = Def.bulletAnimateCycle;
                dyingCycle   = Def.bulletDyingCycle;
                isDyingLoop  = false;
                changeImages.Add(Def.bImgB);
                dyingAnimation.Add(Def.bImgBSD);
                displayImage.Source = changeImages[0];
                displayImage.Width  = Def.bulletRange[0];
                displayImage.Height = Def.bulletRange[1];
            }
            else if (gmObj is Wall)
            {
                animateCycle = 0;
                dyingCycle   = 0;
                isDyingLoop  = false;
                changeImages.Add(Def.bImgW1);
                //changeImages.Add(Def.bImgW2);
                changeImages.Add(Def.bImgW3);
                changeImages.Add(Def.bImgW4);
                displayImage.Source = changeImages.First <BitmapImage>();
                displayImage.Width  = Def.wallSize;
                displayImage.Height = Def.wallSize;
            }
        }