private void GoToGameOver() { int redScore = 0; int blueScore = 0; foreach (var cardLoc in _cardLocations) { if (cardLoc.Children[0] != null) { var card = cardLoc.Children[0].UserObject as CardBase; if (card is RedCard) { redScore += 1; } else { blueScore += 1; } } } var gameOverScene = GameOverLayer.GameScene(Window, redScore, blueScore); var transitionToGameOver = new CCTransitionMoveInR(0.3f, gameOverScene); Director.ReplaceScene(transitionToGameOver); // Window.DefaultDirector.ReplaceScene (GameOverLayer.GameScene(Window, redScore, blueScore)); }
public void ResetGame() { gameProgress = 0; elapsedTimeSinceLastPowerUp = 0.0f; cloudOffsets = Vector2.Zero; Components.Clear(); world = new World(new Vector2(0, 25)); staticWorldGround = BodyFactory.CreateRectangle(world, worldWidthInBlocks, 1, 1.0f, new Vector2(worldWidthInBlocks / 2.0f, 0.5f)); staticWorldL = BodyFactory.CreateRectangle(world, 4, worldHeightInBlocks, 1.0f, new Vector2(2.0f, -worldHeightInBlocks / 2.0f)); staticWorldR = BodyFactory.CreateRectangle(world, 1, worldHeightInBlocks, 1.0f, new Vector2(worldWidthInBlocks, -worldHeightInBlocks / 2.0f)); staticWorldGround.BodyType = BodyType.Static; staticWorldL.BodyType = BodyType.Static; staticWorldR.BodyType = BodyType.Static; staticWorldGround.Friction = 100.0f; staticWorldL.Friction = 100.0f; staticWorldR.Friction = 100.0f; staticWorldGround.CollisionCategories = COLLISION_GROUP_STATIC_OBJECTS; staticWorldL.CollisionCategories = COLLISION_GROUP_LEVEL_SEPARATOR; staticWorldR.CollisionCategories = COLLISION_GROUP_LEVEL_SEPARATOR; tetris = new TetrisPlayer(this, world); Components.Add(tetris); Components.Add(platform = new PlatformPlayer(this, world)); // Create other level components WaterLayer = new WaterLayer(this); SavePlatform = new SavePlatform(this); Components.Add(SavePlatform); Components.Add(WaterLayer); waveLayer = new WaveLayer(this); Components.Add(waveLayer); titleScreenLayer = new TitleScreenLayer(this); gameOverLayer = new GameOverLayer(this); tetrisViewport = new GameViewport(this, gameBlockSizeTetris); tetrisViewport.resize(1280, 720); tetris.viewportToSpawnIn = tetrisViewport; Components.Add(tetrisViewport); // Add GUI components StatusLayer = new GameStatusLayer(this); Components.Add(StatusLayer); MusicManager.StopMusic(); }