Beispiel #1
0
        public void Handle(Selector selector, Player p1, Player p2, Field p1Field, Field p2Field,
                           KeyboardState state, KeyboardState previousState)
        {
            // Handles left and right
            HandleLeftRightWithMaxIndex(selector, state, previousState, 4);
            if (p1Field.monsterZone[selector.index].sprite == null)
            {
                selector.defaultPosition = p1Field.monsterPositions[selector.index];
            }
            selector.selected = p1Field.monsterZone[selector.index];

            // Handle Summon
            if (state.IsKeyDown(Keys.Enter) && previousState.IsKeyUp(Keys.Enter))
            {
                selector.state           = SelectedState.P1_MONSTER_ZONE;
                selector.selected        = p1Field.monsterZone[selector.index];
                selector.defaultPosition = p1Field.monsterPositions[selector.index];
                Summon.Apply(p1, p1Field, selector.summoning, selector.index);
                selector.summoning = null;
                p1.canNormalSummon = false;
            }
            else if (state.IsKeyDown(Keys.Back) && previousState.IsKeyUp(Keys.Back))
            {
                selector.state           = SelectedState.SUMMON_OR_SET;
                selector.action          = SelectedAction.SUMMON;
                selector.selected        = selector.summoning;
                selector.index           = 0;
                selector.defaultPosition = selectorPositions[0];
            }
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for events, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Update the keyboard state
            KeyboardState state = Keyboard.GetState();

            // Check for game exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || state.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // Update turn and check for win/loss
            UpdateGame();
            UpdateTurn();

            // Upate player phase
            p1.Update(gameTime, p1Field);
            p2.Update(gameTime, p2Field);

            // Update traps for hooks (EARLY TESTING)
            KeyValuePair <TrapCard, int> hookedTrap = CheckHooksP1(gameTime, p1, p2, p1Field, p2Field);

            if (hookedTrap.Key != null)
            {
                hookedTrap.Key.effect.Activate(p1, p2, p1Field, p2Field, hookedTrap.Value);
            }

            // Update selector
            selectionHandlers[selector.state].Handle(selector, p1, p2, p1Field, p2Field, state, previousState);

            // for testing, draw with 'D'
            if (state.IsKeyDown(Keys.D) && previousState.IsKeyUp(Keys.D))
            {
                DrawCard.Apply(p1, p1Field);
            }

            // Update keyboard state
            previousState = state;

            // AI starts with monster for testing
            foreach (Card card in p1Field.magicAndTrapZone)
            {
                if (card is TrapHole)
                {
                    if (p2.hand[0] is MonsterCard)
                    {
                        p1.hooks.Add(TrapHook.NORMAL_SUMMON, 0);
                        Summon.Apply(p2, p2Field, (MonsterCard)p2.hand[0], 0);
                    }
                }
            }

            base.Update(gameTime);
        }
Beispiel #3
0
 public override void Execute()
 {
     if (!this.m_initialized)
     {
         this.Initialize();
     }
     if (base.Handlers.Length == 2)
     {
         Kill   kill         = base.Handlers[0] as Kill;
         Summon summonEffect = base.Handlers[1] as Summon;
         if (kill != null && summonEffect != null)
         {
             System.Collections.Generic.IEnumerable <SummonedMonster> allFighters = base.Fight.GetAllFighters <SummonedMonster>((SummonedMonster entry) => entry.Team == this.Caster.Team && entry.Monster.MonsterId == (int)summonEffect.Dice.DiceNum);
             kill.SetAffectedActors(allFighters);
             kill.Apply();
             summonEffect.Apply();
         }
     }
 }