aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mundus Build 15-04-2020 No1.exe (renamed from Mundus Build 11-04-2020 No1.exe)bin544768 -> 550400 bytes
-rw-r--r--Mundus/Data/SuperLayers/LI.cs4
-rw-r--r--Mundus/Data/SuperLayers/Sky.cs57
-rw-r--r--Mundus/Icons/Project files/s_sky.xcfbin0 -> 665 bytes
-rw-r--r--Mundus/Icons/Sky/Ground/s_sky.pngbin0 -> 3297 bytes
-rw-r--r--Mundus/Mundus.csproj14
-rw-r--r--Mundus/Service/Crafting/CraftingController.cs4
-rw-r--r--Mundus/Service/GameGenerator.cs4
-rw-r--r--Mundus/Service/Mobs/IMob.cs4
-rw-r--r--Mundus/Service/Mobs/LandMobs/Player.cs14
-rw-r--r--Mundus/Service/Mobs/MobMovement.cs55
-rw-r--r--Mundus/Service/Mobs/MobStatsController.cs7
-rw-r--r--Mundus/Service/Mobs/MobTerraforming.cs38
-rw-r--r--Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs1
-rw-r--r--Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs50
-rw-r--r--Mundus/Service/SuperLayers/HeightController.cs39
-rw-r--r--Mundus/Service/SuperLayers/ImageController.cs30
-rw-r--r--Mundus/Service/SwitchItems.cs3
-rw-r--r--Mundus/Service/Tiles/ItemPresets/GroundPresets.cs (renamed from Mundus/Service/SuperLayers/GroundPresets.cs)6
-rw-r--r--Mundus/Service/Tiles/Items/GroundTile.cs6
-rw-r--r--Mundus/gtk-gui/generated.cs2
-rw-r--r--Mundus/gtk-gui/gui.stetic5
-rw-r--r--Mundus/packages.config4
23 files changed, 271 insertions, 76 deletions
diff --git a/Mundus Build 11-04-2020 No1.exe b/Mundus Build 15-04-2020 No1.exe
index 89d9be9..ab4ad95 100644
--- a/Mundus Build 11-04-2020 No1.exe
+++ b/Mundus Build 15-04-2020 No1.exe
Binary files differ
diff --git a/Mundus/Data/SuperLayers/LI.cs b/Mundus/Data/SuperLayers/LI.cs
index 7f3a063..d112b64 100644
--- a/Mundus/Data/SuperLayers/LI.cs
+++ b/Mundus/Data/SuperLayers/LI.cs
@@ -1,10 +1,12 @@
namespace Mundus.Data.SuperLayers {
public static class LI { //stands for Layer Instances
//add other layers
+ public static Sky Sky { get; private set; }
public static Land Land { get; private set; }
- public static Underground Underground { get; private set;}
+ public static Underground Underground { get; private set; }
public static void CreateInstances() {
+ Sky = new Sky();
Land = new Land();
Underground = new Underground();
}
diff --git a/Mundus/Data/SuperLayers/Sky.cs b/Mundus/Data/SuperLayers/Sky.cs
new file mode 100644
index 0000000..ee408c0
--- /dev/null
+++ b/Mundus/Data/SuperLayers/Sky.cs
@@ -0,0 +1,57 @@
+using System;
+using Mundus.Service.Tiles;
+using Mundus.Service.Tiles.Items;
+
+namespace Mundus.Data.SuperLayers {
+ public class Sky : ISuperLayer {
+ private static MobTile[,] mobLayer;
+ private static Structure[,] structureLayer;
+ private static GroundTile[,] groundLayer;
+
+ public Sky() { }
+
+ public MobTile GetMobLayerTile(int yPos, int xPos) {
+ return mobLayer[yPos, xPos];
+ }
+ public Structure GetStructureLayerTile(int yPos, int xPos) {
+ return structureLayer[yPos, xPos];
+ }
+ public GroundTile GetGroundLayerTile(int yPos, int xPos) {
+ return groundLayer[yPos, xPos];
+ }
+
+ public void SetMobLayer(MobTile[,] mobTiles) {
+ mobLayer = mobTiles;
+ }
+ public void SetMobAtPosition(MobTile tile, int yPos, int xPos) {
+ mobLayer[yPos, xPos] = tile;
+ }
+ public void RemoveMobFromPosition(int yPos, int xPos) {
+ mobLayer[yPos, xPos] = null;
+ }
+
+ public void SetStructureLayer(Structure[,] itemTiles) {
+ structureLayer = itemTiles;
+ }
+ public void SetStructureAtPosition(Structure tile, int yPos, int xPos) {
+ structureLayer[yPos, xPos] = tile;
+ }
+ public void RemoveStructureFromPosition(int yPos, int xPos) {
+ structureLayer[yPos, xPos] = null;
+ }
+
+ public void SetGroundLayer(GroundTile[,] groundTiles) {
+ groundLayer = groundTiles;
+ }
+ public void SetGroundAtPosition(GroundTile tile, int yPos, int xPos) {
+ groundLayer[yPos, xPos] = tile;
+ }
+ public void RemoveGroundFromPosition(int yPos, int xPos) {
+ groundLayer[yPos, xPos] = null;
+ }
+
+ public override string ToString() {
+ return "Sky";
+ }
+ }
+}
diff --git a/Mundus/Icons/Project files/s_sky.xcf b/Mundus/Icons/Project files/s_sky.xcf
new file mode 100644
index 0000000..8d4102f
--- /dev/null
+++ b/Mundus/Icons/Project files/s_sky.xcf
Binary files differ
diff --git a/Mundus/Icons/Sky/Ground/s_sky.png b/Mundus/Icons/Sky/Ground/s_sky.png
new file mode 100644
index 0000000..509356c
--- /dev/null
+++ b/Mundus/Icons/Sky/Ground/s_sky.png
Binary files differ
diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj
index 0686653..3aef682 100644
--- a/Mundus/Mundus.csproj
+++ b/Mundus/Mundus.csproj
@@ -80,6 +80,7 @@
<EmbeddedResource Include="Icons\Land\Tools\rock_pickaxe.png" />
<EmbeddedResource Include="Icons\Land\Tools\rock_axe.png" />
<EmbeddedResource Include="Icons\Land\Tools\rock_shovel.png" />
+ <EmbeddedResource Include="Icons\Sky\Ground\s_sky.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
@@ -113,7 +114,9 @@
<Compile Include="Views\Windows\IGameWindow.cs" />
<Compile Include="Service\Mobs\MobMovement.cs" />
<Compile Include="Data\MapSizes.cs" />
- <Compile Include="Service\SwitchItems.cs" />
+ <Compile Include="Service\SwitchItems.cs">
+ <IncludeInPackage>true</IncludeInPackage>
+ </Compile>
<Compile Include="Service\SuperLayers\ImageController.cs" />
<Compile Include="Service\Calculate.cs" />
<Compile Include="Data\Windows\WI.cs" />
@@ -138,12 +141,15 @@
<Compile Include="Data\Crafting\RI.cs" />
<Compile Include="Service\Tiles\ItemPresets\ToolPresets.cs" />
<Compile Include="Service\Tiles\ItemPresets\MaterialPresets.cs" />
- <Compile Include="Service\SuperLayers\GroundPresets.cs" />
<Compile Include="Data\SuperLayers\Underground.cs" />
<Compile Include="Service\SuperLayers\Generators\LandSuperLayerGenerator.cs" />
<Compile Include="Service\SuperLayers\Generators\UndergroundSuperLayerGenerator.cs" />
<Compile Include="Service\Tiles\ItemPresets\StructurePresets.cs" />
<Compile Include="Service\Tiles\Items\GroundTile.cs" />
+ <Compile Include="Service\Tiles\ItemPresets\GroundPresets.cs" />
+ <Compile Include="Service\SuperLayers\HeightController.cs" />
+ <Compile Include="Data\SuperLayers\Sky.cs" />
+ <Compile Include="Service\SuperLayers\Generators\SkySuperLayerGenerator.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\" />
@@ -167,6 +173,10 @@
<Folder Include="Service\Tiles\ItemPresets\" />
<Folder Include="Icons\Land\Materials\" />
<Folder Include="Service\SuperLayers\Generators\" />
+ <Folder Include="Icons\Sky\Ground\" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Mundus/Service/Crafting/CraftingController.cs b/Mundus/Service/Crafting/CraftingController.cs
index b1ca35c..4e998a1 100644
--- a/Mundus/Service/Crafting/CraftingController.cs
+++ b/Mundus/Service/Crafting/CraftingController.cs
@@ -14,7 +14,7 @@ namespace Mundus.Service.Crafting {
/// </summary>
public static void FindAvalableItems() {
avalableItems = LMI.Player.Inventory.Items.Where(x => x != null)
- //Can't use distinct on non primative types, beause they also hold their memory location info.
+ //Can't use distinct on non primative types, beause they also hold their memory location info (I think).
//This is my way of getting only the "unique" item tiles.
.Select(x => x.stock_id).Distinct().Select(x => LMI.Player.Inventory.Items.Where(y => y != null).First(y => y.stock_id == x))
//For each "unique" item tile (key), get how many there are of it in the player inventory (value)
@@ -39,6 +39,7 @@ namespace Mundus.Service.Crafting {
/// </summary>
/// <param name="itemRecipe">CraftingRecipie of the item that will be crafted</param>
public static void CraftItem(CraftingRecipe itemRecipe) {
+ // Removes all items that are used to craft the result item
foreach (var itemAndCount in itemRecipe.GetRequiredItemsAndCounts()) {
for(int i = 0, removedItems = 0; i < LMI.Player.Inventory.Items.Length && removedItems < itemAndCount.Value; i++) {
if (LMI.Player.Inventory.Items[i] != null) {
@@ -51,6 +52,7 @@ namespace Mundus.Service.Crafting {
}
ItemTile tmp = null;
+ // Adds the result item to the inventory (in the correct type)
if (itemRecipe.ResultItem.GetType() == typeof(Material)) {
tmp = new Material((Material)itemRecipe.ResultItem);
}
diff --git a/Mundus/Service/GameGenerator.cs b/Mundus/Service/GameGenerator.cs
index 7e9313a..ea235b4 100644
--- a/Mundus/Service/GameGenerator.cs
+++ b/Mundus/Service/GameGenerator.cs
@@ -14,8 +14,8 @@ namespace Mundus.Service {
default: throw new ArgumentException( "Map size must be \"small\", \"medium\" or \"large\"" );
}
- //Add the other layers
- LandSuperLayerGenerator.GenerateAllLayers( MapSizes.CurrSize );
+ SkySuperLayerGenerator.GenerateAllLayers(MapSizes.CurrSize);
+ LandSuperLayerGenerator.GenerateAllLayers(MapSizes.CurrSize);
UndergroundSuperLayerGenerator.GenerateAllLayers(MapSizes.CurrSize);
}
diff --git a/Mundus/Service/Mobs/IMob.cs b/Mundus/Service/Mobs/IMob.cs
index 0ff282e..9af9cb5 100644
--- a/Mundus/Service/Mobs/IMob.cs
+++ b/Mundus/Service/Mobs/IMob.cs
@@ -4,9 +4,7 @@ using Mundus.Service.Tiles;
namespace Mundus.Service.Mobs {
public interface IMob {
MobTile Tile { get; }
- ISuperLayer CurrSuperLayer { get; set; }
- ISuperLayer GetLayerUndearneathCurr();
- ISuperLayer GetLayerOnTopOfCurr();
+ ISuperLayer CurrSuperLayer { get; set; }
int XPos { get; set; }
int YPos { get; set; }
int Health { get; set; }
diff --git a/Mundus/Service/Mobs/LandMobs/Player.cs b/Mundus/Service/Mobs/LandMobs/Player.cs
index cb048a1..280a12f 100644
--- a/Mundus/Service/Mobs/LandMobs/Player.cs
+++ b/Mundus/Service/Mobs/LandMobs/Player.cs
@@ -17,20 +17,6 @@ namespace Mundus.Service.Mobs.LandMobs {
this.Tile = tile;
this.Inventory = new Inventory(inventorySize);
this.Health = health;
- }
-
- public ISuperLayer GetLayerUndearneathCurr() {
- if (CurrSuperLayer == LI.Land) {
- return LI.Underground;
- }
- return null;
- }
-
- public ISuperLayer GetLayerOnTopOfCurr() {
- if (CurrSuperLayer == LI.Underground) {
- return LI.Land;
- }
- return null;
}
}
}
diff --git a/Mundus/Service/Mobs/MobMovement.cs b/Mundus/Service/Mobs/MobMovement.cs
index 89ff359..c51bf1e 100644
--- a/Mundus/Service/Mobs/MobMovement.cs
+++ b/Mundus/Service/Mobs/MobMovement.cs
@@ -1,5 +1,6 @@
using Mundus.Data;
using Mundus.Data.Superlayers.Mobs;
+using Mundus.Service.SuperLayers;
namespace Mundus.Service.Mobs {
public static class MobMovement {
@@ -8,40 +9,50 @@ namespace Mundus.Service.Mobs {
}
public static void ChangePosition(IMob mob, int yPos, int xPos, int size) {
- if (yPos >= 0 && xPos >= 0 && yPos < MapSizes.CurrSize && xPos < MapSizes.CurrSize) {
- ChangePosition(mob, yPos, xPos);
+ if (InBoundaries(yPos, xPos)) {
+ if (CanWalkAt(mob, yPos, xPos)) {
+ ChangePosition(mob, yPos, xPos);
+ }
}
}
public static void ChangePosition(IMob mob, int yPos, int xPos) {
- if (Walkable(mob, yPos, xPos)) {
- mob.CurrSuperLayer.RemoveMobFromPosition(mob.YPos, mob.XPos);
-
- if (mob.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) == null &&
- mob.GetLayerUndearneathCurr() != null) {
- mob.CurrSuperLayer = mob.GetLayerUndearneathCurr();
- }
- else if (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) != null) {
- //Mobs can only climb to the superlayer on top of them, if there is a climable structure
- //and there is a "hole" on top of the climable structure
- if (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos).IsClimable &&
- mob.GetLayerOnTopOfCurr() != null &&
- mob.GetLayerOnTopOfCurr().GetGroundLayerTile(yPos, xPos) == null) {
- mob.CurrSuperLayer = mob.GetLayerOnTopOfCurr();
- }
- }
+ mob.CurrSuperLayer.RemoveMobFromPosition(mob.YPos, mob.XPos);
- mob.YPos = yPos;
- mob.XPos = xPos;
- mob.CurrSuperLayer.SetMobAtPosition(mob.Tile, yPos, xPos);
+ if (mob.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) == null) {
+ mob.CurrSuperLayer = HeightController.GetLayerUnderneathMob(mob);
+ }
+ else if (!mob.CurrSuperLayer.GetGroundLayerTile(yPos, xPos).Solid) {
+ mob.CurrSuperLayer = HeightController.GetLayerUnderneathMob(mob);
+ }
+ else if (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) != null) {
+ //Mobs can only climb to the superlayer on top of them, if there is a climable structure
+ //and there is a "hole" on top of the climable structure
+ if (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos).IsClimable &&
+ HeightController.GetLayerAboveMob(mob) != null)
+ {
+ if (HeightController.GetLayerAboveMob(mob).GetGroundLayerTile(yPos, xPos) == null ||
+ !HeightController.GetLayerAboveMob(mob).GetGroundLayerTile(yPos, xPos).Solid)
+ {
+ mob.CurrSuperLayer = HeightController.GetLayerAboveMob(mob);
+ }
+ }
}
+
+ mob.YPos = yPos;
+ mob.XPos = xPos;
+ mob.CurrSuperLayer.SetMobAtPosition(mob.Tile, yPos, xPos);
}
- private static bool Walkable(IMob mob, int yPos, int xPos) {
+ private static bool CanWalkAt(IMob mob, int yPos, int xPos) {
//Mobs can only walk on free ground (no structure on top) or walkable structures
return (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) == null ||
mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos).IsWalkable) ||
mob.CurrSuperLayer.GetMobLayerTile(yPos, xPos) != null;
+ }
+
+ private static bool InBoundaries(int yPos, int xPos) {
+ return yPos >= 0 && xPos >= 0 && yPos < MapSizes.CurrSize && xPos < MapSizes.CurrSize;
}
}
}
diff --git a/Mundus/Service/Mobs/MobStatsController.cs b/Mundus/Service/Mobs/MobStatsController.cs
index 06bac39..4b4af5e 100644
--- a/Mundus/Service/Mobs/MobStatsController.cs
+++ b/Mundus/Service/Mobs/MobStatsController.cs
@@ -1,6 +1,7 @@
using Gtk;
using Mundus.Data;
using Mundus.Data.Superlayers.Mobs;
+using Mundus.Service.SuperLayers;
namespace Mundus.Service.Mobs {
public static class MobStatsController {
@@ -57,10 +58,12 @@ namespace Mundus.Service.Mobs {
}
public static bool ExistsHoleOnTopOfPlayer() {
- if (LMI.Player.GetLayerOnTopOfCurr() == null) {
+ //There can't be a hole if there is nothing above layer
+ if (HeightController.GetLayerAboveMob(LMI.Player) == null) {
return false;
}
- return LMI.Player.GetLayerOnTopOfCurr().GetGroundLayerTile(LMI.Player.YPos, LMI.Player.XPos) == null;
+ return HeightController.GetLayerAboveMob(LMI.Player).GetGroundLayerTile(LMI.Player.YPos, LMI.Player.XPos) == null ||
+ !HeightController.GetLayerAboveMob(LMI.Player).GetGroundLayerTile(LMI.Player.YPos, LMI.Player.XPos).Solid;
}
}
}
diff --git a/Mundus/Service/Mobs/MobTerraforming.cs b/Mundus/Service/Mobs/MobTerraforming.cs
index 0d1ef4e..4805ab0 100644
--- a/Mundus/Service/Mobs/MobTerraforming.cs
+++ b/Mundus/Service/Mobs/MobTerraforming.cs
@@ -2,22 +2,23 @@
using Mundus.Data.Superlayers.Mobs;
using Mundus.Data.SuperLayers;
using Mundus.Data.Tiles;
+using Mundus.Service.SuperLayers;
using Mundus.Service.Tiles.Items;
namespace Mundus.Service.Mobs {
public static class MobTerraforming {
public static void PlayerTerraformAt(int mapYPos, int mapXPos, string inventoryPlace, int inventoryIndex) {
- var selectedType = Inventory.GetPlayerItem(inventoryPlace, inventoryIndex).GetType();
+ var selectedItemType = Inventory.GetPlayerItem(inventoryPlace, inventoryIndex).GetType();
- if (selectedType == typeof(Structure) && PlayerCanBuildStructureAt(mapYPos, mapXPos)) {
+ if (selectedItemType == typeof(Structure) && PlayerCanBuildStructureAt(mapYPos, mapXPos)) {
PlayerBuildStructureAt(mapYPos, mapXPos, inventoryPlace, inventoryIndex);
LMI.Player.Inventory.DeleteItemTile(inventoryPlace, inventoryIndex);
}
- else if (selectedType == typeof(GroundTile) && PlayerCanPlaceGroundAt(mapYPos, mapXPos)) {
+ else if (selectedItemType == typeof(GroundTile) && PlayerCanPlaceGroundAt(mapYPos, mapXPos)) {
PlayerPlaceGroundAt(mapYPos, mapXPos, inventoryPlace, inventoryIndex);
LMI.Player.Inventory.DeleteItemTile(inventoryPlace, inventoryIndex);
}
- else if (selectedType == typeof(Tool) && PlayerCanDestroyAt(mapYPos, mapXPos)) {
+ else if (selectedItemType == typeof(Tool) && PlayerCanDestroyAt(mapYPos, mapXPos)) {
PlayerDestroyAt(mapYPos, mapXPos, inventoryPlace, inventoryIndex);
}
}
@@ -42,12 +43,13 @@ namespace Mundus.Service.Mobs {
private static void PlayerTryDestroyGroundAt(int mapYPos, int mapXPos, Tool shovel) {
var selectedGround = LMI.Player.CurrSuperLayer.GetGroundLayerTile(mapYPos, mapXPos);
-
- if (selectedGround.ReqShovelClass <= shovel.Class) {
+
+ // Grdound tiles that shoud be unbreakable have negative required shovel class
+ if (selectedGround.ReqShovelClass <= shovel.Class && selectedGround.ReqShovelClass >= 0) {
LMI.Player.CurrSuperLayer.SetGroundAtPosition(null, mapYPos, mapXPos);
//When a shovel destroys ground tile, it destroys the structure below (if it is not walkable)
- ISuperLayer under = LMI.Player.GetLayerUndearneathCurr();
+ ISuperLayer under = HeightController.GetLayerUnderneathMob(LMI.Player);
if (under != null && under.GetStructureLayerTile(mapYPos, mapXPos) != null) {
if (!under.GetStructureLayerTile(mapYPos, mapXPos).IsWalkable) {
under.RemoveStructureFromPosition(mapYPos, mapXPos);
@@ -65,8 +67,12 @@ namespace Mundus.Service.Mobs {
if (selStructure.ReqToolType == tool.Type && selStructure.ReqToolClass <= tool.Class) {
int damagePoints = 1 + (tool.Class - selStructure.ReqToolClass);
-
- if (selStructure.GetDrop() != selStructure) {
+
+ // Some structures have a "drop", a specific item that they give upon being damaged.
+ // Other structures drop themselves (you "pick up" the structure after breaking it).
+ if (selStructure.GetDrop() != selStructure) {
+ // The amount of dropped items it adds to inventory is that of the damage points.
+ // If the structure will "die" (health <= 0) before giving all items, it stops giving items.
for (int i = 0; i < damagePoints && i < selStructure.Health && LMI.Player.Inventory.Items.Contains(null); i++) {
LMI.Player.Inventory.AppendToItems(new Material((Material)selStructure.GetDrop()));
}
@@ -74,7 +80,8 @@ namespace Mundus.Service.Mobs {
else if (LMI.Player.Inventory.Items.Contains(null)) {
LMI.Player.Inventory.AppendToItems((Structure)selStructure.GetDrop());
}
-
+
+ // Damage to the structure is done after adding the dropped item/items.
if (!selStructure.Damage(damagePoints)) {
LMI.Player.CurrSuperLayer.SetStructureAtPosition(null, mapYPos, mapXPos);
}
@@ -101,11 +108,12 @@ namespace Mundus.Service.Mobs {
private static void PlayerBuildStructureAt(int yPos, int xPos, string inventoryPlace, int inventoryIndex) {
Structure toBuild = (Structure)LMI.Player.Inventory.GetItemTile(inventoryPlace, inventoryIndex);
- //Climable structures will be placed under a hole (if they can be)
- if (toBuild.IsClimable && LMI.Player.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) == null
- && LMI.Player.GetLayerUndearneathCurr().GetStructureLayerTile(yPos, xPos) == null) {
-
- LMI.Player.GetLayerUndearneathCurr().SetStructureAtPosition(toBuild, yPos, xPos);
+ // Climable structures will be placed under a hole (if they can be).
+ // Non climable structures won't be placed anywhere if there is a hole.
+ if (toBuild.IsClimable && LMI.Player.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) == null &&
+ HeightController.GetLayerUnderneathMob(LMI.Player).GetStructureLayerTile(yPos, xPos) == null)
+ {
+ HeightController.GetLayerUnderneathMob(LMI.Player).SetStructureAtPosition(toBuild, yPos, xPos);
}
else if (LMI.Player.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) != null) {
LMI.Player.CurrSuperLayer.SetStructureAtPosition(toBuild, yPos, xPos);
diff --git a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
index 461f20a..1788fe8 100644
--- a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
+++ b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
@@ -1,7 +1,6 @@
using System;
using Mundus.Data.Superlayers.Mobs;
using Mundus.Data.SuperLayers;
-using Mundus.Data.Tiles;
using Mundus.Service.Tiles;
using Mundus.Service.Tiles.ItemPresets;
using Mundus.Service.Tiles.Items;
diff --git a/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs
new file mode 100644
index 0000000..37a9978
--- /dev/null
+++ b/Mundus/Service/SuperLayers/Generators/SkySuperLayerGenerator.cs
@@ -0,0 +1,50 @@
+using System;
+using Mundus.Data.SuperLayers;
+using Mundus.Service.Tiles;
+using Mundus.Service.Tiles.ItemPresets;
+using Mundus.Service.Tiles.Items;
+
+namespace Mundus.Service.SuperLayers.Generators {
+ public static class SkySuperLayerGenerator {
+ private static Random rnd;
+
+ public static void GenerateAllLayers(int size) {
+ rnd = new Random();
+
+ LI.Sky.SetMobLayer(GenerateMobLayer(size));
+ LI.Sky.SetGroundLayer(GenerateGroundLayer(size));
+ LI.Sky.SetStructureLayer(GenerateStructureLayer(size));
+ }
+
+ private static MobTile[,] GenerateMobLayer(int size) {
+ MobTile[,] tiles = new MobTile[size, size];
+
+ for (int col = 0; col < size; col++) {
+ for (int row = 0; row < size; row++) {
+ }
+ }
+ return tiles;
+ }
+
+ private static GroundTile[,] GenerateGroundLayer(int size) {
+ GroundTile[,] tiles = new GroundTile[size, size];
+
+ for (int col = 0; col < size; col++) {
+ for (int row = 0; row < size; row++) {
+ tiles[col, row] = GroundPresets.GetASSky();
+ }
+ }
+ return tiles;
+ }
+
+ private static Structure[,] GenerateStructureLayer(int size) {
+ Structure[,] tiles = new Structure[size, size];
+
+ for (int col = 0; col < size; col++) {
+ for (int row = 0; row < size; row++) {
+ }
+ }
+ return tiles;
+ }
+ }
+}
diff --git a/Mundus/Service/SuperLayers/HeightController.cs b/Mundus/Service/SuperLayers/HeightController.cs
new file mode 100644
index 0000000..9d216f5
--- /dev/null
+++ b/Mundus/Service/SuperLayers/HeightController.cs
@@ -0,0 +1,39 @@
+using System;
+using Mundus.Data.SuperLayers;
+using Mundus.Service.Mobs;
+
+namespace Mundus.Service.SuperLayers {
+ public static class HeightController {
+ private static ISuperLayer sky = LI.Sky;
+ private static ISuperLayer land = LI.Land;
+ private static ISuperLayer underground = LI.Underground;
+
+ public static ISuperLayer GetLayerUnderneath(ISuperLayer currentLayer) {
+ if (land == currentLayer) {
+ return underground;
+ }
+ if (sky == currentLayer) {
+ return land;
+ }
+ return null;
+ }
+
+ public static ISuperLayer GetLayerUnderneathMob(IMob currentMob) {
+ return GetLayerUnderneath(currentMob.CurrSuperLayer);
+ }
+
+ public static ISuperLayer GetLayerAbove(ISuperLayer currentLayer) {
+ if (underground == currentLayer) {
+ return land;
+ }
+ if (land == currentLayer) {
+ return sky;
+ }
+ return null;
+ }
+
+ public static ISuperLayer GetLayerAboveMob(IMob currentMob) {
+ return GetLayerAbove(currentMob.CurrSuperLayer);
+ }
+ }
+}
diff --git a/Mundus/Service/SuperLayers/ImageController.cs b/Mundus/Service/SuperLayers/ImageController.cs
index b1f3d7a..b939291 100644
--- a/Mundus/Service/SuperLayers/ImageController.cs
+++ b/Mundus/Service/SuperLayers/ImageController.cs
@@ -13,15 +13,18 @@ namespace Mundus.Service.SuperLayers {
Image img = null;
//Layer 0 is GroundLayer, 1 is ItemLayer and 2 is Moblayer
- if (layer == 0) {
+ if (layer == 0)
+ {
img = new Image(GetGroundImage(row, col).Stock, IconSize.Dnd);
}
else if (layer == 1 &&
- superLayer.GetStructureLayerTile( row, col ) != null) {
+ superLayer.GetStructureLayerTile( row, col ) != null)
+ {
img = new Image(GetStructureImage(row, col).Stock, IconSize.Dnd );
}
else if (layer == 2 &&
- superLayer.GetMobLayerTile( row, col ) != null) {
+ superLayer.GetMobLayerTile( row, col ) != null)
+ {
img = new Image(superLayer.GetMobLayerTile( row, col ).stock_id, IconSize.Dnd);
}
return img;
@@ -39,24 +42,29 @@ namespace Mundus.Service.SuperLayers {
return img;
}
- //Return a tile if it exists, otherwise return the "blank" icon
public static Image GetStructureImage(int row, int col) {
ISuperLayer superLayer = LMI.Player.CurrSuperLayer;
Image img = new Image("blank", IconSize.Dnd );
- if (row >= 0 && col >= 0 && col < MapSizes.CurrSize && row < MapSizes.CurrSize &&
- superLayer.GetStructureLayerTile( row, col ) != null) {
- img = superLayer.GetStructureLayerTile( row, col ).Texture;
+ if (IsInsideBoundaries(row, col) &&
+ superLayer.GetStructureLayerTile(row, col) != null)
+ {
+ img = superLayer.GetStructureLayerTile(row, col).Texture;
}
return img;
}
+ private static bool IsInsideBoundaries(int row, int col) {
+ return row >= 0 && col >= 0 && col < MapSizes.CurrSize && row < MapSizes.CurrSize;
+ }
+
public static Image GetHotbarImage(int index) {
Image img = new Image("blank", IconSize.Dnd);
if (index < LMI.Player.Inventory.Hotbar.Length) {
if (LMI.Player.Inventory.Hotbar[index] != null) {
- //Structures have two icons, one when they are placed and one as an inventory item
+ // Structures have two icons, one when they are placed and one as an inventory item.
+ // All other item types have only one icon (texture).
if (LMI.Player.Inventory.Hotbar[index].GetType() == typeof(Structure)) {
Structure tmp = (Structure)LMI.Player.Inventory.Hotbar[index];
img = new Image(tmp.inventory_stock_id, IconSize.Dnd);
@@ -71,9 +79,11 @@ namespace Mundus.Service.SuperLayers {
public static Image GetInventoryItemImage(int index) {
Image img = new Image("blank", IconSize.Dnd);
+
if (index < LMI.Player.Inventory.Items.Length) {
if (LMI.Player.Inventory.Items[index] != null) {
- //Structures have two icons, one when they are placed and one as an inventory item
+ // Structures have two icons, one when they are placed and one as an inventory item.
+ // All other item types have only one icon (texture).
if (LMI.Player.Inventory.Items[index].GetType() == typeof(Structure)) {
Structure tmp = (Structure)LMI.Player.Inventory.Items[index];
img = new Image(tmp.inventory_stock_id, IconSize.Dnd);
@@ -88,6 +98,7 @@ namespace Mundus.Service.SuperLayers {
public static Image GetAccessoryImage(int index) {
Image img = new Image("blank_gear", IconSize.Dnd);
+
if (index < LMI.Player.Inventory.Accessories.Length) {
if (LMI.Player.Inventory.Accessories[index] != null) {
img = LMI.Player.Inventory.Accessories[index].Texture;
@@ -98,6 +109,7 @@ namespace Mundus.Service.SuperLayers {
public static Image GetGearImage(int index) {
Image img = new Image("blank_gear", IconSize.Dnd);
+
if (index < LMI.Player.Inventory.Gear.Length) {
if (LMI.Player.Inventory.Gear[index] != null) {
img = LMI.Player.Inventory.Gear[index].Texture;
diff --git a/Mundus/Service/SwitchItems.cs b/Mundus/Service/SwitchItems.cs
index 90a0794..1efa01b 100644
--- a/Mundus/Service/SwitchItems.cs
+++ b/Mundus/Service/SwitchItems.cs
@@ -38,7 +38,8 @@ namespace Mundus.Service {
var toTransfer = origin[oIndex];
- if (toTransfer != null) {
+ if (toTransfer != null) {
+ // Certain item types can only be placed inside certain inventory places.
if (((toTransfer.GetType() == typeof(Tool) || toTransfer.GetType() == typeof(GroundTile)) && (destination == "hotbar" || destination == "items")) ||
((toTransfer.GetType() == typeof(Material) || toTransfer.GetType() == typeof(Structure)) && (destination == "hotbar" || destination == "items")) ||
(toTransfer.GetType() == typeof(Gear) && (destination == "hotbar" || destination == "items" || destination == "accessories" || destination == "gear"))) {
diff --git a/Mundus/Service/SuperLayers/GroundPresets.cs b/Mundus/Service/Tiles/ItemPresets/GroundPresets.cs
index d2f748f..2f349df 100644
--- a/Mundus/Service/SuperLayers/GroundPresets.cs
+++ b/Mundus/Service/Tiles/ItemPresets/GroundPresets.cs
@@ -2,8 +2,12 @@
using Mundus.Service.Tiles.Items;
using Mundus.Service.Tiles.ItemPresets;
-namespace Mundus.Service.SuperLayers {
+namespace Mundus.Service.Tiles.ItemPresets {
public static class GroundPresets {
+ public static GroundTile GetASSky() {
+ return new GroundTile("S_sky", -1, false);
+ }
+
/// <summary>
/// Returns a new instance of the grass ground tile
/// </summary>
diff --git a/Mundus/Service/Tiles/Items/GroundTile.cs b/Mundus/Service/Tiles/Items/GroundTile.cs
index 3b1b846..4b5eea2 100644
--- a/Mundus/Service/Tiles/Items/GroundTile.cs
+++ b/Mundus/Service/Tiles/Items/GroundTile.cs
@@ -4,12 +4,14 @@ using Mundus.Data.Tiles;
namespace Mundus.Service.Tiles.Items {
public class GroundTile : ItemTile {
public int ReqShovelClass { get; private set; }
+ public bool Solid { get; private set; }
- public GroundTile(GroundTile groundTile) :this(groundTile.stock_id, groundTile.ReqShovelClass)
+ public GroundTile(GroundTile groundTile) :this(groundTile.stock_id, groundTile.ReqShovelClass, groundTile.Solid)
{ }
- public GroundTile(string stock_id, int reqShovelClass) :base(stock_id) {
+ public GroundTile(string stock_id, int reqShovelClass, bool solid = true) :base(stock_id) {
this.ReqShovelClass = reqShovelClass;
+ this.Solid = solid;
}
public override string ToString() {
diff --git a/Mundus/gtk-gui/generated.cs b/Mundus/gtk-gui/generated.cs
index d196d4b..ba06be5 100644
--- a/Mundus/gtk-gui/generated.cs
+++ b/Mundus/gtk-gui/generated.cs
@@ -70,6 +70,8 @@ namespace Stetic
w1.Add("L_wooden_ladder_inventory", w29);
global::Gtk.IconSet w30 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Underground.Materials.U_stone.png"));
w1.Add("U_stone", w30);
+ global::Gtk.IconSet w31 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Sky.Ground.s_sky.png"));
+ w1.Add("S_sky", w31);
w1.AddDefault();
}
}
diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic
index ded0fd0..f9bceff 100644
--- a/Mundus/gtk-gui/gui.stetic
+++ b/Mundus/gtk-gui/gui.stetic
@@ -152,6 +152,11 @@
<property name="Image">resource:Mundus.Icons.Underground.Materials.U_stone.png</property>
</source>
</icon-set>
+ <icon-set id="S_sky">
+ <source>
+ <property name="Image">resource:Mundus.Icons.Sky.Ground.s_sky.png</property>
+ </source>
+ </icon-set>
</icon-factory>
<widget class="Gtk.Window" id="Mundus.Views.Windows.NewGameWindow" design-size="581 275">
<property name="MemberName" />
diff --git a/Mundus/packages.config b/Mundus/packages.config
new file mode 100644
index 0000000..cc1fbe7
--- /dev/null
+++ b/Mundus/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="StyleCop.Analyzers" version="1.1.118" targetFramework="net47" developmentDependency="true" />
+</packages> \ No newline at end of file