Esempio n. 1
0
 private void ECommander_won(object sender, EventArgs e)
 {
     Existence.getInstance().clear();
     DyingExistence.getInstance().clear();
     stageNum = 1;
     state    = Def.State.GameOver;
 }
Esempio n. 2
0
 private void ECommander_lost(object sender, EventArgs e)
 {
     Existence.getInstance().clear();
     DyingExistence.getInstance().clear();
     stageNum++;
     state = Def.State.EnemyInit;
 }
Esempio n. 3
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 });
            };
        }
Esempio n. 4
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;
            }
        }