示例#1
0
 public WorbsWorld(Game game, Player player)
     : base(game)
 {
     this.player = player;
     camera = player.Camera;
     AddFirstLevel();
 }
示例#2
0
        public TileMap Generate(MapInformation mapInformation, Camera camera)
        {
            Random random = new Random();

            //Create map
            List<MapLayer> mapLayers = new List<MapLayer>();

            //Ground
            MapLayer ground = new MapLayer(mapInformation.TileWidth, mapInformation.TileHeight);
            for (int y = 0; y < ground.Height; y++)
                for (int x = 0; x < ground.Width; x++)
                {
                    int grassTile = random.Next(0, 2);
                    ground[x, y] = new Tile(grassTile, 0);
                }

            //Decoration
            MapLayer decoration = new MapLayer(40, 40);
            for (int i = 0; i < mapInformation.NumberOfDecorativeObjects; i++)
            {
                int x = random.Next(0, 40);
                int y = random.Next(0, 40);
                //TODO ADD CHECK SO NO OVERWRITE
                int tileIndex = random.Next(3, 15);

                if(tileIndex == 14) //Add tree
                {
                    Tile treeTile = new Tile(tileIndex, 0); // tileSet: 0
                    if (y > 0)
                        decoration[x, y-1] = treeTile;
                    tileIndex = 15; //to get the foot below
                }

                Tile tile = new Tile(tileIndex, 0); // tileSet: 0
                decoration[x, y] = tile;
            }

            mapLayers.Insert(0, ground);
            mapLayers.Insert(1, decoration);

            //Add player position
            //TODO make sure it is created along water at the sides
            int playerX = random.Next(1, (mapInformation.TileWidth * 32)-32); //TODO have better calc
            int playerY = random.Next(1, (mapInformation.TileHeight * 32)-32); //TODO have better calc
            camera.Position = new Vector2((float)150, (float)150);
            //camera.Position = new Vector2((float)playerX, (float)playerY);

            //Create enemies
            foreach (EnemyInformation ei in mapInformation.Enemies)
            {
                Enemy enemy = new Enemy(game);                          //TODO dont add enemies to close to the player
                int enemyX = random.Next(1, (mapInformation.TileWidth * 32) - 32); //TODO have better calc
                int enemyY = random.Next(1, (mapInformation.TileWidth * 32) - 32); //TODO have better calc
                enemy.Create(ei, new Vector2((float)enemyX, (float)enemyY));
                enemies.Add(enemy);
            }

            return new TileMap(camera.Game, mapInformation.TileSets, mapLayers);
        }
示例#3
0
 public TileMap(Game game, List<TileSet> tileSets, List<MapLayer> mapLayers, Camera camera)
     : base(game)
 {
     this.tileSets = tileSets;
     this.mapLayers = mapLayers;
     this.camera = camera;
     SetMapSize();
     ValidateSizeOfAllLayers();
 }
示例#4
0
 public Projectile(Game game, string textureName, Vector2 position, float damage, Vector2 speed, bool playerProjectile, Camera camera)
     : base(game)
 {
     this.textureName = textureName;
     this.position = position;
     this.startingPosition = this.position;
     this.viewport = game.GraphicsDevice.Viewport;
     Damage = damage;
     this.speed = speed;
     this.PlayerProjectile = playerProjectile;
     this.camera = camera;
     Active = true;
     speed.Normalize();
 }
