Ejemplo n.º 1
0
 public Stockpile(Faction faction, IEnumerable<Voxel> voxels, RoomData data, ChunkManager chunks)
     : base(voxels, data, chunks)
 {
     Boxes = new List<Body>();
     faction.Stockpiles.Add(this);
     Faction = faction;
 }
Ejemplo n.º 2
0
 public Room(bool designation, IEnumerable<Voxel> designations, RoomData data, ChunkManager chunks)
     : base(data.Name + " " + Counter, chunks)
 {
     RoomData = data;
     ReplacementType = VoxelLibrary.GetVoxelType(RoomData.FloorType);
     Chunks = chunks;
     Counter++;
     Designations = designations.ToList();
     IsBuilt = false;
 }
Ejemplo n.º 3
0
        public Room(IEnumerable<Voxel> voxels, RoomData data, ChunkManager chunks)
            : base(data.Name + " " + Counter, chunks)
        {
            RoomData = data;
            ReplacementType = VoxelLibrary.GetVoxelType(RoomData.FloorType);
            Chunks = chunks;

            Designations = new List<Voxel>();
            Counter++;

            IsBuilt = true;
            foreach (Voxel voxel in voxels)
            {
                AddVoxel(voxel);
            }
        }
Ejemplo n.º 4
0
 private static Room _factory(RoomData Data, Faction Faction, WorldManager World)
 {
     return(new BalloonPort(Data, Faction, World));
 }
Ejemplo n.º 5
0
 private static Room _factory(RoomData Data, Faction Faction, WorldManager World)
 {
     return(new Treasury(Data, Faction, World));
 }
Ejemplo n.º 6
0
 public Farm(IEnumerable<Voxel> voxels, RoomData data, ChunkManager chunks)
     : base(voxels, data, chunks)
 {
 }
Ejemplo n.º 7
0
 public Farm(bool designation, IEnumerable<Voxel> designations, RoomData data, ChunkManager chunks)
     : base(designation, designations, data, chunks)
 {
 }
Ejemplo n.º 8
0
 public Stockpile(Faction faction, bool designation, IEnumerable <Voxel> designations, RoomData data, WorldManager world) :
     base(designation, designations, data, world)
 {
     Boxes = new List <Body>();
     faction.Stockpiles.Add(this);
     Faction = faction;
 }
Ejemplo n.º 9
0
 public static void RegisterType(RoomData t)
 {
     roomTypes[t.Name] = t;
 }
Ejemplo n.º 10
0
 public Farm(bool designation, IEnumerable <Voxel> designations, RoomData data, ChunkManager chunks) :
     base(designation, designations, data, chunks)
 {
 }
Ejemplo n.º 11
0
        public void SetupBuildRoomTab()
        {
            BuildRoomTab = new BuildTab()
            {
                Tab = Selector.AddTab("Rooms")
            };

            CreateBuildTab(BuildRoomTab, BuildType.Room);
            BuildRoomTab.BuildButton.OnClicked += BuildRoomButton_OnClicked;
            List <string> roomTypes = RoomLibrary.GetRoomTypes().ToList();

            int        numRooms   = roomTypes.Count();
            int        numColumns = 1;
            GridLayout layout     = new GridLayout(GUI, BuildRoomTab.Scroller, numRooms, numColumns)
            {
                LocalBounds    = new Rectangle(0, 0, 720, 40 * numRooms),
                EdgePadding    = 0,
                WidthSizeMode  = SizeMode.Fit,
                HeightSizeMode = SizeMode.Fixed
            };

            int i = 0;

            foreach (string roomType in roomTypes)
            {
                RoomData room = RoomLibrary.GetData(roomType);

                GridLayout roomLayout = new GridLayout(GUI, layout, 1, 3)
                {
                    WidthSizeMode  = SizeMode.Fixed,
                    HeightSizeMode = SizeMode.Fixed,
                    EdgePadding    = 0
                };

                if (i == 0)
                {
                    RoomTabOnClicked(room);
                }

                roomLayout.OnClicked += () => RoomTabOnClicked(room);
                int i1 = i;
                roomLayout.OnHover += () => HoverItem(layout, i1);

                layout.SetComponentPosition(roomLayout, 0, i, 1, 1);

                ImagePanel icon = new ImagePanel(GUI, roomLayout, room.Icon)
                {
                    KeepAspectRatio = true,
                    MinWidth        = 32,
                    MinHeight       = 32
                };
                roomLayout.SetComponentPosition(icon, 0, 0, 1, 1);

                Label description = new Label(GUI, roomLayout, room.Name, GUI.SmallFont)
                {
                    ToolTip = room.Description
                };
                roomLayout.SetComponentPosition(description, 1, 0, 1, 1);
                i++;
            }
            layout.UpdateSizes();
        }
