示例#1
0
        //
        private Card getRandomCard(Pile DrawPile)
        {
            bool foundint = false;
            int  s        = 0;

            while (!foundint)
            {
                int x = random.Next(0, 52);
                if (cardcounter[x] < numberOfDecks)
                {
                    foundint = true;
                }
                s = x;
            }
            cardcounter[s]++;
            bool full = true;

            for (int i = 0; i < cardcounter.Length; i++)
            {
                if (cardcounter[i] < numberOfDecks)
                {
                    full = false;
                }
            }

            if (full)
            {
                cardcounter = new int[52];
            }
            return(new Card(s, deck[s].cardFront, deck[s].cardBack, DrawPile.position, false));
        }
示例#2
0
 // update method
 public override void Update(Pile[] Hand, Pile rgamestack, Pile lgamestack, GameTime gameTime)
 {
     //base.MouseUpdate();
     GamePadUpdate();
     KeyUpdate();
     base.Update(Hand, rgamestack, lgamestack, gameTime);
 }
示例#3
0
 // moves card to pile with delay
 public void toPile(Pile pile, float delay)
 {
     Move(Actions.ExpoMove, new Vector2(pile.position.X, pile.position.Y), .4f, delay);
     pile.Add(this);
     Raise(.2f, delay);
     tweenerDepth.Ended += delegate() { Lower(.99f - pile.Count() * .001f, .2f); };
 }
示例#4
0
 // update method
 public override void Update(Pile[] Hand, Pile rgamestack, Pile lgamestack, GameTime gameTime)
 {
     if (moveDelay != null)
     {
         moveDelay.Update(gameTime);
     }
     Move(Hand, rgamestack, lgamestack);
     base.Update(Hand, rgamestack, lgamestack, gameTime);
 }
示例#5
0
        // draws card to different piles
        public void DrawCard(Pile drawPile, Pile destinationPile, float delay)
        {
            if (destinationPile.drawnTo)
            {
                return;
            }
            ableToReBegin           = false;
            destinationPile.drawnTo = true;
            Card temp = null;

            switch (myType)
            {
            case gameType.Levels:
            case gameType.Normal:
                temp = drawPile.Take();
                break;

            case gameType.Marathon:
            case gameType.Timed:


                temp = getRandomCard(drawPile);
                base.Add(temp);
                break;
            }
            temp.Flip(true, delay);
            temp.toPile(destinationPile, delay);
            if (destinationPile.hasPowerUp)
            {
                destinationPile.RemovePowerUp();
            }
            temp.WhenDoneMoving(delegate() { destinationPile.drawnTo = false; Timer drawTimer = new Timer(1);
                                             base.Add(drawTimer); drawTimer.SetTimer(0, .5f, delegate() { ableToReBegin = true; });

                                             if ((destinationPile == lGameStack || destinationPile == rGameStack) && !destinationPile.hasPowerUp)
                                             {
                                                 SelectPowerUp(destinationPile);
                                             }
                                });
        }
示例#6
0
        //
        private void SelectPowerUp(Pile pile)
        {
            if (powerUpOn)
            {
                double r = random.NextDouble();
                if (r < .05)
                {
                    int x = random.Next(0, (int)PowerUps.freeze);

                    PowerUp newPower = new PowerUp(freeze.engine.attributes.color, freeze.engine.textures, powerUpOn)
                    {
                        attributes = new Attributes()
                        {
                            texture  = freeze.attributes.texture,
                            position = new Vector2(100, 100),
                            color    = Color.White
                        }
                    };
                    newPower.isSeeable = false;
                    newPower.WhenPlayed(delegate(Player player)
                    {
                        player.Freeze();
                        newPower.Fade(4);
                        if (player.isPlayer1)
                        {
                            newPower.Move(Actions.ExpoMove, yourSelector.attributes.position, 1);
                        }
                        else
                        {
                            newPower.Move(Actions.ExpoMove, oppSelector.attributes.position, 1);
                        }
                    });
                    base.Add(newPower);
                    pile.GivePowerUp(newPower);
                }
            }
        }
示例#7
0
文件: Speed.cs 项目: rabdureh/SPEGame
 // 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();
     }
 }
