Exemple #1
0
        // adds cards to game stacks if no cards are playable
        public void ReBegin()
        {
            if (!ableToReBegin || !ableToReBegin2)
            {
                return;
            }
            if (speedState == gameState.Winner)
            {
                return;
            }
            if (speedState == gameState.PlayAgain)
            {
                return;
            }
            ableToReBegin = false;
            speedState    = gameState.ReBeginning;
            Timer watch = new Timer(1);

            base.Add(watch);
            watch.SetTimer(0, 1, delegate()
            {
                Text nomove = new Text("No Moves", _font)
                {
                    attributes = new Attributes()
                    {
                        color = Color.Yellow, position = new Vector2(512, 400)
                    },
                    scale = new Vector2(.5f, .5f)
                };
                base.Add(nomove);
                nomove.Move(Actions.LinearMove, nomove.attributes.position, 1);
                nomove.WhenDoneMoving(delegate() { nomove.isSeeable = false; });
            });
            if (lSpitStack.Count() != 0)
            {
                Timer stopwatch = new Timer(5);
                base.Add(stopwatch);

                stopwatch.SetTimer(0, 3, delegate()
                {
                    Text two = new Text("2", _font)
                    {
                        attributes = new Attributes()
                        {
                            color = Color.Yellow, position = new Vector2(512, 400)
                        }
                    };
                    base.Add(two);
                    two.Fade(1);
                });
                stopwatch.SetTimer(1, 4, delegate()
                {
                    Text one = new Text("1", _font)
                    {
                        attributes = new Attributes()
                        {
                            color = Color.Yellow, position = new Vector2(512, 400)
                        }
                    };
                    base.Add(one);
                    one.Fade(1);
                });
                stopwatch.SetTimer(2, 5, delegate()
                {
                    Text title = new Text("SPEED!", _font)
                    {
                        attributes = new Attributes()
                        {
                            color = Color.Yellow, position = new Vector2(512, 400)
                        }
                    };
                    base.Add(title);
                    title.Fade(.5f);
                    title.WhenDoneFading(new Tweener.EndHandler(BeginGame));
                });
                stopwatch.SetTimer(3, 2, delegate()
                {
                    Text three = new Text("3", _font)
                    {
                        attributes = new Attributes()
                        {
                            color = Color.Yellow, position = new Vector2(512, 400)
                        }
                    };
                    base.Add(three);
                    three.Fade(1);
                });
            }

            else
            {
                Winner(DetermineWinner());
            }
        }
Exemple #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(); });
                }
            });
            //}
        }
Exemple #3
0
        //
        public void Begin()
        {
            base.RemoveLast();
            if (myType == gameType.Timed)
            {
                //base.Add(time1);
                base.Add(time2);
            }

            if (myType == gameType.Levels)
            {
                levelss = new Text("Level " + level, _font)
                {
                    height     = 100,
                    attributes = new Attributes()
                    {
                        color    = Color.Black,
                        position = new Vector2(rSpitStack.position.X + 50, yourName.attributes.position.Y),
                        depth    = .01f
                    },
                    scale = new Vector2(.15f, .15f),
                };
                base.Add(levelss);
            }
            base.Add(yourName);
            base.Add(oppName);
            base.Add(yourScore);
            base.Add(oppScore);
            speedState = gameState.Beginning;
            for (int i = 0; i < 5; i++)
            {
                DrawCard(yourStack, yourCards[i], i * .675f);
                DrawCard(opponentStack, opponentCards[i], i * .675f);
            }

            Timer stopwatch = new Timer(3);

            base.Add(stopwatch);
            Text three = new Text("3", _font)
            {
                attributes = new Attributes()
                {
                    color = Color.Yellow, position = new Vector2(512, 400)
                }
            };

            base.Add(three);
            three.Fade(1);

            stopwatch.SetTimer(0, 1, delegate()
            {
                Text two = new Text("2", _font)
                {
                    attributes = new Attributes()
                    {
                        color = Color.Yellow, position = new Vector2(512, 400)
                    }
                };
                base.Add(two);
                two.Fade(1);
            });
            stopwatch.SetTimer(1, 2, delegate()
            {
                Text one = new Text("1", _font)
                {
                    attributes = new Attributes()
                    {
                        color = Color.Yellow, position = new Vector2(512, 400)
                    }
                };
                base.Add(one);
                one.Fade(1);
            });
            stopwatch.SetTimer(2, 3, delegate()
            {
                Text title = new Text("SPEED!", _font)
                {
                    attributes = new Attributes()
                    {
                        color = Color.Yellow, position = new Vector2(512, 400)
                    }
                };
                base.Add(title);
                title.Fade(.5f);
                title.WhenDoneFading(new Tweener.EndHandler(BeginGame));
                if (myType == gameType.Timed)
                {
                    title.WhenDoneFading(delegate() { base.Add(gameTimer); });
                }
            });
        }
