Ejemplo n.º 1
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);
                }
            }
        }
Ejemplo n.º 2
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(); });
                }
            });
            //}
        }
Ejemplo n.º 3
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(); });
                    }
                });
            //}
        }
Ejemplo n.º 4
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);
                }
            }
        }