示例#8
0
        // computer logic to know when to play cards
        public void Move(Pile[] Hand, Pile rgamestack, Pile lgamestack)
        {
            if (myState == CompState.moving)
            {
                return;
            }

            if (ExistAMove2(Hand, rgamestack, lgamestack))
            {
                myState = CompState.moving;
                // moves left if that is fastest way to closest playable card
                if (pileNumber != selector)
                {
                    int x = pileNumber - selector;
                    if (x >= 3 || (x < 0 && x >= -2))
                    {
                        moveDelay = new Timer(1);
                        moveDelay.SetTimer(0, timeDelay + ((float)random.NextDouble() - .5f) * timeDelay, delegate()
                        {
                            if (!isPlayer1)
                            {
                                MoveSelectorLeft();
                            }
                            else
                            {
                                MoveSelectorRight();
                            }
                            myState = CompState.normal;
                        });
                    }
                    // moves right if otherwise
                    else if (x <= -3 || (x > 0 && x < 3))
                    {
                        moveDelay = new Timer(1);
                        moveDelay.SetTimer(0, timeDelay + ((float)random.NextDouble() - .5f) * timeDelay, delegate()
                        {
                            if (!isPlayer1)
                            {
                                MoveSelectorRight();
                            }
                            else
                            {
                                MoveSelectorLeft();
                            }
                            myState = CompState.normal;
                        });
                    }
                }
                // stays on same pile & plays it if closest card is there
                else if (pileNumber == selector)
                {
                    moveDelay = new Timer(1);
                    moveDelay.SetTimer(0, timeDelay + ((float)random.NextDouble() - .5f) * timeDelay, delegate()
                                       { SelectCard(isLeftPile); myState = CompState.normal; });
                }
            }
            else if (Hand[selector].Count() == 0)
            {
                myState   = CompState.moving;
                moveDelay = new Timer(1);
                moveDelay.SetTimer(0, timeDelay + ((float)random.NextDouble() - .5f) * timeDelay, delegate()
                {
                    if (!isPlayer1)
                    {
                        MoveSelectorRight();
                    }
                    else
                    {
                        MoveSelectorLeft();
                    }
                    myState = CompState.normal;
                });
            }
        }
示例#9
0
        public bool ExistAMove2(Pile[] Hand, Pile rgamestack, Pile lgamestack)
        {
            bool moves           = false;
            int  maxPile         = -2;
            int  maxFurtherMoves = -1;

            Card[] Hands = new Card[Hand.Length];
            for (int i = 0; i < Hand.Length; i++)
            {
                if (Hand[i].Count() != 0)
                {
                    Hands[i] = Hand[i].Peek();
                }
            }
            Card right = rgamestack.Peek();
            Card left  = lgamestack.Peek();

            for (int i = 0; i < Hands.Length; i++)
            {
                if (Hands[i] != null)
                {
                    int cv     = Hands[i].cardValue;
                    int value1 = left.cardValue;
                    int value2 = right.cardValue;
                    if ((cv == 0 && value1 == 12) || (cv == 12 && value1 == 0) || (cv == value1 + 1 || cv == value1 - 1))
                    {
                        Card[] newHand = new Card[Hands.Length];
                        for (int j = 0; j < Hands.Length; j++)
                        {
                            if (j != i)
                            {
                                newHand[j] = Hands[j];
                            }
                        }
                        int tempFurtherMoves = FurtherMoves(newHand, Hands[i], right);

                        if (moves)
                        {
                            if (tempFurtherMoves > maxFurtherMoves)
                            {
                                maxFurtherMoves = tempFurtherMoves;
                                maxPile         = i;
                                isLeftPile      = true;
                            }
                            if (tempFurtherMoves == maxFurtherMoves)
                            {
                                int olddistance = Math.Abs(maxPile - selector);
                                if (olddistance > 2)
                                {
                                    olddistance = Math.Abs(olddistance - 5);
                                }
                                int newdistance = Math.Abs(i - selector);
                                if (newdistance > 2)
                                {
                                    newdistance = Math.Abs(newdistance - 5);
                                }
                                if (newdistance < olddistance)
                                {
                                    isLeftPile = true; maxPile = i;
                                }
                            }
                        }
                        else
                        {
                            moves           = true;
                            isLeftPile      = true;
                            maxPile         = i;
                            maxFurtherMoves = tempFurtherMoves;
                        }
                        pileNumber = maxPile;
                    }
                    if ((cv == 0 && value2 == 12) || (cv == 12 && value2 == 0) || (cv == value2 + 1 || cv == value2 - 1))
                    {
                        Card[] newHand = new Card[Hands.Length];
                        for (int j = 0; j < Hands.Length; j++)
                        {
                            if (j != i)
                            {
                                newHand[j] = Hands[j];
                            }
                        }
                        int tempFurtherMoves = FurtherMoves(newHand, left, Hands[i]);
                        if (moves)
                        {
                            if (tempFurtherMoves > maxFurtherMoves)
                            {
                                maxFurtherMoves = tempFurtherMoves;
                                maxPile         = i;
                                isLeftPile      = false;
                            }
                            if (tempFurtherMoves == maxFurtherMoves)
                            {
                                int olddistance = Math.Abs(maxPile - selector);
                                if (olddistance > 2)
                                {
                                    olddistance = Math.Abs(olddistance - 5);
                                }
                                int newdistance = Math.Abs(i - selector);
                                if (newdistance > 2)
                                {
                                    newdistance = Math.Abs(newdistance - 5);
                                }
                                if (newdistance < olddistance)
                                {
                                    isLeftPile = false; maxPile = i;
                                }
                            }
                        }
                        else
                        {
                            moves           = true;
                            isLeftPile      = false;
                            maxPile         = i;
                            maxFurtherMoves = tempFurtherMoves;
                        }
                        pileNumber = maxPile;
                    }
                }
            }

            return(moves);
        }
