Пример #1
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);
        }
Пример #2
0
 private void UpdateDrawPhase(GameTime gameTime, Field field)
 {
     DrawCard.Apply(this, field);
     currentPhase = Phase.STANDBY;
 }
Пример #3
0
        /// Initializes both sides of the field (has lots of testing material in it.
        private void InitField()
        {
            HumanPlayer.Builder p1Builder = new HumanPlayer.Builder();
            AIPlayer.Builder    p2Builder = new AIPlayer.Builder();
            p1 = p1Builder
                 .WithHandPositions(p1HandPositions)
                 .Build();
            p2 = p2Builder
                 .Build();
            p2.lifePoints = 500;

            p1Deck = new List <Card>
            {
                new AncientElf(spriteManager),
                new FeralImp(spriteManager),
                new DarkMagician(spriteManager),
                new GreatWhite(spriteManager),
                new DarkHole(spriteManager),
                new TrapHole(spriteManager)
            };

            Field.Builder p1FieldBuilder = new Field.Builder();
            p1Field = p1FieldBuilder
                      .WithDeck(p1Deck)
                      .WithDeckSpriteAndPosition(spriteManager.cardBack, p1DeckPosition)
                      .WithGraveYardPosition(p1GraveYardPosition)
                      .WithMonsterPositions(p1MonsterPositions)
                      .WithMagicAndTrapPositions(p1MagicAndTrapPositions)
                      .WithFieldCardPosition(p1FieldZonePosition)
                      .Build();

            p2Deck = new List <Card>
            {
                new AncientElf(spriteManager),
                new FeralImp(spriteManager),
                new DarkMagician(spriteManager),
                new GreatWhite(spriteManager),
                new DarkHole(spriteManager),
                new CastleWalls(spriteManager)
            };
            Field.Builder p2FieldBuilder = new Field.Builder();
            p2Field = p2FieldBuilder
                      .WithDeck(p2Deck)
                      .WithDeckSpriteAndPosition(spriteManager.cardBack, p2DeckPosition)
                      .WithGraveYardPosition(p2GraveYardPosition)
                      .WithMonsterPositions(p2MonsterPositions)
                      .WithMagicAndTrapPositions(p2MagicAndTrapPositions)
                      .WithFieldCardPosition(p2FieldZonePosition)
                      .Build();

            // Draw cards
            DrawCard.Apply(p1, p1Field);
            DrawCard.Apply(p1, p1Field);
            DrawCard.Apply(p1, p1Field);
            DrawCard.Apply(p1, p1Field);
            DrawCard.Apply(p1, p1Field);

            DrawCard.Apply(p2, p2Field);
            DrawCard.Apply(p2, p2Field);
            DrawCard.Apply(p2, p2Field);
            DrawCard.Apply(p2, p2Field);
            DrawCard.Apply(p2, p2Field);
        }