示例#1
0
 private void ECommander_lost(object sender, EventArgs e)
 {
     Existence.getInstance().clear();
     DyingExistence.getInstance().clear();
     stageNum++;
     state = Def.State.EnemyInit;
 }
示例#2
0
 private void ECommander_won(object sender, EventArgs e)
 {
     Existence.getInstance().clear();
     DyingExistence.getInstance().clear();
     stageNum = 1;
     state    = Def.State.GameOver;
 }
示例#3
0
 public void dying()
 {
     if (dyingAnimation.Count == 0)
     {
         canvas.Children.Remove(displayImage);
         DyingExistence.getInstance().remove(gmObj);
         return;
     }
     if (initialdeath)
     {
         imageState          = 0;
         dyingCount          = 0;
         initialdeath        = false;
         displayImage.Source = dyingAnimation[imageState];
     }
     if (dyingCount >= dyingCycle)
     {
         imageState++;
         if (!isDyingLoop && imageState >= dyingAnimation.Count)
         {
             canvas.Children.Remove(displayImage);
             DyingExistence.getInstance().remove(gmObj);
             if (canDispose != null)
             {
                 canDispose(this, EventArgs.Empty);
             }
             return;
         }
         imageState++;
         dyingCount          = 0;
         displayImage.Source = dyingAnimation[imageState];
     }
     else
     {
         dyingCount++;
     }
 }
示例#4
0
        public GameScreen()
        {
            this.InitializeComponent();
            exist = Existence.getInstance();
            dying = DyingExistence.getInstance();
            stage = Stage.getInstance();
            //display = new Dictionary<GameObject, GameObjectImage>();
            display               = new ConcurrentDictionary <GameObject, GameObjectImage>();
            playerDeathCount      = 0;
            playerDeathImage      = new Image();
            playerRemainingImages = new List <Image>();
            playerRemainNum       = stage.remainingPlayerAttacker;
            //stage.clock += Stage_clock;
            TimerCallback callback = state => { Stage_clock(); };

            timer = new Timer(callback, null, 0, Def.frameSpan);

            this.Loaded += delegate {
                this.keyholder.Focus(FocusState.Keyboard);
                this.keyholder.LostFocus += (s, e) => this.keyholder.Focus(FocusState.Keyboard);
                this.keyholder.IsTabStop  = true;
                //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryResizeView(new Size { Width = Def.existWidth, Height = Def.existHeight });
            };
        }
示例#5
0
        //private void timerEvent(ThreadPoolTimer timer)
        private void timerEvent()
        {
            switch (state)
            {
            case Def.State.EnemyInit:
                state                  = Def.State.PlayerInit;
                eCommander             = new EnemyCommander(stageNum);
                eCommander.teamDamage += ECommander_teamDamage;
                eCommander.lost       += ECommander_lost;
                eCommander.won        += ECommander_won;
                Wall.makeTemplateDefenceWall();
                break;

            case Def.State.PlayerInit:
                state = Def.State.InGame;
                pCommander.organizeAttacker();

                break;

            case Def.State.InGame:
                if (moveDic["left"])
                {
                    pCommander.moveLeft();
                }
                if (moveDic["right"])
                {
                    pCommander.moveRight();
                }
                oneShot       = currentSpace && !previousSpace;
                previousSpace = currentSpace;
                if (oneShot)
                {
                    pCommander.shot();
                }
                if (eCommander != null)
                {
                    eCommander.invade(pCommander.pAttackerCenter, (int)Def.ObjectID.EnemyID);
                }
                Existence.getInstance().moveAll();
                break;

            case Def.State.BeShotDown:
                if (shotdownCount <= Def.shotdownTime)
                {
                    shotdownCount++;
                }
                else
                {
                    shotdownCount = 0;
                    if (pCommander.remaining == 0)
                    {
                        Existence.getInstance().clear();
                        DyingExistence.getInstance().clear();
                        pCommander.initializePlayerValues();
                        state = Def.State.GameOver;
                    }
                    else
                    {
                        state = Def.State.PlayerInit;
                    }
                }
                break;
            }
        }