示例#10
0
        // determines if a move is available based on card values & dealt hand
        public bool ExistAMove(Pile[] Hand, Pile rgamestack, Pile lgamestack)
        {
            bool moves = false;

            for (int i = 0; i < Hand.Length; i++)
            {
                if (Hand[i].Count() != 0)
                {
                    int cv     = Hand[i].Peek().cardValue;
                    int value1 = lgamestack.Peek().cardValue;
                    int value2 = rgamestack.Peek().cardValue;
                    if ((cv == 0 && value1 == 12) || (cv == 12 && value1 == 0) || (cv == value1 + 1 || cv == value1 - 1))
                    {
                        if (moves)
                        {
                            int olddistance = Math.Abs(pileNumber - selector);
                            if (olddistance > 2)
                            {
                                olddistance = Math.Abs(olddistance - 5);
                            }
                            int newdistance = Math.Abs(i - selector);
                            if (newdistance > 2)
                            {
                                newdistance = Math.Abs(newdistance - 5);
                            }
                            if (newdistance < olddistance)
                            {
                                isLeftPile = true; pileNumber = i;
                            }
                        }
                        else
                        {
                            moves      = true;
                            isLeftPile = true;
                            pileNumber = i;
                        }
                    }
                    if ((cv == 0 && value2 == 12) || (cv == 12 && value2 == 0) || (cv == value2 + 1 || cv == value2 - 1))
                    {
                        if (moves)
                        {
                            int olddistance = Math.Abs(pileNumber - selector);
                            if (olddistance > 2)
                            {
                                olddistance = Math.Abs(olddistance - 5);
                            }
                            int newdistance = Math.Abs(i - selector);
                            if (newdistance > 2)
                            {
                                newdistance = Math.Abs(newdistance - 5);
                            }
                            if (newdistance < olddistance)
                            {
                                isLeftPile = false; pileNumber = i;
                            }
                        }
                        else
                        {
                            moves      = true;
                            isLeftPile = false;
                            pileNumber = i;
                        }
                    }
                }
            }
            return(moves);
        }
示例#11
0
 // moves card to pile with delay
 public void toPile(Pile pile, float delay)
 {
     Move(Actions.ExpoMove, new Vector2(pile.position.X, pile.position.Y), .4f, delay);
     pile.Add(this);
     Raise(.2f, delay);
     tweenerDepth.Ended += delegate() { Lower(.99f - pile.Count() * .001f, .2f); };
 }
示例#12
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();
            }
        }
