Exemplo n.º 1
0
        public static void CreateWoodenBuilding(int xPos, int yPos, int xLength, int yLength)
        {
            for (int y = 0; y <= 1; y++)
            {
                for (int x = 0; x < xLength; x++)
                {
                    map.AddObjectAt(PropFactory.CreateWoodWall(), xPos + x, yPos + ((yLength - 1) * y));
                }
            }

            for (int x = 0; x <= 1; x++)
            {
                for (int y = 1; y < yLength - 1; y++)
                {
                    map.AddObjectAt(PropFactory.CreateWoodWall(), xPos + ((xLength - 1) * x), yPos + y);
                }
            }

            for (int x = 0; x < xLength; x++)
            {
                for (int y = 0; y < yLength; y++)
                {
                    map.GetBlockAt(x + xPos, y + yPos).TerrainList[0] = new Terrain("wood_floor_bmp");
                }
            }
        }
Exemplo n.º 2
0
        protected void LoadData()
        {
            player = new Player(new Vector2(0, 0), "player_bmp");
            player.Graphic.Texture = GraphicsDispenser.getTexture("player_bmp");
            player.AddSkill(new Skill(SkillNames.MEDICAL_SKILL));

            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());

            player.Inventory.Add(ItemFactory.CreateBandage(player));
            player.Inventory.Add(ItemFactory.CreateBandage(player));

            Weapon sword2 = WeaponFactory.CreateSword();

            sword2.Name = "OTHER Sword";
            player.Inventory.Add(sword2);
            player.Inventory.Add(WeaponFactory.CreateSword());



            map = new Map(80, 80);
            map.GetBlockAt(5, 5).AddObject(player);
            MapGenerator.map = map;
            MapGenerator.CreateWoodenBuilding(10, 10, 30, 30);

            Light l = new Light(80, Color.Blue);

            map.AddObjectAt(l, 21, 23);

            Door d = new Door("door_closed_bmp");

            d.Interaction = new UseDoorPAbility(d);
            map.GetBlockAt(5, 10).AddObject(d);

            camera = new Camera(player, Game.VISBLE_MAP_WIDTH, Game.VISBLE_MAP_HEIGHT, map);

            Zombie z = EntityFactory.CreateZombie(player);

            z.ChangeStateTo(ZombieStateNames.SEARCH_STATE, player.Location);
            entities.Add(z);
            map.GetBlockAt(6, 6).AddObject(z);
            MapGenerator.PutZombiesEverywhere(100, player);

            Item item = new Item("item_bmp");

            map.GetBlockAt(3, 3).AddObject(item);

            MessageBus.Instance.AddMessage(new DominatingMessage(player, z, item));
        }
Exemplo n.º 3
0
        protected void LoadData()
        {
            player = new Player("player_bmp");
            player.AddSkill(new Skill(SkillNames.MEDICAL_SKILL));

            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());

            player.Inventory.Add(ItemFactory.CreateBandage(player));
            player.Inventory.Add(ItemFactory.CreateBandage(player));

            Weapon sword2 = WeaponFactory.CreateSword();

            sword2.Name = "OTHER Sword";
            player.Inventory.Add(sword2);
            player.Inventory.Add(WeaponFactory.CreateSword());



            map = new Map(30, 30);
            map.AddObjectAt(player, 5, 5);
            Zombie lZack = new Zombie(player, map);

            map.AddObjectAt(lZack, 10, 10);

            Room lRoom = new Room(new Coord(8, 8), 5, 5, MapGenObject.Direction.SOUTH);

            lRoom.Construct(map);

            Door d = new Door("door_closed_bmp");

            d.Interaction = new UseDoorPAbility(d);
            map.GetBlockAt(5, 10).AddObject(d);

            ToggleSwitch lSwitch = new ToggleSwitch();

            lSwitch.ConnectedProp = d;
            lSwitch.OnGraphic     = new Sprite("toggle_off");
            lSwitch.OffGraphic    = new Sprite("toggle_on");
            map.AddObjectAt(lSwitch, 7, 7);

            camera = new Camera(player, Game.VISBLE_MAP_WIDTH, Game.VISBLE_MAP_HEIGHT, map);

            Item item = new Item("item_bmp");

            map.GetBlockAt(3, 3).AddObject(item);
        }
