// deals cards to their piles, says to press enter to start public void Deal() { speedState = gameState.Dealing; if (myType == gameType.Levels) { Text levelText = new Text("Level " + level, _font) { height = 200, attributes = new Attributes() { color = Color.Yellow, depth = .5f, position = new Vector2(512, 400), }, }; base.Add(levelText); levelText.Fade(4); } Shuffle(cards); for (int i = 0; i < cards.Length; i++) { cards[i].isFaceUp = false; if (i % 4 == 3 && i < 20) { cards[i].toPile(rSpitStack, (float)i / 13); } else if (i % 4 == 2 && i < 20) { cards[i].toPile(lSpitStack, (float)i / 13); } else if (i % 2 == 1) { cards[i].toPile(yourStack, (float)i / 13); } else if (i % 2 == 0) { cards[i].toPile(opponentStack, (float)i / 13); } } Text begin = new Text("Press Enter to Start", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400), rotation = 0, depth = .5f }, scale = new Vector2(.1f, .1f) }; cards[51].WhenDoneMoving(delegate() { base.Add(begin); speedState = gameState.AskBegin; }); }
// does actions if player is a winner public void Winner(Player winner) { speedState = gameState.Winner; yourName.Fade(4); oppName.Fade(4); yourScore.Fade(4); oppScore.Fade(4); if (myType == gameType.Levels) { levelss.Fade(4); } for (int i = 0; i < yourCards.Length; i++) { if (yourCards[i].Count() != 0) { yourCards[i].Take().Fade(4); } if (opponentCards[i].Count() != 0) { opponentCards[i].Take().Fade(4); } } while (yourStack.Count() != 0) { yourStack.Take().Fade(4); } while (opponentStack.Count() != 0) { opponentStack.Take().Fade(4); } if (winner == null) { Tie(); } else if (winner.isPlayer1) { YourAWinner(); } else { OppAWinner(); } }
// 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()); } }
// 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(); }); } }); //} }
// turns game on public override void TurnOn() { if (myType == gameType.Timed) { gameTimer = new Timer(1); gameTimer.SetTimer(0, gameLength, delegate() { Winner(DetermineWinner()); ableToReBegin = false; ableToReBegin2 = false; /*time1.Fade(4);*/ time2.Fade(4); speedState = gameState.Winner; }); /*time1 = new Text(gameTimer.getCountDown(0), _font); * time1.height = 100; * time1.attributes.position = new Vector2(yourName.attributes.position.X, oppName.attributes.position.Y); * time1.isSeeable = true; * time1.attributes.color = Color.Black; * time1.attributes.depth = .02f; * time1.scale = new Vector2(.15f, .15f);*/ time2 = new Text(gameTimer.getCountDown(0), _font); time2.height = 100; time2.attributes.position = new Vector2(oppName.attributes.position.X, yourName.attributes.position.Y); time2.isSeeable = true; time2.attributes.color = Color.Black; time2.attributes.depth = .02f; time2.scale = new Vector2(.12f, .12f); } Deal(); base.TurnOn(); }
// 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); }); } }); }
// if game ends in a tie, displays certain text & fades some drawables& adds endgame actions public void Tie() { speedState = gameState.Winner; Text tieTop = new Text("It's a tie!", _font) { attributes = new Attributes() { position = new Vector2(512, 200), color = Color.RoyalBlue, //rotation = -.2f, depth = .1f }, scale = new Vector2(.8f, .8f) }; Text tieMiddle = new Text("You're both", _font) { attributes = new Attributes() { position = new Vector2(512, 400), color = Color.Red, //rotation = -.2f, depth = .1f }, scale = new Vector2(.7f, .7f) }; Text tieBottom = new Text("SCRUBS!!!", _font) { attributes = new Attributes() { position = new Vector2(512, 600), color = Color.Red, //rotation = -.2f, depth = .1f }, scale = new Vector2(.7f, .7f) }; yourSelector.Fade(2); yourSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); yourSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); oppSelector.Fade(2); oppSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); oppSelector.WhenDoneMoving(delegate() { base.Add(tieTop); if (myType == gameType.Levels) { YouTie(); } base.Add(tieMiddle); base.Add(tieBottom); }); oppSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); Timer endGame = new Timer(2); base.Add(endGame); endGame.SetTimer(0, 6, delegate() { yourScore.attributes.color = Color.LightSkyBlue; yourScore.isSeeable = true; yourScore.attributes.position = new Vector2(400, 675); yourScore.height = 150; oppScore.attributes.color = Color.Red; oppScore.isSeeable = true; oppScore.attributes.position = new Vector2(624, 675); oppScore.height = 150; Text dash = new Text(" - ", _font); dash.attributes = new Attributes() { color = Color.Black, position = new Vector2(512, 675) }; dash.isSeeable = true; dash.height = 150; base.Add(dash); Reset(); }); endGame.SetTimer(1, 4, delegate() { tieTop.Fade(2); tieMiddle.Fade(2); tieBottom.Fade(2); }); }
// if top player wins, displays certain text & fades some drawables& adds endgame actions public void OppAWinner() { speedState = gameState.Winner; Text winner = new Text("Winner!!!", _font) { attributes = new Attributes() { color = Color.Red, position = new Vector2(512, 180), //rotation = -.2f, depth = .1f }, scale = new Vector2(.8f, .8f) }; Text loser = new Text("Scrub!!!", _font) { attributes = new Attributes() { color = Color.DarkBlue, position = new Vector2(512, 650), //rotation = -.2f, depth = .1f }, scale = new Vector2(.8f, .8f) }; yourSelector.Fade(2); oppSelector.Fade(2); oppSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); oppSelector.WhenDoneMoving(delegate() { base.Add(winner); base.Add(loser); }); oppSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); Timer endGame = new Timer(2); base.Add(endGame); endGame.SetTimer(0, 6, delegate() { yourScore.attributes.color = Color.LightSkyBlue; yourScore.isSeeable = true; yourScore.attributes.position = new Vector2(624, 675); yourScore.height = 150; oppScore.attributes.color = Color.Red; oppScore.isSeeable = true; oppScore.attributes.position = new Vector2(400, 675); oppScore.height = 150; Text dash = new Text(" - ", _font); dash.attributes = new Attributes() { color = Color.Black, position = new Vector2(512, 675) }; dash.isSeeable = true; dash.height = 150; base.Add(dash); if (myType == gameType.Levels) { YouLost(); } else { Reset(); } }); endGame.SetTimer(1, 4, delegate() { winner.Fade(2); loser.Fade(2); }); }
// if bottom player wins, displays certain text & fades some drawables& adds endgame actions public void YourAWinner() { speedState = gameState.Winner; Text winner = new Text("Winner!!!", _font) { attributes = new Attributes() { color = Color.LightSkyBlue, position = new Vector2(512, 650), //rotation = -.2f, depth = .1f, }, scale = new Vector2(.8f,.8f) }; Text loser = new Text("Scrub!!!", _font) { attributes = new Attributes() { color = Color.DarkRed, position = new Vector2(512, 180), //rotation = -.2f, depth = .1f }, scale = new Vector2(.8f,.8f) }; oppSelector.Fade(2); yourSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); yourSelector.Fade(2); yourSelector.WhenDoneMoving( delegate() { base.Add(winner); base.Add(loser); }); yourSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); Timer endGame = new Timer(2); base.Add(endGame); endGame.SetTimer(0, 6, delegate() { yourScore.attributes.color = Color.LightSkyBlue; yourScore.isSeeable = true; yourScore.attributes.position = new Vector2(400, 675); yourScore.height = 150; oppScore.attributes.color = Color.Red; oppScore.isSeeable = true; oppScore.attributes.position = new Vector2(624, 675); oppScore.height = 150; Text dash = new Text(" - ", _font); dash.attributes = new Attributes() { color = Color.Black, position = new Vector2(512, 675) }; dash.isSeeable = true; dash.height = 150; base.Add(dash); if (myType == gameType.Levels) YouWon(); else Reset(); }); endGame.SetTimer(1, 4, delegate() { winner.Fade(2); loser.Fade(2); }); }
// if game ends in a tie, displays certain text & fades some drawables& adds endgame actions public void Tie() { speedState = gameState.Winner; Text tieTop = new Text("It's a tie!", _font) { attributes = new Attributes() { position = new Vector2(512, 200), color = Color.RoyalBlue, //rotation = -.2f, depth = .1f }, scale = new Vector2(.8f,.8f) }; Text tieMiddle = new Text("You're both", _font) { attributes = new Attributes() { position = new Vector2(512, 400), color = Color.Red, //rotation = -.2f, depth = .1f }, scale = new Vector2(.7f,.7f) }; Text tieBottom = new Text("SCRUBS!!!", _font) { attributes = new Attributes() { position = new Vector2(512, 600), color = Color.Red, //rotation = -.2f, depth = .1f }, scale = new Vector2(.7f,.7f) }; yourSelector.Fade(2); yourSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); yourSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); oppSelector.Fade(2); oppSelector.Move(Actions.ExpoMove, new Vector2(512, 400), 2); oppSelector.WhenDoneMoving( delegate() { base.Add(tieTop); if (myType == gameType.Levels) YouTie(); base.Add(tieMiddle); base.Add(tieBottom); }); oppSelector.Scale(Actions.LinearMove, yourSelector.attributes.scale * 2, 2); Timer endGame = new Timer(2); base.Add(endGame); endGame.SetTimer(0, 6, delegate() { yourScore.attributes.color = Color.LightSkyBlue; yourScore.isSeeable = true; yourScore.attributes.position = new Vector2(400, 675); yourScore.height = 150; oppScore.attributes.color = Color.Red; oppScore.isSeeable = true; oppScore.attributes.position = new Vector2(624, 675); oppScore.height = 150; Text dash = new Text(" - ", _font); dash.attributes = new Attributes() { color = Color.Black, position = new Vector2(512, 675) }; dash.isSeeable = true; dash.height = 150; base.Add(dash); Reset();}); endGame.SetTimer(1, 4, delegate() { tieTop.Fade(2); tieMiddle.Fade(2); tieBottom.Fade(2); }); }
// 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()); }
// 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(); }); } }); //} }
// deals cards to their piles, says to press enter to start public void Deal() { speedState = gameState.Dealing; if (myType == gameType.Levels) { Text levelText = new Text("Level " + level, _font) { height = 200, attributes = new Attributes() { color = Color.Yellow, depth = .5f, position = new Vector2(512, 400), }, }; base.Add(levelText); levelText.Fade(4); } Shuffle(cards); for (int i = 0; i < cards.Length; i++) { cards[i].isFaceUp = false; if (i % 4 == 3 && i < 20) cards[i].toPile(rSpitStack, (float)i / 13); else if (i % 4 == 2 && i < 20) cards[i].toPile(lSpitStack, (float)i / 13); else if (i % 2 == 1) cards[i].toPile(yourStack, (float)i / 13); else if (i % 2 == 0) cards[i].toPile(opponentStack, (float)i / 13); } Text begin = new Text("Press Enter to Start", _font) { attributes = new Attributes() { color = Color.Yellow, position = new Vector2(512, 400), rotation = 0, depth = .5f }, scale = new Vector2(.1f,.1f) }; cards[51].WhenDoneMoving( delegate() { base.Add(begin); speedState = gameState.AskBegin; }); }
// 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); }); }); }