示例#13
0
文件: Speed.cs 项目: rabdureh/SPEGame
        // initializes lots of variables
        public Speed(Card[] deckOfCards, Drawable background, Texture2D selector, SpriteFont font, 
            Player bottom, Player top, List<Texture2D> particles, gameType gameType, SoundEffect shuffling,
            SoundEffect playingcard, SoundEffectInstance shuffinstance, bool isSoundOn, bool isPowerUpOn, bool isVibrateOn, PowerUp powerup)
            : base(background)
        {
            myType = gameType;
            cardcounter = new int[52];
            random = new Random();
            _font = font;
            shuffle = shuffling;
            playcard = playingcard;
            shuffleinstance = shuffinstance;
            isHalted = false;
            isShaking = false;
            textures = particles;
            soundOn = isSoundOn;
            powerUpOn = isPowerUpOn;
            vibrateOn = isVibrateOn;
            ableToReBegin = true;
            ableToReBegin2 = true;
            freeze = powerup;
            freeze.isSeeable = false;
            base.Add(freeze);
            freeze.WhenPlayed(delegate(Player player)
            {
                player.Freeze();
                Timer timer = new Timer(1); base.Add(timer); timer.SetTimer(0, 4, delegate()
                {
                    player.UnFreeze();
                });
                freeze.Fade(4);
                if (player.isPlayer1) freeze.Move(Actions.ExpoMove, yourSelector.attributes.position, 1);
                else freeze.Move(Actions.ExpoMove, oppSelector.attributes.position, 1);
            });

            you = bottom;
            opp = top;
            you.SelectedCardLeft += delegate(){ PlayCard(you, you.selector, lGameStack);};
            you.SelectedCardRight += delegate() { PlayCard(you, you.selector, rGameStack); };
            opp.SelectedCardLeft += delegate() { PlayCard(opp, opp.selector, lGameStack); };
            opp.SelectedCardRight += delegate() { PlayCard(opp, opp.selector, rGameStack); };
            you.score = 0;
            opp.score = 0;

            deck = new Card[deckOfCards.Length];
            cards = new Card[deckOfCards.Length];
            for (int i = 0; i < deckOfCards.Length; i++)
            {
                deck[i] = deckOfCards[i];
                cards[i] = deckOfCards[i];
            }

            for (int i = 0; i < cards.Length; i++)
            {
                cards[i].attributes.position = new Vector2(-100, 100);
                cards[i].isFaceUp = false;
                cards[i].isSeeable = true;
                cards[i].attributes.color = Color.White;
                cards[i].attributes.rotation = 0;
                cards[i].ClearTweeners();
                cards[i].attributes.height = 180;
                cards[i].attributes.width = 130;
                deck[i].attributes.position = new Vector2(-100, 100);
                deck[i].isFaceUp = false;
                deck[i].isSeeable = true;
                deck[i].attributes.color = Color.White;
                deck[i].attributes.rotation = 0;
                deck[i].ClearTweeners();
                deck[i].attributes.height = 180;
                deck[i].attributes.width = 130;
            }
            yourStack = new Pile(new Vector2(897, 675));
            opponentStack = new Pile(new Vector2(127, 125));
            lSpitStack = new Pile(new Vector2(217, 400));
            rSpitStack = new Pile(new Vector2(807, 400));
            lGameStack = new Pile(new Vector2(413, 400));
            rGameStack = new Pile(new Vector2(610, 400));
            yourCards = new Pile[5];
            opponentCards = new Pile[5];

            for (int i = 0; i < yourCards.Length; i++)
            {
                opponentCards[i] = new Pile(new Vector2(opponentStack.position.X + (i + 1) * 154, opponentStack.position.Y));
                yourCards[i] = new Pile(new Vector2(yourStack.position.X - (i + 1) * 154, yourStack.position.Y));
            }

            yourName = new Text(you.playerName + " -  ", _font);
            yourName.height = 100;
            yourName.attributes.position = new Vector2((yourCards[3].position.X + yourCards[4].position.X)/2 - 20, (yourCards[3].position.Y + lGameStack.position.Y) / 2);
            yourName.isSeeable = true;
            yourName.attributes.color = Color.LightSkyBlue;
            yourName.attributes.depth = .02f;
            yourName.scale = new Vector2(.15f, .15f);

            oppName = new Text("  - " + opp.playerName, _font);
            oppName.height = 100;
            oppName.attributes.position = new Vector2((opponentCards[3].position.X + opponentCards[4].position.X)/2 + 20, (opponentCards[3].position.Y + lGameStack.position.Y) / 2);
            oppName.isSeeable = true;
            oppName.attributes.color = Color.Red;
            oppName.attributes.depth = .02f;
            oppName.scale = new Vector2(.15f, .15f);

            yourScore = new Text(you.score.ToString(), _font);
            yourScore.height = 100;
            yourScore.attributes.position = new Vector2(yourName.attributes.position.X + yourName.width/2 + 10, yourName.attributes.position.Y);
            yourScore.isSeeable = true;
            yourScore.attributes.color = Color.LightSkyBlue;
            yourScore.attributes.depth = .02f;
            yourScore.scale = new Vector2(.15f, .15f);

            oppScore = new Text(opp.score.ToString(), _font);
            oppScore.height = 100;
            oppScore.attributes.position = new Vector2(oppName.attributes.position.X - oppName.width/2 - 10, oppName.attributes.position.Y);
            oppScore.isSeeable = true;
            oppScore.attributes.color = Color.Red;
            oppScore.attributes.depth = .02f;
            oppScore.scale = new Vector2(.15f, .15f);

            for (int i = 0; i < cards.Length; i++)
            {
                base.Add(cards[i]);
            }

            oppSelector = new Drawable()
            {
                attributes = new Attributes()
                {
                    texture = selector,
                    position = new Vector2(-100, -100),
                    color = Color.Red,
                    height = 190,
                    width = 140,
                    depth = .11f,
                    rotation = 0
                }
            };

            yourSelector = new Drawable()
            {
                attributes = new Attributes()
                {
                    texture = selector,
                    position = new Vector2(-100, -100),
                    color = Color.LightSkyBlue,
                    height = 190,
                    width = 140,
                    depth = .11f,
                    rotation = 0
                }
            };

            base.Add(oppSelector);
            base.Add(yourSelector);

            if (myType == gameType.Marathon)
            {
                winningscore = 30;
            }

            //if (myType == gameType.Timed)
            //{
                gameLength = 120;
                delayTimer = new Timer(1);
                delayTimer.SetTimer(0, 4, delegate()
                {
                    if (speedState == gameState.GamePlay && lSpitStack.Count() != 0)
                    {
                        speedState = gameState.ReBeginning;
                        Text delay = new Text("Delay", font)
                        {
                            attributes = new Attributes()
                                {
                                    color = Color.Yellow,
                                    position = new Vector2(512, 400),
                                    depth = .001f,
                                },
                            height = 400,
                        };
                        base.Add(delay);
                        delay.Fade(2);
                        delay.WhenDoneFading(delegate() { BeginGame(); });
                    }
                });
            //}
        }