Exemple #4
0
        // adds cards to game stacks if no cards are playable
        public void ReBegin()
        {
            if (!ableToReBegin || !ableToReBegin2) return;
            if (speedState == gameState.Winner) return;
            if (speedState == gameState.PlayAgain) return;
            ableToReBegin = false;
            speedState = gameState.ReBeginning;
                Timer watch = new Timer(1);
                base.Add(watch);
                watch.SetTimer(0, 1, delegate()
                {
                    Text nomove = new Text("No Moves", _font)
                    {
                        attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) },
                        scale = new Vector2(.5f, .5f)
                    };
                    base.Add(nomove);
                    nomove.Move(Actions.LinearMove, nomove.attributes.position, 1);
                    nomove.WhenDoneMoving(delegate() { nomove.isSeeable = false; });
                });
            if (lSpitStack.Count() != 0)
            {
                Timer stopwatch = new Timer(5);
                base.Add(stopwatch);

                stopwatch.SetTimer(0, 3, delegate()
                {
                    Text two = new Text("2", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                    base.Add(two);
                    two.Fade(1);
                });
                stopwatch.SetTimer(1, 4, delegate()
                {
                    Text one = new Text("1", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                    base.Add(one);
                    one.Fade(1);
                });
                stopwatch.SetTimer(2, 5, delegate()
                {
                    Text title = new Text("SPEED!", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                    base.Add(title);
                    title.Fade(.5f);
                    title.WhenDoneFading(new Tweener.EndHandler(BeginGame));
                });
                stopwatch.SetTimer(3, 2, delegate()
                {
                    Text three = new Text("3", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                    base.Add(three);
                    three.Fade(1);
                });
            }

            else Winner(DetermineWinner());
        }
Exemple #5
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(); });
                    }
                });
            //}
        }
Exemple #6
0
        //
        public void Begin()
        {
            base.RemoveLast();
            if (myType == gameType.Timed)
            {
                //base.Add(time1);
                base.Add(time2);
            }

            if (myType == gameType.Levels)
            {
                levelss = new Text("Level " + level, _font)
                {
                    height = 100,
                    attributes = new Attributes()
                    {
                        color = Color.Black,
                        position = new Vector2(rSpitStack.position.X + 50, yourName.attributes.position.Y),
                        depth = .01f
                    },
                    scale = new Vector2(.15f, .15f),
                };
                base.Add(levelss);

            }
                base.Add(yourName);
                base.Add(oppName);
                base.Add(yourScore);
                base.Add(oppScore);
            speedState = gameState.Beginning;
            for (int i = 0; i < 5; i++)
            {
                DrawCard(yourStack, yourCards[i], i * .675f);
                DrawCard(opponentStack, opponentCards[i], i * .675f);
            }

            Timer stopwatch = new Timer(3);
            base.Add(stopwatch);
            Text three = new Text("3", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
            base.Add(three);
            three.Fade(1);

            stopwatch.SetTimer(0, 1, delegate()
            {
                Text two = new Text("2", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                base.Add(two);
                two.Fade(1);

            });
            stopwatch.SetTimer(1, 2, delegate()
            {
                Text one = new Text("1", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                base.Add(one);
                one.Fade(1);

            });
            stopwatch.SetTimer(2, 3, delegate()
            {
                Text title = new Text("SPEED!", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400) } };
                base.Add(title);
                title.Fade(.5f);
                title.WhenDoneFading(new Tweener.EndHandler(BeginGame));
                if(myType == gameType.Timed) title.WhenDoneFading(delegate() { base.Add(gameTimer); });
            });
        }