Ejemplo n.º 12
0
 public Stockpile(Faction faction, bool designation, IEnumerable <VoxelHandle> designations, RoomData data, WorldManager world) :
     base(designation, designations, data, world, faction)
 {
     Boxes = new List <Body>();
     faction.Stockpiles.Add(this);
     Faction            = faction;
     BlacklistResources = new List <Resource.ResourceTags>()
     {
         Resource.ResourceTags.Corpse,
         Resource.ResourceTags.Money
     };
 }
Ejemplo n.º 13
0
        public static List <Body> GenerateRoomComponentsTemplate(
            RoomData roomData,
            List <VoxelHandle> voxels,
            ComponentManager componentManager,
            Microsoft.Xna.Framework.Content.ContentManager content,
            GraphicsDevice graphics)
        {
            List <Body> components = new List <Body>();

            RoomTile[,] currentTiles = RoomTemplate.CreateFromRoom(
                voxels, componentManager.World.ChunkManager);
            float[,] rotations = new float[currentTiles.GetLength(0), currentTiles.GetLength(1)];
            foreach (RoomTemplate myTemp in roomData.Templates)
            {
                RoomTemplate template = new RoomTemplate(myTemp)
                {
                    Rotation = 0
                };
                for (int r = -2; r < currentTiles.GetLength(0) + 1; r++)
                {
                    for (int c = -2; c < currentTiles.GetLength(1) + 1; c++)
                    {
                        for (int rotation = 0; rotation < 5; rotation++)
                        {
                            template.PlaceTemplate(ref currentTiles, ref rotations, r, c);
                            template.RotateClockwise(1);
                        }
                    }
                }
            }

            var box        = VoxelHelpers.GetVoxelBoundingBox(voxels);
            int thingsMade = 0;

            for (int r = 0; r < currentTiles.GetLength(0); r++)
            {
                for (int c = 0; c < currentTiles.GetLength(1); c++)
                {
                    RoomTile tile             = currentTiles[r, c];
                    Body     createdComponent = null;
                    Vector3  noise            =
                        VertexNoise.GetNoiseVectorFromRepeatingTexture(box.Min +
                                                                       new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1));
                    switch (tile)
                    {
                    case RoomTile.Barrel:
                        createdComponent = EntityFactory.CreateEntity <Body>("Barrel", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Wheat:
                        createdComponent = EntityFactory.CreateEntity <Body>("Wheat", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Mushroom:
                        createdComponent = EntityFactory.CreateEntity <Body>("Mushroom", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Table:
                        createdComponent = EntityFactory.CreateEntity <Body>("Table", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Stove:
                        createdComponent = EntityFactory.CreateEntity <Body>("Stove", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.KitchenTable:
                        createdComponent = EntityFactory.CreateEntity <Body>("Kitchen Table", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Lamp:
                        createdComponent = EntityFactory.CreateEntity <Body>("Lamp", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Flag:
                        createdComponent = EntityFactory.CreateEntity <Body>("Flag", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Chair:
                        createdComponent = EntityFactory.CreateEntity <Body>("Chair", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Books:
                        createdComponent = EntityFactory.CreateEntity <Body>(MathFunctions.RandEvent(0.5f) ? "Books" : "Potions", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Anvil:
                        createdComponent = EntityFactory.CreateEntity <Body>("Anvil", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Forge:
                        createdComponent = EntityFactory.CreateEntity <Body>("Forge", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Target:
                        createdComponent = EntityFactory.CreateEntity <Body>("Target", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Strawman:
                        createdComponent = EntityFactory.CreateEntity <Body>("Strawman", box.Min + new Vector3(r + 0.5f - 1, 1.5f, c + 0.5f - 1) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.BookShelf:
                        createdComponent = EntityFactory.CreateEntity <Body>("Bookshelf", box.Min + new Vector3(r - 1 + 0.5f, 1.5f, c - 1 + 0.5f) + noise);
                        thingsMade++;
                        break;

                    case RoomTile.Pillow:

                        for (int dx = -1; dx < 2; dx++)
                        {
                            for (int dy = -1; dy < 2; dy++)
                            {
                                if (Math.Abs(dx) + Math.Abs(dy) != 1 || r + dx < 0 || r + dx >= currentTiles.GetLength(0) || c + dy < 0 || c + dy >= currentTiles.GetLength(1))
                                {
                                    continue;
                                }

                                if (currentTiles[r + dx, c + dy] != RoomTile.Bed)
                                {
                                    continue;
                                }

                                createdComponent = EntityFactory.CreateEntity <Body>("Bed", box.Min + new Vector3(r - 1 + 0.5f, 1.5f, c - 1 + 0.5f) + noise);
                                break;
                            }
                        }


                        thingsMade++;
                        break;

                    default:
                        break;
                    }

                    if (createdComponent == null)
                    {
                        continue;
                    }
                    createdComponent.Tags.Add("Moveable");
                    createdComponent.LocalTransform = Matrix.CreateRotationY(-(rotations[r, c] + (float)Math.PI * 0.5f)) * createdComponent.LocalTransform;
                    components.Add(createdComponent);
                }
            }
            return(components);
        }
Ejemplo n.º 14
0
        public void RoomTabOnClicked(RoomData room)
        {
            SelectedRoom = room;

            BuildRoomTab.InfoTitle.Text = room.Name;
            BuildRoomTab.InfoImage.Image = room.Icon;
            BuildRoomTab.InfoDescription.Text = room.Description;

            BuildRoomTab.BuildButton.IsVisible = true;
            string additional = "";

            if (!room.CanBuildAboveGround)
            {
                additional += "\n* Must be built below ground.";
            }

            if (!room.CanBuildBelowGround)
            {
                additional += "\n* Must be built above ground.";
            }

            if (room.MustBeBuiltOnSoil)
            {
                additional += "\n* Must be built on soil.";
            }

            BuildRoomTab.InfoDescription.Text += additional;

            string requirementsText = "Requires (per 4 tiles):\n";

            foreach (KeyValuePair<ResourceLibrary.ResourceType, ResourceAmount> pair in room.RequiredResources)
            {
                requirementsText += pair.Key + ": " + pair.Value.NumResources + "\n";
            }

            if (room.RequiredResources.Count == 0)
            {
                requirementsText += "Nothing";
            }

            BuildRoomTab.InfoRequirements.Text = requirementsText;
        }
Ejemplo n.º 15
0
 private static Room _factory(RoomData Data, Faction Faction, WorldManager World)
 {
     return(new Graveyard(Data, Faction, World));
 }
Ejemplo n.º 16
0
 private BalloonPort(RoomData Data, Faction Faction, WorldManager World) :
     base(Data, Faction, World)
 {
 }
Ejemplo n.º 17
0
 public static void RegisterType(RoomData t)
 {
     roomTypes[t.Name] = t;
 }
Ejemplo n.º 18
0
 public Farm(IEnumerable <Voxel> voxels, RoomData data, ChunkManager chunks) :
     base(voxels, data, chunks)
 {
 }
Ejemplo n.º 19
0
 private static Room _factory(RoomData Data, Faction Faction, WorldManager World)
 {
     return(new Stockpile(Data, Faction, World));
 }
Ejemplo n.º 20
0
 public Treasury(Faction faction, bool designation, IEnumerable <VoxelHandle> designations, RoomData data, WorldManager world) :
     base(designation, designations, data, world, faction)
 {
     Coins = new List <Body>();
     Money = 0;
     faction.Treasurys.Add(this);
     Faction = faction;
 }