Exemple #1
0
 //
 public void Freeze()
 {
     if (myState == PlayerState.Frozen || (myState == PlayerState.Penalized && oldState == PlayerState.Frozen))
     {
         freezeTimer.ResetTimer(0);
     }
     oldState = PlayerState.Frozen;
     if (myState != PlayerState.Penalized)
     {
         myState = PlayerState.Frozen;
     }
     freezeTimer.SetTimer(0, 4, delegate() { UnFreeze(); });
 }
Exemple #2
0
        // plays cards from selected piles to destination piles
        public void PlayCard(Player player, int selectedPile, Pile destinationPile)
        {
            if (speedState != gameState.GamePlay)
            {
                return;
            }
            Pile fromPile;

            if (player.isPlayer1)
            {
                fromPile = yourCards[player.selector];
            }
            else
            {
                fromPile = opponentCards[player.selector];
            }
            if (fromPile.Count() == 0)
            {
                return;
            }
            if (fromPile.drawnTo)
            {
                return;
            }
            speedState = gameState.PlayingCard;
            Card c     = fromPile.Peek();
            int  cv    = c.cardValue;
            int  value = destinationPile.Peek().cardValue;

            if ((cv == 0 && value == 12) || (cv == 12 && value == 0) || (cv == value + 1 || cv == value - 1))
            {
                //if(myType == gameType.Timed)
                delayTimer.ResetTimer(0);
                Card m = fromPile.Take();
                m.toPile(destinationPile);
                if (soundOn)
                {
                    playcard.Play();
                }
                if (vibrateOn)
                {
                    GamePad.SetVibration(PlayerIndex.One, 1.0f, 1.0f);
                }
                m.Rotate(Actions.ExpoMove, (float)(random.NextDouble() - .5) / 2, .3f);
                m.WhenDoneMoving(delegate()
                {
                    m.Move(Actions.LinearMove, m.attributes.position + new Vector2(random.Next(-5, 5), random.Next(-5, 5)), 3f);
                    player.score++;
                    if (powerUpOn)
                    {
                        if (destinationPile.hasPowerUp)
                        {
                            Player victim;
                            if (player.isPlayer1)
                            {
                                victim = opp;
                            }
                            else
                            {
                                victim = you;
                            }
                            destinationPile.PlayPowerUp(victim);
                        }
                    }
                    speedState = gameState.GamePlay;
                    if (player.isPlayer1)
                    {
                        if (yourStack.Count() != 0)
                        {
                            if (fromPile.Count() == 0)
                            {
                                DrawCard(yourStack, fromPile, 0f);
                            }
                        }
                    }
                    else
                    {
                        if (opponentStack.Count() != 0)
                        {
                            if (fromPile.Count() == 0)
                            {
                                DrawCard(opponentStack, fromPile, 0f);
                            }
                        }
                    }
                    Shake();
                    SelectPowerUp(destinationPile);
                    ParticleEngine smoke = new ParticleEngine(textures, destinationPile.position, new Vector2(300, 300), m.attributes.depth, .3f, Color.WhiteSmoke);
                    base.Add(smoke);
                });
            }
            else
            {
                speedState         = gameState.GamePlay;
                c.attributes.color = Color.Red;
                Timer timer = new Timer(1);
                base.Add(timer);
                timer.SetTimer(0, 1, delegate() { c.attributes.color = Color.White; player.RemovePenalty(); });
                player.Penalize();
            }
        }