/// <summary> /// Initializes the game. /// </summary> /// <param name="config">Config of the current game.</param> /// <param name="gameData">Game data object for the current game.</param> public void Init(Config config, GameData gameData) { _config = config; _gameData = gameData; _hud = GetHUDScene(_config.FeedbackType); if (_hud != null) { AddChild(_hud); } _gameTimer = new Timer { WaitTime = _config.TimePerGame, OneShot = true }; _gameTimer.Connect("timeout", this, nameof(StopGameByTime)); AddChild(_gameTimer); _taskTimer = new Timer { WaitTime = _config.TimePerTask, OneShot = false }; _taskTimer.Connect("timeout", this, nameof(EndTaskTime)); AddChild(_taskTimer); _currentModifier = 0; _completedTasks = 0; _currentPerfectStreak = 0; _currentComboStreak = 0; ShowComponents(); ResetComponents(); DisableComponents(); //create countdown timer var startCountdownTimer = new Timer(); startCountdownTimer.WaitTime = Constants.GAME_COUNTDOWN_WAIT_TIME; startCountdownTimer.OneShot = true; startCountdownTimer.Connect("timeout", this, nameof(StartGame)); AddChild(startCountdownTimer); startCountdownTimer.Start(); }
public HudInfo(BaseHUD h) { hud = h; count = 1; }
public override void build() { base.build(); layerManager = new LayerManager(); //loadAlpha = 1; levelModel = (GameModel.levelsModels.ElementAt(GameModel.currentLevelID).behaviour as LevelBehaviour).levelModel; //loadScreen.init(content); backColor = levelModel.color; clouds = new LinkedList <Clouds>(); if (levelModel.clouds != null) { for (int i = 0; i < levelModel.clouds.Count; i++) { Clouds tempCloud = new Clouds(); tempCloud.texture = content.Load <Texture2D>(levelModel.clouds.ElementAt(i)); Vector2 temp = new Vector2((i + 1) % 2 == 0 ? -100 : 600, (float)new Random().Next(0, 50)); tempCloud.position = temp; clouds.AddLast(tempCloud); } } /*Cria as layers*/ environment = new StaticLayer("ENVIRONMENT"); for (int i = 0; i < levelModel.levelLayers.Count; i++) { environment.add(new StaticObject(levelModel.levelLayers.ElementAt(i))); } FXLayer = new Layer("FX"); BackEntityFXLayer = new Layer("BACK ENTITY FX"); entityLayer = new Layer("ENTITY LAYER"); rufus = new Rufus(400 - 30); rufus.position.Y = 200; rufus.dieCallback = endGame; entityLayer.add(rufus); /*Adiciona as layers*/ layerManager.add(environment); layerManager.add(BackEntityFXLayer); layerManager.add(entityLayer); layerManager.add(FXLayer); layerManager.init(content); baseHUD = new BaseHUD(); baseHUD.init(content); baseHUD.position.X = 6; baseHUD.position.Y = 444; baseHUD.start(); addChild(baseHUD); pauseButton = new PauseButton(pauseGame); pauseButton.init(content); pauseButton.position.X = 732; pauseButton.position.Y = 410; pauseButton.scale = new Vector2(1f); addChild(pauseButton); gameLoop = new GameLoop(content, rufus); gameLoop.beginGame(entityLayer); pause = false; comboBar = new ComboBar(rufus.setOnInvencible, rufus.setOffInvencible); comboBar.init(content); comboBar.updateScale(0); addChild(comboBar); inGameMenu = new InGameMenu(); inGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame); inGameMenu.hide(); addChild(inGameMenu); endGameMenu = new EndGameMenu(); endGameMenu.init(content, menuPlayCallback, backToMenu, reinitGame, goShop, goPreGame); endGameMenu.hide(); addChild(endGameMenu); totMush = 0; rufus.collideCallback = collideCallback; //endGame(); }