Exemplo n.º 4
0
        public void MoveInRandomDirection()
        {
            int lXDiff = rand.Next(-1, 1);
            int lYDiff = rand.Next(-1, 1);

            zombie.Move(iMap.GetBlockAt(zombie.Location.Coordinates[lXDiff, lYDiff]));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Render map centered on focus with line of sight
        /// </summary>
        public void Draw(ZSpriteBatch spriteBatch)
        {
            UpdateLoS();

            // draw map
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    //spriteBatch.Draw(map.GetBlockAt(x, y).Graphic.Texture, new Vector2(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE), Color.White);
                    //player.Location.Coordinates.X + x, y);
                    //Coord coord = new Coord(focus.Location.Coordinates.X + x - Game.VISIBLE_MAP_OFFSET, focus.Location.Coordinates.Y + y - Game.VISIBLE_MAP_OFFSET);
                    Coord coord = this[x, y];
                    int   r     = GameMap.LightMap[x, y].R;
                    if (map.IsInMap(coord) && visiblePositions[x, y])
                    {
                        Texture2D texture = map.GetBlockAt(coord).Graphic.Texture;
                        spriteBatch.Draw(texture,
                                         new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE),
                                         GameMap.LightMap[coord.X, coord.Y]);
                    }
                    else if (map.IsInMap(coord))
                    {
                        Texture2D texture = map.GetBlockAt(coord).Graphic.Texture;
                        spriteBatch.DrawRectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Color.Gray);
                        //spriteBatch.Draw(texture,
                        //                 new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE),
                        //                 Color.White);
                    }
                    else
                    {
                        spriteBatch.Draw(GraphicsDispenser.getTexture("void_bmp"),
                                         new Rectangle(x * Game.MAP_BLOCK_SIZE, y * Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE, Game.MAP_BLOCK_SIZE),
                                         Color.White);
                    }
                }
            }
            this.ResetVision();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Puts zombies everywhere.
        /// </summary>
        /// <param name="numOfZombies">Number of zombies you want put.</param>
        /// <param name="p">The player, needed for zombie AI.</param>
        public static void PutZombiesEverywhere(int numOfZombies, Player p)
        {
            bool   zomPlaced = false;
            Random r         = new Random();

            for (int i = 0; i < Math.Abs(numOfZombies); i++)
            {
                zomPlaced = false;
                while (zomPlaced == false)
                {
                    int x = r.Next(map.Width);
                    int y = r.Next(map.Height);
                    if (map.GetBlockAt(x, y).Passable)
                    {
                        zomPlaced = true;
                        //	map.AddObjectAt(EntityFactory.CreateZombie(p), x, y);
                    }
                }
            }
        }
Exemplo n.º 7
0
        protected void LoadData()
        {
            player = new Player("player_bmp");
            player.AddSkill(new Skill(SkillNames.MEDICAL_SKILL));

            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());
            player.Inventory.Add(ItemFactory.CreateDefaultItem());

            player.Inventory.Add(ItemFactory.CreateBandage(player));
            player.Inventory.Add(ItemFactory.CreateBandage(player));

            Weapon sword2 = WeaponFactory.CreateSword();
            sword2.Name = "OTHER Sword";
            player.Inventory.Add(sword2);
            player.Inventory.Add(WeaponFactory.CreateSword());

            map = new Map(30, 30);
            map.AddObjectAt(player, 5, 5);
            Zombie lZack = new Zombie(player, map);
            map.AddObjectAt(lZack, 10, 10);

            Room lRoom = new Room(new Coord(8, 8), 5, 5, MapGenObject.Direction.SOUTH);
            lRoom.Construct(map);

            Door d = new Door("door_closed_bmp");
            d.Interaction = new UseDoorPAbility(d);
            map.GetBlockAt(5, 10).AddObject(d);

            ToggleSwitch lSwitch = new ToggleSwitch();
            lSwitch.ConnectedProp = d;
            lSwitch.OnGraphic = new Sprite("toggle_off");
            lSwitch.OffGraphic = new Sprite("toggle_on");
            map.AddObjectAt(lSwitch, 7, 7);

            camera = new Camera(player, Game.VISBLE_MAP_WIDTH, Game.VISBLE_MAP_HEIGHT, map);

            Item item = new Item("item_bmp");
            map.GetBlockAt(3, 3).AddObject(item);
        }