예제 #1
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;

            //Carregando os recursos de Linguagem:
            var languadeLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            //Carregando os recursos:
            _mediumFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");
            _smallFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianSmall");
            _largeFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianLarge");

            _title1 = new Label(languadeLoader.GetString("StageLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 10), _largeFont);
            _title2 = new Label(languadeLoader.GetString("WonLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 5), _largeFont);

            _nextStage = new Label(languadeLoader.GetString("NextStageLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height / 10)), _mediumFont);

            ////Buscando o ID do mapa que vencemos:
            //_stageWonInfo = StageManager.Instance.CurrentMap;

            ////Criando a Câmera:
            //_camera = new Camera2D(game);
            //game.Components.Add(_camera);

            //int x = (int)(_stageWonInfo._mapSize.X / 2), y = (int)(_stageWonInfo._mapSize.Y / 2);
            //_camera.Focus = new Tile(game, _stageWonInfo.MapTiles[x, y]._type, _stageWonInfo.MapTiles[x, y]._mapPosition);

            //Tudo correu bem:
            return true;
        }
예제 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //Ativando os touch inputs que trataremos:
            TouchPanel.EnabledGestures = GestureType.Tap | GestureType.Flick | GestureType.Hold;

            //Salvando as orientações suportadas pelo App:
            graphics.SupportedOrientations = DisplayOrientation.Portrait;
            graphics.PreferredBackBufferWidth = 720;
            graphics.PreferredBackBufferHeight = 1280;
            graphics.ApplyChanges();

            //Enviando a instância do jogo para o Map Loader:
            StageManager.Instance.MainGame = this;

            //Inicializando a máquina de estados:
            _stateMachine = new StateMachine(this);

            //Inicializando o resto do jogo:
            base.Initialize();
        }
예제 #3
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;

            //Carregando os recursos de Linguagem:
            var languadeLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            //Carregando os recursos:
            _mediumFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");
            _smallFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianSmall");
            _largeFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianLarge");

            _title1 = new Label(languadeLoader.GetString("StageLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 10), _largeFont);
            _title2 = new Label(languadeLoader.GetString("LostLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 5), _largeFont);

            _tryAgain = new Label(languadeLoader.GetString("TryAgainLabel"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height / 10)), _mediumFont);

            //Tudo correu bem:
            return true;
        }
예제 #4
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;
            _currentStage = 1;

            //Carregando os recursos:
            _debugFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianLarge");

            //Instanciando os tiles que representam os mapas:
            _pageOne = new Tile[5, 6];
            _pageOneLbl = new Label[5, 6];

            //Instanciando os tiles:
            int _tmpCount = 1;
            for (int y = 0; y < 6; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    //Criando o tile:
                    _pageOne[x, y] = new Tile(_game, TILE_TYPES.NORMAL, new Vector2(x,y));

                    _pageOne[x, y].Sprite.Scale = 1.0f;

                    //Calculando a posição:
                    _pageOne[x, y].Sprite.DrawPosition = new Vector2(5f + (x * (_game.GraphicsDevice.Viewport.Width / 5)),
                                                              (2 * (_game.GraphicsDevice.Viewport.Height / 8)) + (y * (_game.GraphicsDevice.Viewport.Height / 8)));

                    //Criando a LABEL:
                    _pageOneLbl[x, y] = new Label(_tmpCount.ToString(),
                                                  new Vector2(_pageOne[x, y].Sprite.DrawPosition.X + ((Tile.TILE_SIZE.X * _pageOne[x, y].Sprite.Scale) / 2)/* - (_debugFont.MeasureString(1.ToString()).X / 2)*/,
                                                              _pageOne[x, y].Sprite.DrawPosition.Y),
                                                  _debugFont);

                    //Incrementando:
                    _tmpCount++;
                }
            }

            //Verificando qual foi o mapa queo usuário parou:
            //var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            //Object value = localSettings.Values["CURRENT_MAP"];

            //if(value == null)
            //{
            //    //PAramos no PRIMEIRO estágio:
            //    _currentStage = 1;
            //}
            //else
            //{
            //    //Salvando o estágio que paramos:
            //    int.TryParse(value.ToString(), out _currentStage);
            //}

            _currentStage = StageManager.Instance.QtdLoadedMaps;

            //Sinalizando na GUI os estágios já passados:
            for (int y = 0; y < 6; y++)
            {
                for (int x = 0; x < 5; x++)
                {
                    //Já passamos?
                    if (int.Parse(_pageOneLbl[x, y].Text) < _currentStage)
                    {
                        _pageOneLbl[x, y].Color = Color.LightGreen;
                        _pageOne[x, y].Sprite.Color = Color.White;
                    }
                    //Ainda não passamos:
                    else if (int.Parse(_pageOneLbl[x, y].Text) > _currentStage)
                    {
                        _pageOneLbl[x, y].Color = Color.DarkGray;
                        _pageOne[x, y].Sprite.Color = Color.DarkGray;
                    }
                    else
                    {
                        //É o mesmo:
                        _pageOneLbl[x, y].Color = Color.LightSkyBlue;
                        _pageOne[x, y].Sprite.Color = Color.White;
                    }
                }
            }

            //Tudo correu bem:
            return true;
        }
예제 #5
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;
            _clearDataTimer = TimeSpan.Zero;
            _clearDataToggle = false;
            _sound = true;

            //Carregando os recursos de Linguagem:
            var languadeLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            //Carregando os recursos:
            _mediumFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");
            _smallFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianSmall");
            _largeFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianLarge");

            //Criando as opções:
            _soundLbl = new Label(languadeLoader.GetString("SoundLabelOptions"), new Vector2(25 + (_mediumFont.MeasureString("Sounds").X / 2), game.GraphicsDevice.Viewport.Height / 3), _mediumFont);
            _soundState = new Label(languadeLoader.GetString("OnState"), new Vector2(game.GraphicsDevice.Viewport.Width - (_mediumFont.MeasureString("OFF").X), game.GraphicsDevice.Viewport.Height / 3), _mediumFont);

            _clearDataState = new Label(languadeLoader.GetString("ClearAppData"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height / 5)), _mediumFont);
            _clearDataState.Color = Color.DarkRed;

            _clearDataInfo = new Label(languadeLoader.GetString("ClearAppDataConfirm"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height / 8)), _smallFont);
            _clearDataInfo.Visible = false;

            _title = new Label(languadeLoader.GetString("OptionsMenuOption"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 10), _largeFont);

            //Salvando a propriedade do som:
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Object value = localSettings.Values["SOUNDS"];

            if (value == null)
            {
                //PAramos no PRIMEIRO estágio:
                localSettings.Values["SOUNDS"] = true;
            }

            _sound = (bool)localSettings.Values["SOUNDS"];

            //Atualizando a GUI:
            UpdateGui();

            //Tudo correu bem:
            return true;
        }
예제 #6
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;
            _loadNewLevel = false;
            _gameRunning = true;
            _stateChangeTimer = TimeSpan.Zero;

            //Carregando os recursos:
            _mediumFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");

            //Se temos mais de um mapa carregado:
            if (StageManager.Instance.QtdLoadedMaps > 0)
            {
                _currentMap = new Map(StageManager.Instance.CurrentMap, _game);
            }

            //Criando o Player:
            _player = new Player(game, _currentMap.SpawnTile);

            //Criando a Câmera:
            _camera = new Camera2D(game);
            game.Components.Add(_camera);
            _camera.Focus = _player;

            //Criando o titulo do mapa:
            _stageTitle = new Label(StageManager.Instance.CurrentMap._mapName, new Vector2(_game.GraphicsDevice.Viewport.Width / 2, _game.GraphicsDevice.Viewport.Height / 10), _mediumFont);

            //Criando o background:
            _background = new Background(_game, 30, false);

            //Tudo correu bem:
            return true;
        }
