Esempio n. 1
0
        /// <summary>
        /// Verifies that the entity is attempting to move into a valid tile
        /// </summary>
        /// <param name="map"></param>
        /// <param name="attemptedMovePosition"></param>
        /// <returns></returns>
        public bool CanMoveIntoTile(int level, Point attemptedMovePosition)
        {
            Terrain map = TerrainManager.GetCurrentMap(level);

            // Make sure we stay within the map boundaries
            if ((attemptedMovePosition.X >= map.MapSize.X || attemptedMovePosition.X < 0) ||
                (attemptedMovePosition.Y >= map.MapSize.Y || attemptedMovePosition.Y < 0))
            {
                return(false);
            }

            // Checks if the tile has a collider
            if (map.GetTileAtGridPosition(attemptedMovePosition).IsCollider)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public Player() : base(TerrainManager.CurrentLevel)
        {
            // Make sure we have a valid map to load into
            if (TerrainManager.MapList.Equals(null))
            {
                throw new Exception("Map passed to Player constructor is empty!");
            }

            this.CurrentLevel = TerrainManager.CurrentLevel;

            this.GridPosition      = new Point(0, 0);
            this.ObjectSize        = this.ScaleObjectToTileSize();
            this.DrawPosition      = this.UpdateDrawPosition();
            this.DrawOffset        = this.GenerateDrawOffset();
            this.DrawRectangle     = this.UpdateDrawRectangle(this.GridPosition, TerrainManager.GetCurrentMap(this.CurrentLevel).MapSize);
            this.IsCollider        = true;
            this.IsDormant         = false;
            this.currentExperience = 0;
            this.movementTimeLimit = 500;
            this.moveAllowed       = true;
        }