示例#5
0
        public Player(Game game, Camera camera)
            : base(game)
        {
            Camera = camera;
            var startingPosition = Camera.Position;
            multiSprite = new MultiSprite(startingPosition, 70);
            multiSprite.States.Add(State.IdleDown.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleDown", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.IdleUp.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleUp", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.IdleRight.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleRight", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.IdleLeft.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleLeft", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.Walk.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/Walk", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.WalkUp.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/WalkUp", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
            multiSprite.States.Add(State.WalkDown.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/WalkDown", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
            //multiSprite.States.Add(State.Attack.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/Attack", new Point(0, 0), new Point(140, 160), new Point(2, 1), SpriteDirection.Right));
            multiSprite.CurrentState = State.IdleDown.ToString();

            // Load player characteristics
            HitPoints = 100;
            Health = HitPoints;
        }
示例#6
0
 public GameScene(Game game)
     : base(game)
 {
     Type = SceneType.Game;
     // Initialize camera and player
     camera = new Camera(game, new Rectangle(0, 0, 800, 480)); // TODO: Fix this so it is not hardcoded -> GraphicsDevice is not initialized at this point, need to wrap it somehow (perhaps add it as a service) so the camera will access it later when it's initialized
     // Player
     Player = new Player(game, camera);
     // World
     theWorldOfWorbs = new WorbsWorld(game, Player);
     SceneComponents.Add(theWorldOfWorbs);
     //User interface
     controls = new GameControls(game);
     GraphicButton inventoryButton = new GraphicButton(game, "ShowInventory", "Sprites/menu-button-30", new Vector2(760, 10));
     controls.AddControl(inventoryButton);
     inventoryButton.Clicked += ShowInventory;
     StaticSceneComponents.Add(controls);
     playerHealthBar = new HealthBar(game, "Sprites/player-health-bar", "Sprites/blood-stream", new Vector2(10, 10), Player.Health);
     StaticSceneComponents.Add(playerHealthBar);
 }
示例#7
0
 public Player(Game game, Camera camera)
     : base(game)
 {
     // Player entity
     Entity = new Entity(game, "Gandalf", Gender.Male, EntityType.Player, EntityClassManager.GetClasses()["Wizard"], EntityRaceManager.GetRaces()["Human"]);
     Entity.Inventory.Add(ItemManager.GetItems()["Apprentice's Wand"]);
     // Camera
     Camera = camera;
     var startingPosition = Camera.Position;
     multiSprite = new MultiSprite(startingPosition, 70);
     multiSprite.States.Add(State.IdleDown.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleDown", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.IdleUp.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleUp", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.IdleRight.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleRight", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.IdleLeft.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/IdleLeft", new Point(0, 0), new Point(50, 50), new Point(1, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.Walk.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/Walk", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.WalkUp.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/WalkUp", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
     multiSprite.States.Add(State.WalkDown.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/WalkDown", new Point(0, 0), new Point(50, 50), new Point(2, 1), SpriteDirection.Right));
     //multiSprite.States.Add(State.Attack.ToString(), new SpriteSheet("SpriteSheets/Player/Wizard/Attack", new Point(0, 0), new Point(140, 160), new Point(2, 1), SpriteDirection.Right));
     multiSprite.CurrentState = State.IdleDown.ToString();
 }
示例#8
0
        public GameScene(Game game)
            : base(game)
        {
            // Initialize map settings
            camera = new Camera(game, new Rectangle(0, 0, 800, 480)); // TODO: Fix this so it is not hardcoded -> GraphicsDevice is not initialized at this point, need to wrap it somehow (perhaps add it as a service) so the camera will access it later when it's initialized

            MapInformation mapInformation = new MapInformation(Game);
            mapInformation.LoadMapFromXML("test map");
            map = MapGenerator.Generate(mapInformation, camera);

            Font gameTitle = new Font(game, "Generated map", new Vector2(0, 0), Color.Black);

            crossControl = new CrossControl(game);

            // Player
            player = new Player(game, camera);
            SceneComponents.Add(map);
            SceneComponents.Add(gameTitle);
            SceneComponents.Add(player);
            SceneComponents.Add(crossControl);
        }
示例#9
0
 public TileMap(Game game, TileSet tileSet, MapLayer mapLayer, Camera camera)
     : this(game, new List<TileSet> { tileSet }, new List<MapLayer> { mapLayer }, camera)
 {
 }