예제 #7
0
        public bool Init(MainGame game, StateMachine stateMachine)
        {
            //Salvando os valores:
            _game = game;
            _stateMachine = stateMachine;

            //Carregando os recursos de Linguagem:
            var languadeLoader = new Windows.ApplicationModel.Resources.ResourceLoader();

            //Carregando os recursos:
            _menuFont = _game.Content.Load<SpriteFont>("Fonts/QuestrianMedium");
            _titleFont = _game.Content.Load<SpriteFont>("Fonts/KL1MonoCase");

            //Criando o Título:
            _title = new Label("Blocky", new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height / 8), _titleFont);

            //Criando os botões:
            _buttons = new Label[4];

            _buttons[0] = new Label(languadeLoader.GetString("PlayMenuOption"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height * 0.65f)), _menuFont);
            _buttons[1] = new Label(languadeLoader.GetString("HighScoresMenuOption"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height * 0.5f)), _menuFont);
            _buttons[2] = new Label(languadeLoader.GetString("OptionsMenuOption"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height * 0.35f)), _menuFont);
            _buttons[3] = new Label(languadeLoader.GetString("ExitMenuOption"), new Vector2(game.GraphicsDevice.Viewport.Width / 2, game.GraphicsDevice.Viewport.Height - (game.GraphicsDevice.Viewport.Height * 0.2f)), _menuFont);

            //Criando o efeito de background:
            _background = new Background(_game, 60, true);

            //Tudo correu bem:
            return true;
        }