示例#14
0
文件: Speed.cs 项目: rabdureh/SPEGame
        // draws card to different piles
        public void DrawCard(Pile drawPile, Pile destinationPile, float delay)
        {
            if (destinationPile.drawnTo) return;
            ableToReBegin = false;
            destinationPile.drawnTo = true;
            Card temp = null;
            switch (myType)
            {
                case gameType.Levels:
                case gameType.Normal:
                    temp = drawPile.Take();
                    break;
                case gameType.Marathon:
                case gameType.Timed:

                    temp = getRandomCard(drawPile);
                    base.Add(temp);
                    break;
            }
            temp.Flip(true, delay);
            temp.toPile(destinationPile, delay);
            if (destinationPile.hasPowerUp) destinationPile.RemovePowerUp();
            temp.WhenDoneMoving(delegate() { destinationPile.drawnTo = false; Timer drawTimer = new Timer(1);
            base.Add(drawTimer); drawTimer.SetTimer(0, .5f, delegate() { ableToReBegin = true; });

                if ((destinationPile == lGameStack || destinationPile == rGameStack) && !destinationPile.hasPowerUp) SelectPowerUp(destinationPile);

            });
        }
示例#15
0
文件: Speed.cs 项目: rabdureh/SPEGame
        //
        private void SelectPowerUp(Pile pile)
        {
            if (powerUpOn)
            {
                double r = random.NextDouble();
                if (r < .05)
                {
                    int x = random.Next(0, (int)PowerUps.freeze);

                    PowerUp newPower = new PowerUp(freeze.engine.attributes.color, freeze.engine.textures, powerUpOn)
                    {
                        attributes = new Attributes()
                        {
                            texture = freeze.attributes.texture,
                            position = new Vector2(100, 100),
                            color = Color.White
                        }
                    };
                    newPower.isSeeable = false;
                    newPower.WhenPlayed(delegate(Player player)
                {
                    player.Freeze();
                    newPower.Fade(4);
                    if (player.isPlayer1) newPower.Move(Actions.ExpoMove, yourSelector.attributes.position, 1);
                    else newPower.Move(Actions.ExpoMove, oppSelector.attributes.position, 1);
                });
                    base.Add(newPower);
                    pile.GivePowerUp(newPower);
                }
            }
        }
