Exemple #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, 6);
            if (p1.hand[selector.index].sprite == null)
            {
                selector.defaultPosition = p1.handPositions[selector.index];
            }
            selector.selected = p1.hand[selector.index];

            // Handles up and down
            PositionController.Builder builder    = new PositionController.Builder();
            PositionController         controller = builder.WithSelector(selector)
                                                    .WithUpArea(SelectedState.P1_MAGIC_AND_TRAP_ZONE)
                                                    .WithUpZone(p1Field.magicAndTrapZone)
                                                    .WithUpPositions(p1Field.magicAndTrapPositions)
                                                    .WithDownArea(SelectedState.P2_MAGIC_AND_TRAP_ZONE)
                                                    .WithDownZone(p2Field.magicAndTrapZone)
                                                    .WithDownPositions(p2Field.magicAndTrapPositions)
                                                    .WithCurrentState(state)
                                                    .WithPreviousState(previousState)
                                                    .Build();

            HandleUpAndDown(controller);

            // Handles actions
            if (state.IsKeyDown(Keys.Enter) && previousState.IsKeyUp(Keys.Enter))
            {
                if (selector.selected is MonsterCard)
                {
                    selector.state           = SelectedState.SUMMON_OR_SET;
                    selector.action          = SelectedAction.SUMMON;
                    selector.summoning       = (MonsterCard)selector.selected;
                    selector.index           = 0;
                    selector.defaultPosition = selectorPositions[0];
                }
                else if (selector.selected is MagicCard)
                {
                    selector.state           = SelectedState.SET_OR_ACTIVATE;
                    selector.action          = SelectedAction.SET;
                    selector.settingMagic    = (MagicCard)selector.selected;
                    selector.index           = 0;
                    selector.defaultPosition = selectorPositions[0];
                }
                else if (selector.selected is TrapCard)
                {
                    selector.state           = SelectedState.SETTING_TRAP;
                    selector.settingTrap     = (TrapCard)selector.selected;
                    selector.index           = 0;
                    selector.selected        = p1Field.magicAndTrapZone[0];
                    selector.defaultPosition = p1Field.magicAndTrapPositions[0];
                }
            }
        }
Exemple #2
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);
            // Handles all necessary actions in the given zone (including up and down)
            PositionController.Builder builder    = new PositionController.Builder();
            PositionController         controller = builder.WithSelector(selector)
                                                    .WithActiveZone(p1Field.magicAndTrapZone)
                                                    .WithActiveZonePositions(p1Field.magicAndTrapPositions)
                                                    .WithUpArea(SelectedState.P1_MONSTER_ZONE)
                                                    .WithUpZone(p1Field.monsterZone)
                                                    .WithUpPositions(p1Field.monsterPositions)
                                                    .WithDownArea(SelectedState.P1_HAND)
                                                    .WithDownZone(p1.hand)
                                                    .WithDownPositions(p1.handPositions)
                                                    .WithCurrentState(state)
                                                    .WithPreviousState(previousState)
                                                    .Build();

            HandleInZone(controller);

            // Handles actions
            if (state.IsKeyDown(Keys.Enter) && previousState.IsKeyUp(Keys.Enter))
            {
                if (selector.selected is MagicCard)
                {
                    selector.settingMagic = (MagicCard)selector.selected;
                    // Activate effect
                    selector.settingMagic.effect.Activate(p1, p2, p1Field, p2Field);
                    // Destory card from hand
                    selector.state  = SelectedState.P1_MAGIC_AND_TRAP_ZONE;
                    selector.action = SelectedAction.NONE;
                    selector.index  = p1Field.magicAndTrapZone.IndexOf(selector.selected);
                    p1Field.magicAndTrapZone[selector.index] = new Card();
                    p1Field.graveYard.Add(selector.settingMagic);
                    selector.settingMagic = null;
                }
                else if (selector.selected is TrapCard)
                {
                    //activate trap
                }
            }
        }
        public void Handle(Selector selector, Player p1, Player p2, Field p1Field, Field p2Field,
                           KeyboardState state, KeyboardState previousState)
        {
            // Handles left and right (DO I WANT THIS??? vv)
            //HandleLeftRightWithFieldZone(selector, state, previousState);
            // Instead of this vv
            // 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];

            // Handles all necessary actions in the given zone (including up and down)
            PositionController.Builder builder    = new PositionController.Builder();
            PositionController         controller = builder.WithSelector(selector)
                                                    .WithActiveZone(p1Field.monsterZone)
                                                    .WithActiveZonePositions(p1Field.monsterPositions)
                                                    .WithUpArea(SelectedState.P2_MONSTER_ZONE)
                                                    .WithUpZone(p2Field.monsterZone)
                                                    .WithUpPositions(p2Field.monsterPositions)
                                                    .WithDownArea(SelectedState.P1_MAGIC_AND_TRAP_ZONE)
                                                    .WithDownZone(p1Field.magicAndTrapZone)
                                                    .WithDownPositions(p1Field.magicAndTrapPositions)
                                                    .WithCurrentState(state)
                                                    .WithPreviousState(previousState)
                                                    .Build();

            HandleInZone(controller);

            // Handle Battle decisions
            if (state.IsKeyDown(Keys.Enter) && previousState.IsKeyUp(Keys.Enter) && selector.selected.sprite != null)
            {
                selector.state           = SelectedState.BATTLE_SELECT;
                selector.action          = SelectedAction.ATTACK;
                selector.selected        = (MonsterCard)selector.selected;
                selector.defaultPosition = selectorPositions[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);
            // Handles all necessary actions in the given zone (including up and down)
            PositionController.Builder builder    = new PositionController.Builder();
            PositionController         controller = builder.WithSelector(selector)
                                                    .WithActiveZone(p2Field.magicAndTrapZone)
                                                    .WithActiveZonePositions(p2Field.magicAndTrapPositions)
                                                    .WithUpArea(SelectedState.P1_HAND)
                                                    .WithUpZone(p1.hand)
                                                    .WithUpPositions(p1.handPositions)
                                                    .WithDownArea(SelectedState.P2_MONSTER_ZONE)
                                                    .WithDownZone(p2Field.monsterZone)
                                                    .WithDownPositions(p2Field.monsterPositions)
                                                    .WithCurrentState(state)
                                                    .WithPreviousState(previousState)
                                                    .Build();

            HandleInZone(controller);
        }