Example #1
0
        public Background(MainGame game, int qtdTiles, bool player)
        {
            //Instanciando os membros:
            _random = new Random();
            _updateTimer = TimeSpan.Zero;
            _hasPlayer = player;

            //Instanciando os tiles que serão exibidos aleatoriamente no fundo da tela:
            _randomTiles = new Tile[qtdTiles];

            for (int i = 0; i < qtdTiles; i++)
            {
                _randomTiles[i] = new Tile(game, TILE_TYPES.NORMAL, new Vector2(0, 0));
                _randomTiles[i].Sprite.DrawPosition = new Vector2(_random.Next(0, game.GraphicsDevice.Viewport.Width),
                                                            _random.Next(0, game.GraphicsDevice.Viewport.Height));
                _randomTiles[i].Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
                _randomTiles[i].Sprite.Scale = (float)_random.NextDouble() + 0.5f;
            }

            //Criando o player:
            if(_hasPlayer)
            {
                _playerTile = new Tile(game, TILE_TYPES.NORMAL, new Vector2(0, 0));
                _playerTile.Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
                _playerTile.Sprite.DrawPosition = new Vector2(_random.Next(50, game.GraphicsDevice.Viewport.Width - 50),
                                                                _random.Next(50, game.GraphicsDevice.Viewport.Height - 50));

                _player = new Player(game, _playerTile);
                _player.Sprite.Color = new Color(0.5f, 0.5f, 0.5f);
            }
            else
            {
                _player = null;
            }
        }
Example #2
0
        public Player(MainGame game, Tile spawnPoint)
        {
            //Salvando os tiles ocupados:
            mCurrentTiles = new List<Tile>();
            mCurrentTiles.Add(spawnPoint);

            //Definindo o estado inicial:
            mCurrentState = STATE.STANDING;

            //Inicializando o Sprite:
            _sprite = new Sprite(game.Content.Load<Texture2D>("Images/Tileset"), mCurrentTiles[0].Sprite.DrawPosition);

            //Corrigindo o Y:
            _sprite.DrawPosition_Y -= 128;

            //Salvando o spriteRect:
            _sprite.SpriteRect = new Rectangle(0, 64, 128, 192);

            //Atualizando a origem do sprite (Sempre Centralizada):
            _sprite.Origin = new Vector2(_sprite.SpriteRect.Width / 2, _sprite.SpriteRect.Height / 2);
            _sprite.Color = new Color(Color.White, 0.5f);
            _sprite.Rotation = 0f;

            //Zerando:
            _qtdMoves = 0;
            _playTime = TimeSpan.Zero;
        }
Example #3
0
        public Map(sLoadedMap mapInfo, MainGame game)
        {
            //Salvando as informações:
            _mapInfo = mapInfo;
            mExitTiles = new List<Tile>();

            //Instanciando os tiles:
            _tiles = new Tile[(int)_mapInfo._mapSize.X, (int)_mapInfo._mapSize.Y];
            for (int x = 0; x < _mapInfo._mapSize.X; x++)
            {
                for (int y = 0; y < _mapInfo._mapSize.Y; y++)
                {
                    _tiles[x,y] = new Tile(game, _mapInfo.MapTiles[x, y]._type, _mapInfo.MapTiles[x, y]._mapPosition);
                }
            }

            //Acertando as posições de desenho:
            for (int y = 0; y < _mapInfo._mapSize.Y; y++)
            {
                for (int x = (int)_mapInfo._mapSize.X - 1; x >= 0; x--)
                {
                    //Calculando a posição:
                    _tiles[x, y].Sprite.DrawPosition = new Vector2((x * Tile.TILE_SIZE.X / 2) + (y * Tile.TILE_SIZE.X / 2),
                                                               (y * Tile.TILE_SIZE.Y / 2) - (x * Tile.TILE_SIZE.Y / 2));
                }
            }

            //Procurando o Spawn Point e as saídas:
            foreach (var tile in _tiles)
            {
                //É um spawn?
                if(tile.Type == TILE_TYPES.SPAWN)
                {
                    mSpawnPoint = tile;
                }

                if(tile.Type == TILE_TYPES.EXIT)
                {
                    mExitTiles.Add(tile);
                }
            }
        }
        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;
        }