示例#16
0
文件: Speed.cs 项目: rabdureh/SPEGame
        //
        private Card getRandomCard(Pile DrawPile)
        {
            bool foundint = false;
            int s = 0;
            while (!foundint)
            {
                int x = random.Next(0, 52);
                if (cardcounter[x] < numberOfDecks) foundint = true;
                s = x;
            }
            cardcounter[s]++;
            bool full = true;
            for (int i = 0; i < cardcounter.Length; i++)
            {
                if (cardcounter[i] < numberOfDecks) full = false;
            }

            if (full) cardcounter = new int[52];
            return new Card(s, deck[s].cardFront, deck[s].cardBack, DrawPile.position, false);
        }
示例#17
0
 // This has to be implemented by the extended classes
 public virtual void Update(Pile[] Hand, Pile rgamestack, Pile lgamestack, GameTime gameTime)
 {
     freezeTimer.Update(gameTime);
 }
示例#18
0
 // update method
 public override void Update(Pile[] Hand, Pile rgamestack, Pile lgamestack, GameTime gameTime)
 {
     //base.MouseUpdate();
     GamePadUpdate();
     KeyUpdate();
     base.Update(Hand, rgamestack,lgamestack,gameTime);
 }
示例#19
0
        // initializes lots of variables
        public Speed(Card[] deckOfCards, Drawable background, Texture2D selector, SpriteFont font,
                     Player bottom, Player top, List <Texture2D> particles, gameType gameType, SoundEffect shuffling,
                     SoundEffect playingcard, SoundEffectInstance shuffinstance, bool isSoundOn, bool isPowerUpOn, bool isVibrateOn, PowerUp powerup) : base(background)
        {
            myType           = gameType;
            cardcounter      = new int[52];
            random           = new Random();
            _font            = font;
            shuffle          = shuffling;
            playcard         = playingcard;
            shuffleinstance  = shuffinstance;
            isHalted         = false;
            isShaking        = false;
            textures         = particles;
            soundOn          = isSoundOn;
            powerUpOn        = isPowerUpOn;
            vibrateOn        = isVibrateOn;
            ableToReBegin    = true;
            ableToReBegin2   = true;
            freeze           = powerup;
            freeze.isSeeable = false;
            base.Add(freeze);
            freeze.WhenPlayed(delegate(Player player)
            {
                player.Freeze();
                Timer timer = new Timer(1); base.Add(timer); timer.SetTimer(0, 4, delegate()
                {
                    player.UnFreeze();
                });
                freeze.Fade(4);
                if (player.isPlayer1)
                {
                    freeze.Move(Actions.ExpoMove, yourSelector.attributes.position, 1);
                }
                else
                {
                    freeze.Move(Actions.ExpoMove, oppSelector.attributes.position, 1);
                }
            });

            you = bottom;
            opp = top;
            you.SelectedCardLeft  += delegate(){ PlayCard(you, you.selector, lGameStack); };
            you.SelectedCardRight += delegate() { PlayCard(you, you.selector, rGameStack); };
            opp.SelectedCardLeft  += delegate() { PlayCard(opp, opp.selector, lGameStack); };
            opp.SelectedCardRight += delegate() { PlayCard(opp, opp.selector, rGameStack); };
            you.score              = 0;
            opp.score              = 0;

            deck  = new Card[deckOfCards.Length];
            cards = new Card[deckOfCards.Length];
            for (int i = 0; i < deckOfCards.Length; i++)
            {
                deck[i]  = deckOfCards[i];
                cards[i] = deckOfCards[i];
            }

            for (int i = 0; i < cards.Length; i++)
            {
                cards[i].attributes.position = new Vector2(-100, 100);
                cards[i].isFaceUp            = false;
                cards[i].isSeeable           = true;
                cards[i].attributes.color    = Color.White;
                cards[i].attributes.rotation = 0;
                cards[i].ClearTweeners();
                cards[i].attributes.height  = 180;
                cards[i].attributes.width   = 130;
                deck[i].attributes.position = new Vector2(-100, 100);
                deck[i].isFaceUp            = false;
                deck[i].isSeeable           = true;
                deck[i].attributes.color    = Color.White;
                deck[i].attributes.rotation = 0;
                deck[i].ClearTweeners();
                deck[i].attributes.height = 180;
                deck[i].attributes.width  = 130;
            }
            yourStack     = new Pile(new Vector2(897, 675));
            opponentStack = new Pile(new Vector2(127, 125));
            lSpitStack    = new Pile(new Vector2(217, 400));
            rSpitStack    = new Pile(new Vector2(807, 400));
            lGameStack    = new Pile(new Vector2(413, 400));
            rGameStack    = new Pile(new Vector2(610, 400));
            yourCards     = new Pile[5];
            opponentCards = new Pile[5];

            for (int i = 0; i < yourCards.Length; i++)
            {
                opponentCards[i] = new Pile(new Vector2(opponentStack.position.X + (i + 1) * 154, opponentStack.position.Y));
                yourCards[i]     = new Pile(new Vector2(yourStack.position.X - (i + 1) * 154, yourStack.position.Y));
            }

            yourName        = new Text(you.playerName + " -  ", _font);
            yourName.height = 100;
            yourName.attributes.position = new Vector2((yourCards[3].position.X + yourCards[4].position.X) / 2 - 20, (yourCards[3].position.Y + lGameStack.position.Y) / 2);
            yourName.isSeeable           = true;
            yourName.attributes.color    = Color.LightSkyBlue;
            yourName.attributes.depth    = .02f;
            yourName.scale = new Vector2(.15f, .15f);

            oppName        = new Text("  - " + opp.playerName, _font);
            oppName.height = 100;
            oppName.attributes.position = new Vector2((opponentCards[3].position.X + opponentCards[4].position.X) / 2 + 20, (opponentCards[3].position.Y + lGameStack.position.Y) / 2);
            oppName.isSeeable           = true;
            oppName.attributes.color    = Color.Red;
            oppName.attributes.depth    = .02f;
            oppName.scale = new Vector2(.15f, .15f);

            yourScore        = new Text(you.score.ToString(), _font);
            yourScore.height = 100;
            yourScore.attributes.position = new Vector2(yourName.attributes.position.X + yourName.width / 2 + 10, yourName.attributes.position.Y);
            yourScore.isSeeable           = true;
            yourScore.attributes.color    = Color.LightSkyBlue;
            yourScore.attributes.depth    = .02f;
            yourScore.scale = new Vector2(.15f, .15f);

            oppScore        = new Text(opp.score.ToString(), _font);
            oppScore.height = 100;
            oppScore.attributes.position = new Vector2(oppName.attributes.position.X - oppName.width / 2 - 10, oppName.attributes.position.Y);
            oppScore.isSeeable           = true;
            oppScore.attributes.color    = Color.Red;
            oppScore.attributes.depth    = .02f;
            oppScore.scale = new Vector2(.15f, .15f);

            for (int i = 0; i < cards.Length; i++)
            {
                base.Add(cards[i]);
            }

            oppSelector = new Drawable()
            {
                attributes = new Attributes()
                {
                    texture  = selector,
                    position = new Vector2(-100, -100),
                    color    = Color.Red,
                    height   = 190,
                    width    = 140,
                    depth    = .11f,
                    rotation = 0
                }
            };

            yourSelector = new Drawable()
            {
                attributes = new Attributes()
                {
                    texture  = selector,
                    position = new Vector2(-100, -100),
                    color    = Color.LightSkyBlue,
                    height   = 190,
                    width    = 140,
                    depth    = .11f,
                    rotation = 0
                }
            };

            base.Add(oppSelector);
            base.Add(yourSelector);

            if (myType == gameType.Marathon)
            {
                winningscore = 30;
            }

            //if (myType == gameType.Timed)
            //{
            gameLength = 120;
            delayTimer = new Timer(1);
            delayTimer.SetTimer(0, 4, delegate()
            {
                if (speedState == gameState.GamePlay && lSpitStack.Count() != 0)
                {
                    speedState = gameState.ReBeginning;
                    Text delay = new Text("Delay", font)
                    {
                        attributes = new Attributes()
                        {
                            color    = Color.Yellow,
                            position = new Vector2(512, 400),
                            depth    = .001f,
                        },
                        height = 400,
                    };
                    base.Add(delay);
                    delay.Fade(2);
                    delay.WhenDoneFading(delegate() { BeginGame(); });
                }
            });
            //}
        }
示例#20
0
 // This has to be implemented by the extended classes
 public virtual void Update(Pile[] Hand, Pile rgamestack, Pile lgamestack, GameTime gameTime)
 {
     freezeTimer.Update(gameTime);
 }