aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mundus/Data/Crafting/RI.cs14
-rw-r--r--Mundus/Icons/Land/Materials/land_rock.pngbin0 -> 4339 bytes
-rw-r--r--Mundus/Icons/Land/Materials/stick.pngbin0 -> 4339 bytes
-rw-r--r--Mundus/Icons/Land/Tools/stone_pickaxe.pngbin0 -> 4339 bytes
-rw-r--r--Mundus/Icons/Materials/land_rock.pngbin4339 -> 0 bytes
-rw-r--r--Mundus/Icons/Materials/stick.pngbin4339 -> 0 bytes
-rw-r--r--Mundus/Icons/Project files/blank_gear.xcfbin2700 -> 2700 bytes
-rw-r--r--Mundus/Icons/Project files/blank_hand.xcfbin1734 -> 1616 bytes
-rw-r--r--Mundus/Icons/Project files/land_rock.xcfbin3070 -> 2952 bytes
-rw-r--r--Mundus/Icons/Project files/stick.xcfbin2005 -> 1887 bytes
-rw-r--r--Mundus/Icons/Project files/stone_pickaxe.xcfbin0 -> 3028 bytes
-rw-r--r--Mundus/Icons/UI/Blanks/blank_gear.pngbin4339 -> 4339 bytes
-rw-r--r--Mundus/Icons/UI/Blanks/blank_hand.pngbin4339 -> 4339 bytes
-rw-r--r--Mundus/Mundus.csproj8
-rw-r--r--Mundus/Program.cs2
-rw-r--r--Mundus/Service/Calculate.cs3
-rw-r--r--Mundus/Service/Crafting/CraftingController.cs47
-rw-r--r--Mundus/Service/Crafting/CraftingRecipe.cs118
-rw-r--r--Mundus/Service/Crafting/CraftingRecipie.cs53
-rw-r--r--Mundus/Service/SuperLayers/LandPresets.cs9
-rw-r--r--Mundus/Service/SuperLayers/LandSuperLayerGenerator.cs4
-rw-r--r--Mundus/Service/Tiles/ItemPresets/MaterialPresets.cs14
-rw-r--r--Mundus/Service/Tiles/ItemPresets/ToolPresets.cs7
-rw-r--r--Mundus/Service/Tiles/Items/Gear.cs3
-rw-r--r--Mundus/Service/Tiles/Items/ItemTile.cs3
-rw-r--r--Mundus/Service/Tiles/Items/Material.cs2
-rw-r--r--Mundus/Service/Tiles/Items/Structure.cs2
-rw-r--r--Mundus/Service/Tiles/Items/Tool.cs3
-rw-r--r--Mundus/Service/WindowController.cs1
-rw-r--r--Mundus/Views/Windows/CraftingWindow.cs86
-rw-r--r--Mundus/gtk-gui/Mundus.Views.Windows.CraftingWindow.cs64
-rw-r--r--Mundus/gtk-gui/generated.cs6
-rw-r--r--Mundus/gtk-gui/gui.stetic49
33 files changed, 369 insertions, 129 deletions
diff --git a/Mundus/Data/Crafting/RI.cs b/Mundus/Data/Crafting/RI.cs
index 8c15b32..c0af046 100644
--- a/Mundus/Data/Crafting/RI.cs
+++ b/Mundus/Data/Crafting/RI.cs
@@ -1,13 +1,21 @@
using System;
+using System.Collections.Generic;
+using Mundus.Data.Tiles;
using Mundus.Service.Crafting;
+using Mundus.Service.Tiles.ItemPresets;
using Mundus.Service.Tiles.Items;
namespace Mundus.Data.Crafting {
- public static class RI { //short for Recipie Instances
- public static CraftingRecipie StoneAxe { get; private set; }
+ public static class RI { //short for Recipe Instances
+ public static List<CraftingRecipe> AllRecipies { get; private set; }
+
+ public static CraftingRecipe StonePickAxe { get; private set; }
public static void CreateInstances() {
- StoneAxe = new CraftingRecipie(new Tool());
+ AllRecipies = new List<CraftingRecipe>();
+
+ StonePickAxe = new CraftingRecipe(ToolPresets.GetAStonePickaxe(), 2, MaterialPresets.GetALandRock(), 2, MaterialPresets.GetAStick());
+ AllRecipies.Add(StonePickAxe);
}
}
}
diff --git a/Mundus/Icons/Land/Materials/land_rock.png b/Mundus/Icons/Land/Materials/land_rock.png
new file mode 100644
index 0000000..835c242
--- /dev/null
+++ b/Mundus/Icons/Land/Materials/land_rock.png
Binary files differ
diff --git a/Mundus/Icons/Land/Materials/stick.png b/Mundus/Icons/Land/Materials/stick.png
new file mode 100644
index 0000000..288a5ce
--- /dev/null
+++ b/Mundus/Icons/Land/Materials/stick.png
Binary files differ
diff --git a/Mundus/Icons/Land/Tools/stone_pickaxe.png b/Mundus/Icons/Land/Tools/stone_pickaxe.png
new file mode 100644
index 0000000..0f17039
--- /dev/null
+++ b/Mundus/Icons/Land/Tools/stone_pickaxe.png
Binary files differ
diff --git a/Mundus/Icons/Materials/land_rock.png b/Mundus/Icons/Materials/land_rock.png
deleted file mode 100644
index 87c5096..0000000
--- a/Mundus/Icons/Materials/land_rock.png
+++ /dev/null
Binary files differ
diff --git a/Mundus/Icons/Materials/stick.png b/Mundus/Icons/Materials/stick.png
deleted file mode 100644
index b6ee812..0000000
--- a/Mundus/Icons/Materials/stick.png
+++ /dev/null
Binary files differ
diff --git a/Mundus/Icons/Project files/blank_gear.xcf b/Mundus/Icons/Project files/blank_gear.xcf
index 9aae9cf..1269dc8 100644
--- a/Mundus/Icons/Project files/blank_gear.xcf
+++ b/Mundus/Icons/Project files/blank_gear.xcf
Binary files differ
diff --git a/Mundus/Icons/Project files/blank_hand.xcf b/Mundus/Icons/Project files/blank_hand.xcf
index b55e803..f972876 100644
--- a/Mundus/Icons/Project files/blank_hand.xcf
+++ b/Mundus/Icons/Project files/blank_hand.xcf
Binary files differ
diff --git a/Mundus/Icons/Project files/land_rock.xcf b/Mundus/Icons/Project files/land_rock.xcf
index 96786fa..71f3815 100644
--- a/Mundus/Icons/Project files/land_rock.xcf
+++ b/Mundus/Icons/Project files/land_rock.xcf
Binary files differ
diff --git a/Mundus/Icons/Project files/stick.xcf b/Mundus/Icons/Project files/stick.xcf
index 6f90c39..b4b56ff 100644
--- a/Mundus/Icons/Project files/stick.xcf
+++ b/Mundus/Icons/Project files/stick.xcf
Binary files differ
diff --git a/Mundus/Icons/Project files/stone_pickaxe.xcf b/Mundus/Icons/Project files/stone_pickaxe.xcf
new file mode 100644
index 0000000..a23d5d1
--- /dev/null
+++ b/Mundus/Icons/Project files/stone_pickaxe.xcf
Binary files differ
diff --git a/Mundus/Icons/UI/Blanks/blank_gear.png b/Mundus/Icons/UI/Blanks/blank_gear.png
index 3d369a7..5f27004 100644
--- a/Mundus/Icons/UI/Blanks/blank_gear.png
+++ b/Mundus/Icons/UI/Blanks/blank_gear.png
Binary files differ
diff --git a/Mundus/Icons/UI/Blanks/blank_hand.png b/Mundus/Icons/UI/Blanks/blank_hand.png
index 3c41e07..e6bd2d3 100644
--- a/Mundus/Icons/UI/Blanks/blank_hand.png
+++ b/Mundus/Icons/UI/Blanks/blank_hand.png
Binary files differ
diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj
index dccc280..0b3a8a8 100644
--- a/Mundus/Mundus.csproj
+++ b/Mundus/Mundus.csproj
@@ -55,7 +55,6 @@
<EmbeddedResource Include="Icons\Land\Ground\grass.png" />
<EmbeddedResource Include="Icons\Land\Items\boulder.png" />
<EmbeddedResource Include="Icons\player.png" />
- <EmbeddedResource Include="Icons\Materials\land_rock.png" />
<EmbeddedResource Include="Icons\Land\Items\tree.png" />
<EmbeddedResource Include="Icons\Land\Ground\water.png" />
<EmbeddedResource Include="Icons\UI\Blanks\blank.png" />
@@ -66,7 +65,9 @@
<EmbeddedResource Include="Icons\UI\Hearth\3-4.png" />
<EmbeddedResource Include="Icons\UI\Hearth\2-4.png" />
<EmbeddedResource Include="Icons\UI\Hearth\1-4.png" />
- <EmbeddedResource Include="Icons\Materials\stick.png" />
+ <EmbeddedResource Include="Icons\Land\Materials\land_rock.png" />
+ <EmbeddedResource Include="Icons\Land\Materials\stick.png" />
+ <EmbeddedResource Include="Icons\Land\Tools\stone_pickaxe.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
@@ -123,10 +124,11 @@
<Compile Include="Service\Mobs\MobTerraforming.cs" />
<Compile Include="Service\SuperLayers\LandPresets.cs" />
<Compile Include="Service\Mobs\MobStatsController.cs" />
- <Compile Include="Service\Crafting\CraftingRecipie.cs" />
+ <Compile Include="Service\Crafting\CraftingRecipe.cs" />
<Compile Include="Service\Crafting\CraftingController.cs" />
<Compile Include="Data\Crafting\RI.cs" />
<Compile Include="Service\Tiles\ItemPresets\ToolPresets.cs" />
+ <Compile Include="Service\Tiles\ItemPresets\MaterialPresets.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\" />
diff --git a/Mundus/Program.cs b/Mundus/Program.cs
index b2c6271..d6b17e6 100644
--- a/Mundus/Program.cs
+++ b/Mundus/Program.cs
@@ -1,4 +1,5 @@
using Gtk;
+using Mundus.Data.Crafting;
using Mundus.Data.Dialogues;
using Mundus.Data.Superlayers.Mobs;
using Mundus.Data.SuperLayers;
@@ -15,6 +16,7 @@ namespace Mundus {
DI.CreateInstances();
LI.CreateInstances();
LMI.CreateInstances( 1 );
+ RI.CreateInstances();
WI.WMain.Show();
Application.Run();
diff --git a/Mundus/Service/Calculate.cs b/Mundus/Service/Calculate.cs
index 2c8cfa1..336d2da 100644
--- a/Mundus/Service/Calculate.cs
+++ b/Mundus/Service/Calculate.cs
@@ -7,7 +7,8 @@ namespace Mundus.Service {
*On the edge it doesn't follow the player and only shows the corner "chunk". In the other parts it follows the
*the player, making sure he stays in the center of the screen.
*This means that when the player is followed, rendered part of the map depend on the player position, but when
- *he isn't, it depends on the screen and map sizes.*/
+ *he isn't, it depends on the screen and map sizes.*/
+ //kind of hardcoded
public static int CalculateMaxY(int size) {
int maxY = (LMI.Player.YPos - 2 >= 0) ? LMI.Player.YPos + 2 : size - 1;
if (maxY >= MapSizes.CurrSize) maxY = MapSizes.CurrSize - 1;
diff --git a/Mundus/Service/Crafting/CraftingController.cs b/Mundus/Service/Crafting/CraftingController.cs
index 5c234a5..74172bd 100644
--- a/Mundus/Service/Crafting/CraftingController.cs
+++ b/Mundus/Service/Crafting/CraftingController.cs
@@ -1,20 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Mundus.Data.Crafting;
using Mundus.Data.Superlayers.Mobs;
using Mundus.Service.Tiles.Items;
namespace Mundus.Service.Crafting {
public static class CraftingController {
- private static Dictionary<ItemTile, int> avalable;
+ private static Dictionary<ItemTile, int> avalableItems;
public static void FindAvalableItems() {
- avalable = LMI.Player.Inventory.Items.Where(x => x != null)
+ var tmp = LMI.Player.Inventory.Items.Where(x => x != null);
+ 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.
//This is my way of getting only the "unique" item tiles.
- .Select(x => x.stock_id).Distinct().Select(x => LMI.Player.Inventory.Items.First(y => y.stock_id == x))
+ .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)
.Select(x => new KeyValuePair<ItemTile, int>(x, LMI.Player.Inventory.Items.Where(y => y != null).Count(i => i.stock_id == x.stock_id)))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
+
+ public static CraftingRecipe[] GetAvalableRecipies() {
+ List<CraftingRecipe> recipes = new List<CraftingRecipe>();
+
+ foreach (var recipe in RI.AllRecipies) {
+ if (recipe.HasEnoughItems(avalableItems)) {
+ recipes.Add(recipe);
+ }
+ }
+
+ return recipes.ToArray();
+ }
+
+ public static void CraftItem(CraftingRecipe itemRecipe) {
+ 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].stock_id == itemAndCount.Key.stock_id) {
+ LMI.Player.Inventory.Items[i] = null;
+ removedItems++;
+ }
+ }
+ }
+ ItemTile tmp = null;
+
+ if (itemRecipe.ResultItem.GetType() == typeof(Material)) {
+ tmp = new Material((Material)itemRecipe.ResultItem);
+ }
+ if (itemRecipe.ResultItem.GetType() == typeof(Tool)) {
+ tmp = new Tool((Tool)itemRecipe.ResultItem);
+ }
+ if (itemRecipe.ResultItem.GetType() == typeof(Gear)) {
+ tmp = new Gear((Gear)itemRecipe.ResultItem);
+ }
+ if (itemRecipe.ResultItem.GetType() == typeof(Structure)) {
+ tmp = new Structure((Structure)itemRecipe.ResultItem);
+ }
+ LMI.Player.Inventory.AppendToItems(tmp);
+ }
}
} \ No newline at end of file
diff --git a/Mundus/Service/Crafting/CraftingRecipe.cs b/Mundus/Service/Crafting/CraftingRecipe.cs
new file mode 100644
index 0000000..198622a
--- /dev/null
+++ b/Mundus/Service/Crafting/CraftingRecipe.cs
@@ -0,0 +1,118 @@
+using System.Collections.Generic;
+using System.Linq;
+using Mundus.Service.Tiles.Items;
+
+namespace Mundus.Service.Crafting {
+ public class CraftingRecipe {
+ public ItemTile ResultItem { get; private set; }
+
+ public int Count1 { get; private set; }
+ public ItemTile ReqItem1 { get; private set; }
+
+ public int Count2 { get; private set; }
+ public ItemTile ReqItem2 { get; private set; }
+
+ public int Count3 { get; private set; }
+ public ItemTile ReqItem3 { get; private set; }
+
+ public int Count4 { get; private set; }
+ public ItemTile ReqItem4 { get; private set; }
+
+ public int Count5 { get; private set; }
+ public ItemTile ReqItem5 { get; private set; }
+
+ public CraftingRecipe(ItemTile resultItem, int count1, ItemTile reqItem1) :this(resultItem, count1, reqItem1, 0, null, 0, null, 0, null, 0, null)
+ { }
+
+ public CraftingRecipe(ItemTile resultItem, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2) : this(resultItem, count1, reqItem1, count2, reqItem2, 0, null, 0, null, 0, null)
+ { }
+
+ public CraftingRecipe(ItemTile resultItem, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, 0, null, 0, null)
+ { }
+
+ public CraftingRecipe(ItemTile resultItem, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3, int count4, ItemTile reqItem4) : this(resultItem, count1, reqItem1, count2, reqItem2, count3, reqItem3, count4, reqItem4, 0, null)
+ { }
+
+ public CraftingRecipe(ItemTile resultItem, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3, int count4, ItemTile reqItem4, int count5, ItemTile reqItem5) {
+ this.ResultItem = resultItem;
+
+ this.Count1 = count1;
+ this.ReqItem1 = reqItem1;
+
+ this.Count2 = count2;
+ this.ReqItem2 = reqItem2;
+
+ this.Count3 = count3;
+ this.ReqItem3 = reqItem3;
+
+ this.Count4 = count4;
+ this.ReqItem4 = reqItem4;
+
+ this.Count5 = count5;
+ this.ReqItem5 = reqItem5;
+ }
+
+ //ugly af, but will rewrite when I imntegrade data bases
+ public bool HasEnoughItems(Dictionary<ItemTile, int> itemsAndCounts) {
+ bool hasEnough = true;
+
+ if (ReqItem1 != null && hasEnough) {
+ if (itemsAndCounts.Keys.Any(k => k.stock_id == ReqItem1.stock_id)) {
+ hasEnough = itemsAndCounts.First(x => x.Key.stock_id == ReqItem1.stock_id).Value >= Count2;
+ }
+ else hasEnough = false;
+ }
+
+ if (ReqItem2 != null && hasEnough) {
+ if (itemsAndCounts.Keys.Any(k => k.stock_id == ReqItem2.stock_id)) {
+ hasEnough = itemsAndCounts.First(x => x.Key.stock_id == ReqItem2.stock_id).Value >= Count2;
+ }
+ else hasEnough = false;
+ }
+
+ if (ReqItem3 != null && hasEnough) {
+ if (itemsAndCounts.Keys.Any(k => k.stock_id == ReqItem3.stock_id)) {
+ hasEnough = itemsAndCounts.First(x => x.Key.stock_id == ReqItem3.stock_id).Value >= Count3;
+ }
+ else hasEnough = false;
+ }
+
+ if (ReqItem4 != null && hasEnough) {
+ if (itemsAndCounts.Keys.Any(k => k.stock_id == ReqItem4.stock_id)) {
+ hasEnough = itemsAndCounts.First(x => x.Key.stock_id == ReqItem4.stock_id).Value >= Count4;
+ }
+ else hasEnough = false;
+ }
+
+ if (ReqItem5 != null && hasEnough) {
+ if (itemsAndCounts.Keys.Any(k => k.stock_id == ReqItem5.stock_id)) {
+ hasEnough = itemsAndCounts.First(x => x.Key.stock_id == ReqItem5.stock_id).Value >= Count5;
+ }
+ else hasEnough = false;
+ }
+
+ return hasEnough;
+ }
+
+ public bool HasEnoughOfItem(ItemTile item, int count) {
+ if (ReqItem1.stock_id == item.stock_id) return count >= Count1;
+ if (ReqItem2.stock_id == item.stock_id) return count >= Count2;
+ if (ReqItem3.stock_id == item.stock_id) return count >= Count3;
+ if (ReqItem4.stock_id == item.stock_id) return count >= Count4;
+ if (ReqItem5.stock_id == item.stock_id) return count >= Count5;
+ return false;
+ }
+
+ public Dictionary<ItemTile, int> GetRequiredItemsAndCounts() {
+ Dictionary<ItemTile, int> req = new Dictionary<ItemTile, int>();
+
+ req.Add(ReqItem1, Count1);
+ if (ReqItem2 != null) req.Add(ReqItem2, Count2);
+ if (ReqItem3 != null) req.Add(ReqItem3, Count3);
+ if (ReqItem4 != null) req.Add(ReqItem4, Count4);
+ if (ReqItem5 != null) req.Add(ReqItem5, Count5);
+
+ return req;
+ }
+ }
+}
diff --git a/Mundus/Service/Crafting/CraftingRecipie.cs b/Mundus/Service/Crafting/CraftingRecipie.cs
deleted file mode 100644
index 7d14df4..0000000
--- a/Mundus/Service/Crafting/CraftingRecipie.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using Mundus.Service.Tiles.Items;
-
-namespace Mundus.Service.Crafting {
- public class CraftingRecipie {
- public ItemTile Result { get; private set; }
-
- public int Count1 { get; private set; }
- public ItemTile ReqItem1 { get; private set; }
-
- public int Count2 { get; private set; }
- public ItemTile ReqItem2 { get; private set; }
-
- public int Count3 { get; private set; }
- public ItemTile ReqItem3 { get; private set; }
-
- public int Count4 { get; private set; }
- public ItemTile ReqItem4 { get; private set; }
-
- public int Count5 { get; private set; }
- public ItemTile ReqItem5 { get; private set; }
-
- public CraftingRecipie(ItemTile result, int count1, ItemTile reqItem1) :this(result, count1, reqItem1, 0, null, 0, null, 0, null, 0, null)
- { }
-
- public CraftingRecipie(ItemTile result, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2) : this(result, count1, reqItem1, count2, reqItem2, 0, null, 0, null, 0, null)
- { }
-
- public CraftingRecipie(ItemTile result, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3) : this(result, count1, reqItem1, count2, reqItem2, count3, reqItem3, 0, null, 0, null)
- { }
-
- public CraftingRecipie(ItemTile result, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3, int count4, ItemTile reqItem4) : this(result, count1, reqItem1, count2, reqItem2, count3, reqItem3, count4, reqItem4, 0, null)
- { }
-
- public CraftingRecipie(ItemTile result, int count1, ItemTile reqItem1, int count2, ItemTile reqItem2, int count3, ItemTile reqItem3, int count4, ItemTile reqItem4, int count5, ItemTile reqItem5) {
- this.Result = result;
-
- this.Count1 = count1;
- this.ReqItem1 = reqItem1;
-
- this.Count2 = count2;
- this.ReqItem2 = reqItem2;
-
- this.Count3 = count3;
- this.ReqItem3 = reqItem3;
-
- this.Count4 = count4;
- this.ReqItem4 = reqItem4;
-
- this.Count5 = count5;
- this.ReqItem5 = reqItem5;
- }
- }
-}
diff --git a/Mundus/Service/SuperLayers/LandPresets.cs b/Mundus/Service/SuperLayers/LandPresets.cs
index b07edfe..5181c45 100644
--- a/Mundus/Service/SuperLayers/LandPresets.cs
+++ b/Mundus/Service/SuperLayers/LandPresets.cs
@@ -1,14 +1,15 @@
using Mundus.Data.Tiles;
+using Mundus.Service.Tiles.ItemPresets;
using Mundus.Service.Tiles.Items;
namespace Mundus.Service.SuperLayers {
public static class LandPresets {
- public static Structure Boulder() {
- return new Structure("boulder", 10, ToolTypes.Pickaxe, 1, false, new Material("land_rock"));
+ public static Structure GetABoulder() {
+ return new Structure("boulder", 10, ToolTypes.Pickaxe, 1, false, MaterialPresets.GetALandRock());
}
- public static Structure Tree() {
- return new Structure("tree", 5, ToolTypes.Pickaxe, 1, false, new Material("stick"));
+ public static Structure GetATree() {
+ return new Structure("tree", 5, ToolTypes.Pickaxe, 1, false, MaterialPresets.GetAStick());
}
}
}
diff --git a/Mundus/Service/SuperLayers/LandSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/LandSuperLayerGenerator.cs
index 73caaa3..673d644 100644
--- a/Mundus/Service/SuperLayers/LandSuperLayerGenerator.cs
+++ b/Mundus/Service/SuperLayers/LandSuperLayerGenerator.cs
@@ -54,10 +54,10 @@ namespace Mundus.Service.SuperLayers {
for (int col = 0; col < size; col++) {
for (int row = 0; row < size; row++) {
if (rnd.Next( 0, 50 ) == 1) {
- tiles[col, row] = LandPresets.Boulder();
+ tiles[col, row] = LandPresets.GetABoulder();
}
if (rnd.Next(0, 10) == 1) {
- tiles[col, row] = LandPresets.Tree();
+ tiles[col, row] = LandPresets.GetATree();
}
}
}
diff --git a/Mundus/Service/Tiles/ItemPresets/MaterialPresets.cs b/Mundus/Service/Tiles/ItemPresets/MaterialPresets.cs
new file mode 100644
index 0000000..655ba8c
--- /dev/null
+++ b/Mundus/Service/Tiles/ItemPresets/MaterialPresets.cs
@@ -0,0 +1,14 @@
+using System;
+using Mundus.Service.Tiles.Items;
+
+namespace Mundus.Service.Tiles.ItemPresets {
+ public static class MaterialPresets {
+ public static Material GetALandRock() {
+ return new Material("land_rock");
+ }
+
+ public static Material GetAStick() {
+ return new Material("stick");
+ }
+ }
+}
diff --git a/Mundus/Service/Tiles/ItemPresets/ToolPresets.cs b/Mundus/Service/Tiles/ItemPresets/ToolPresets.cs
index 0917cc4..933b6be 100644
--- a/Mundus/Service/Tiles/ItemPresets/ToolPresets.cs
+++ b/Mundus/Service/Tiles/ItemPresets/ToolPresets.cs
@@ -1,6 +1,11 @@
using System;
+using Mundus.Data.Tiles;
+using Mundus.Service.Tiles.Items;
+
namespace Mundus.Service.Tiles.ItemPresets {
public static class ToolPresets {
-
+ public static Tool GetAStonePickaxe() {
+ return new Tool("stone_pickaxe", ToolTypes.Pickaxe, 2);
+ }
}
}
diff --git a/Mundus/Service/Tiles/Items/Gear.cs b/Mundus/Service/Tiles/Items/Gear.cs
index 5af2283..7beef40 100644
--- a/Mundus/Service/Tiles/Items/Gear.cs
+++ b/Mundus/Service/Tiles/Items/Gear.cs
@@ -1,5 +1,8 @@
namespace Mundus.Service.Tiles.Items {
public class Gear : ItemTile {
+ public Gear(Gear gear) : base(gear.stock_id)
+ { }
+
public Gear(string stock_id) : base(stock_id)
{ }
diff --git a/Mundus/Service/Tiles/Items/ItemTile.cs b/Mundus/Service/Tiles/Items/ItemTile.cs
index 56c95a2..4b6b6d7 100644
--- a/Mundus/Service/Tiles/Items/ItemTile.cs
+++ b/Mundus/Service/Tiles/Items/ItemTile.cs
@@ -6,6 +6,9 @@ namespace Mundus.Service.Tiles.Items {
public string stock_id { get; private set; }
public Image Texture { get; private set; }
+ public ItemTile(ItemTile item) :this(item.stock_id)
+ { }
+
public ItemTile(string stock_id) {
this.stock_id = stock_id;
this.Texture = new Image( stock_id, IconSize.Dnd );
diff --git a/Mundus/Service/Tiles/Items/Material.cs b/Mundus/Service/Tiles/Items/Material.cs
index b7011ef..7c7afbf 100644
--- a/Mundus/Service/Tiles/Items/Material.cs
+++ b/Mundus/Service/Tiles/Items/Material.cs
@@ -1,5 +1,7 @@
namespace Mundus.Service.Tiles.Items {
public class Material : ItemTile {
+ public Material(Material material) : base(material.stock_id) { }
+
public Material(string stock_id) : base(stock_id)
{ }
diff --git a/Mundus/Service/Tiles/Items/Structure.cs b/Mundus/Service/Tiles/Items/Structure.cs
index 98de50d..94e808a 100644
--- a/Mundus/Service/Tiles/Items/Structure.cs
+++ b/Mundus/Service/Tiles/Items/Structure.cs
@@ -7,9 +7,9 @@
public bool IsWalkable { get; private set; }
+
public Structure(Structure structure) :this(structure.stock_id, structure.Health, structure.ReqToolType, structure.ReqToolClass, structure.IsWalkable,
new Material(structure.DroppedMaterial.stock_id)) {
- //dunno if I would need it
}
public Structure(string stock_id, byte health, int reqToolType, int reqToolClass, bool isWalkable = false, Material droppedMaterial = null) : base(stock_id) {
diff --git a/Mundus/Service/Tiles/Items/Tool.cs b/Mundus/Service/Tiles/Items/Tool.cs
index 9a10f98..ac7bd55 100644
--- a/Mundus/Service/Tiles/Items/Tool.cs
+++ b/Mundus/Service/Tiles/Items/Tool.cs
@@ -5,6 +5,9 @@ namespace Mundus.Service.Tiles.Items {
public int Type { get; private set; }
public int Class { get; private set; }
+ public Tool(Tool tool) : this(tool.stock_id, tool.Type, tool.Class)
+ { }
+
public Tool(string stock_id, int toolType, int toolClass) : base(stock_id) {
this.Type = toolType;
this.Class = toolClass;
diff --git a/Mundus/Service/WindowController.cs b/Mundus/Service/WindowController.cs
index 139adda..97bb6e7 100644
--- a/Mundus/Service/WindowController.cs
+++ b/Mundus/Service/WindowController.cs
@@ -33,6 +33,7 @@ namespace Mundus.Service {
}
public static void ShowCraftingWindow() {
+ WI.WCrafting.Initialize();
WI.WCrafting.Show();
WI.WCrafting.Present();
}
diff --git a/Mundus/Views/Windows/CraftingWindow.cs b/Mundus/Views/Windows/CraftingWindow.cs
index 137d6bd..1e1b47c 100644
--- a/Mundus/Views/Windows/CraftingWindow.cs
+++ b/Mundus/Views/Windows/CraftingWindow.cs
@@ -1,13 +1,81 @@
using Gtk;
+using System;
+using Mundus.Service.Crafting;
using Mundus.Service.Tiles.Items;
namespace Mundus.Views.Windows {
public partial class CraftingWindow : Gtk.Window {
+ public CraftingRecipe[] Recipes { get; set; }
+ private int recipeIndex;
+
public CraftingWindow() : base( Gtk.WindowType.Toplevel ) {
this.Build();
}
+ protected void OnDeleteEvent(object o, DeleteEventArgs args) {
+ args.RetVal = true;
+ this.Hide();
+ }
+
+ public void Initialize() {
+ Reset();
+ CraftingController.FindAvalableItems();
+ this.Recipes = CraftingController.GetAvalableRecipies();
+ recipeIndex = 0;
+ PrintRecipe();
+ UpdateNextPrevBtns();
+ }
+
+ private void PrintRecipe() {
+ if (Recipes.Length > 0) {
+ CraftingRecipe recipe = Recipes[recipeIndex];
+ btnCraft.Sensitive = true;
+
+ imgItem.SetFromStock(recipe.ResultItem.stock_id, IconSize.Dnd);
+ lblInfo.Text = recipe.ResultItem.ToString();
+
+ lblC1.Text = recipe.Count1 + "";
+ imgI1.SetFromStock(recipe.ReqItem1.stock_id, IconSize.Dnd);
+
+ if (recipe.ReqItem2 != null) {
+ lblC2.Text = recipe.Count2 + "";
+ imgI2.SetFromStock(recipe.ReqItem2.stock_id, IconSize.Dnd);
+ }
+
+ if (recipe.ReqItem3 != null) {
+ lblC3.Text = recipe.Count3 + "";
+ imgI3.SetFromStock(recipe.ReqItem3.stock_id, IconSize.Dnd);
+ }
+
+ if (recipe.ReqItem4 != null) {
+ lblC4.Text = recipe.Count4 + "";
+ imgI4.SetFromStock(recipe.ReqItem4.stock_id, IconSize.Dnd);
+ }
+
+ if (recipe.ReqItem5 != null) {
+ lblC5.Text = recipe.Count5 + "";
+ imgI5.SetFromStock(recipe.ReqItem5.stock_id, IconSize.Dnd);
+ }
+ }
+ }
+
+
+
+ protected void OnBtnPrevClicked(object sender, System.EventArgs e) {
+ recipeIndex--;
+ PrintRecipe();
+ UpdateNextPrevBtns();
+ }
+ protected void OnBtnNextClicked(object sender, System.EventArgs e) {
+ recipeIndex++;
+ PrintRecipe();
+ UpdateNextPrevBtns();
+ }
+ private void UpdateNextPrevBtns() {
+ btnNext.Sensitive = recipeIndex < Recipes.Length - 1;
+ btnPrev.Sensitive = recipeIndex > 0;
+ }
private void Reset() {
lblC1.Text = "0";
@@ -16,16 +84,22 @@ namespace Mundus.Views.Windows {
lblC4.Text = "0";
lblC5.Text = "0";
- imgI1.IconSet = null;
- imgI2.IconSet = null;
- imgI3.IconSet = null;
- imgI4.IconSet = null;
- imgI5.IconSet = null;
+ imgI1.SetFromStock("empty", IconSize.Dnd);
+ imgI2.SetFromStock("empty", IconSize.Dnd);
+ imgI3.SetFromStock("empty", IconSize.Dnd);
+ imgI4.SetFromStock("empty", IconSize.Dnd);
+ imgI5.SetFromStock("empty", IconSize.Dnd);
- imgItem.IconSet = null;
+ imgItem.SetFromStock("empty", IconSize.Dnd);
lblInfo.Text = null;
btnPrev.Sensitive = false;
btnNext.Sensitive = false;
+ btnCraft.Sensitive = false;
+ }
+
+ protected void OnBtnCraftClicked(object sender, EventArgs e) {
+ CraftingController.CraftItem(Recipes[recipeIndex]);
+ this.Hide();
}
}
}
diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.CraftingWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.CraftingWindow.cs
index 54a90f2..09218da 100644
--- a/Mundus/gtk-gui/Mundus.Views.Windows.CraftingWindow.cs
+++ b/Mundus/gtk-gui/Mundus.Views.Windows.CraftingWindow.cs
@@ -6,12 +6,12 @@ namespace Mundus.Views.Windows
{
private global::Gtk.Table tbUI;
+ private global::Gtk.Button btnCraft;
+
private global::Gtk.Button btnNext;
private global::Gtk.Button btnPrev;
- private global::Gtk.Button button28;
-
private global::Gtk.Image imgI1;
private global::Gtk.Image imgI2;
@@ -71,6 +71,22 @@ namespace Mundus.Views.Windows
this.tbUI = new global::Gtk.Table(((uint)(11)), ((uint)(7)), false);
this.tbUI.Name = "tbUI";
// Container child tbUI.Gtk.Table+TableChild
+ this.btnCraft = new global::Gtk.Button();
+ this.btnCraft.HeightRequest = 50;
+ this.btnCraft.Sensitive = false;
+ this.btnCraft.CanFocus = true;
+ this.btnCraft.Name = "btnCraft";
+ this.btnCraft.UseUnderline = true;
+ this.btnCraft.Label = global::Mono.Unix.Catalog.GetString("Craft");
+ this.tbUI.Add(this.btnCraft);
+ global::Gtk.Table.TableChild w1 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnCraft]));
+ w1.TopAttach = ((uint)(9));
+ w1.BottomAttach = ((uint)(10));
+ w1.LeftAttach = ((uint)(1));
+ w1.RightAttach = ((uint)(6));
+ w1.XOptions = ((global::Gtk.AttachOptions)(4));
+ w1.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child tbUI.Gtk.Table+TableChild
this.btnNext = new global::Gtk.Button();
this.btnNext.Sensitive = false;
this.btnNext.CanFocus = true;
@@ -78,13 +94,13 @@ namespace Mundus.Views.Windows
this.btnNext.UseUnderline = true;
this.btnNext.Label = global::Mono.Unix.Catalog.GetString("Next");
this.tbUI.Add(this.btnNext);
- global::Gtk.Table.TableChild w1 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnNext]));
- w1.TopAttach = ((uint)(7));
- w1.BottomAttach = ((uint)(8));
- w1.LeftAttach = ((uint)(4));
- w1.RightAttach = ((uint)(5));
- w1.XOptions = ((global::Gtk.AttachOptions)(4));
- w1.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnNext]));
+ w2.TopAttach = ((uint)(7));
+ w2.BottomAttach = ((uint)(8));
+ w2.LeftAttach = ((uint)(4));
+ w2.RightAttach = ((uint)(5));
+ w2.XOptions = ((global::Gtk.AttachOptions)(4));
+ w2.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
this.btnPrev = new global::Gtk.Button();
this.btnPrev.WidthRequest = 50;
@@ -95,27 +111,11 @@ namespace Mundus.Views.Windows
this.btnPrev.UseUnderline = true;
this.btnPrev.Label = global::Mono.Unix.Catalog.GetString("Prev");
this.tbUI.Add(this.btnPrev);
- global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnPrev]));
- w2.TopAttach = ((uint)(7));
- w2.BottomAttach = ((uint)(8));
- w2.LeftAttach = ((uint)(2));
- w2.RightAttach = ((uint)(3));
- w2.XOptions = ((global::Gtk.AttachOptions)(4));
- w2.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child tbUI.Gtk.Table+TableChild
- this.button28 = new global::Gtk.Button();
- this.button28.HeightRequest = 50;
- this.button28.Sensitive = false;
- this.button28.CanFocus = true;
- this.button28.Name = "button28";
- this.button28.UseUnderline = true;
- this.button28.Label = global::Mono.Unix.Catalog.GetString("Craft");
- this.tbUI.Add(this.button28);
- global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.tbUI[this.button28]));
- w3.TopAttach = ((uint)(9));
- w3.BottomAttach = ((uint)(10));
- w3.LeftAttach = ((uint)(1));
- w3.RightAttach = ((uint)(6));
+ global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnPrev]));
+ w3.TopAttach = ((uint)(7));
+ w3.BottomAttach = ((uint)(8));
+ w3.LeftAttach = ((uint)(2));
+ w3.RightAttach = ((uint)(3));
w3.XOptions = ((global::Gtk.AttachOptions)(4));
w3.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
@@ -434,6 +434,10 @@ namespace Mundus.Views.Windows
this.DefaultWidth = 270;
this.DefaultHeight = 470;
this.Show();
+ this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
+ this.btnPrev.Clicked += new global::System.EventHandler(this.OnBtnPrevClicked);
+ this.btnNext.Clicked += new global::System.EventHandler(this.OnBtnNextClicked);
+ this.btnCraft.Clicked += new global::System.EventHandler(this.OnBtnCraftClicked);
}
}
}
diff --git a/Mundus/gtk-gui/generated.cs b/Mundus/gtk-gui/generated.cs
index c2fce8a..7a0a83c 100644
--- a/Mundus/gtk-gui/generated.cs
+++ b/Mundus/gtk-gui/generated.cs
@@ -24,7 +24,7 @@ namespace Stetic
w1.Add("blank_hand", w6);
global::Gtk.IconSet w7 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Blanks.blank_gear.png"));
w1.Add("blank_gear", w7);
- global::Gtk.IconSet w8 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Materials.land_rock.png"));
+ global::Gtk.IconSet w8 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Materials.land_rock.png"));
w1.Add("land_rock", w8);
global::Gtk.IconSet w9 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Items.tree.png"));
w1.Add("tree", w9);
@@ -40,8 +40,10 @@ namespace Stetic
w1.Add("hearth_2-4", w14);
global::Gtk.IconSet w15 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.1-4.png"));
w1.Add("hearth_1-4", w15);
- global::Gtk.IconSet w16 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Materials.stick.png"));
+ global::Gtk.IconSet w16 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Materials.stick.png"));
w1.Add("stick", w16);
+ global::Gtk.IconSet w17 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Tools.stone_pickaxe.png"));
+ w1.Add("stone_pickaxe", w17);
w1.AddDefault();
}
}
diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic
index 3c7d38a..76d19f5 100644
--- a/Mundus/gtk-gui/gui.stetic
+++ b/Mundus/gtk-gui/gui.stetic
@@ -39,7 +39,7 @@
</icon-set>
<icon-set id="land_rock">
<source>
- <property name="Image">resource:Mundus.Icons.Materials.land_rock.png</property>
+ <property name="Image">resource:Mundus.Icons.Land.Materials.land_rock.png</property>
</source>
</icon-set>
<icon-set id="tree">
@@ -79,7 +79,12 @@
</icon-set>
<icon-set id="stick">
<source>
- <property name="Image">resource:Mundus.Icons.Materials.stick.png</property>
+ <property name="Image">resource:Mundus.Icons.Land.Materials.stick.png</property>
+ </source>
+ </icon-set>
+ <icon-set id="stone_pickaxe">
+ <source>
+ <property name="Image">resource:Mundus.Icons.Land.Tools.stone_pickaxe.png</property>
</source>
</icon-set>
</icon-factory>
@@ -5631,6 +5636,7 @@
<property name="MemberName" />
<property name="Title" translatable="yes">CraftingWindow</property>
<property name="WindowPosition">CenterOnParent</property>
+ <signal name="DeleteEvent" handler="OnDeleteEvent" />
<child>
<widget class="Gtk.Table" id="tbUI">
<property name="MemberName" />
@@ -5763,19 +5769,21 @@
<placeholder />
</child>
<child>
- <widget class="Gtk.Button" id="btnNext">
+ <widget class="Gtk.Button" id="btnCraft">
<property name="MemberName" />
+ <property name="HeightRequest">50</property>
<property name="Sensitive">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
- <property name="Label" translatable="yes">Next</property>
+ <property name="Label" translatable="yes">Craft</property>
<property name="UseUnderline">True</property>
+ <signal name="Clicked" handler="OnBtnCraftClicked" />
</widget>
<packing>
- <property name="TopAttach">7</property>
- <property name="BottomAttach">8</property>
- <property name="LeftAttach">4</property>
- <property name="RightAttach">5</property>
+ <property name="TopAttach">9</property>
+ <property name="BottomAttach">10</property>
+ <property name="LeftAttach">1</property>
+ <property name="RightAttach">6</property>
<property name="AutoSize">True</property>
<property name="XOptions">Fill</property>
<property name="YOptions">Fill</property>
@@ -5788,21 +5796,20 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnPrev">
+ <widget class="Gtk.Button" id="btnNext">
<property name="MemberName" />
- <property name="WidthRequest">50</property>
- <property name="HeightRequest">50</property>
<property name="Sensitive">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
- <property name="Label" translatable="yes">Prev</property>
+ <property name="Label" translatable="yes">Next</property>
<property name="UseUnderline">True</property>
+ <signal name="Clicked" handler="OnBtnNextClicked" />
</widget>
<packing>
<property name="TopAttach">7</property>
<property name="BottomAttach">8</property>
- <property name="LeftAttach">2</property>
- <property name="RightAttach">3</property>
+ <property name="LeftAttach">4</property>
+ <property name="RightAttach">5</property>
<property name="AutoSize">True</property>
<property name="XOptions">Fill</property>
<property name="YOptions">Fill</property>
@@ -5815,20 +5822,22 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="button28">
+ <widget class="Gtk.Button" id="btnPrev">
<property name="MemberName" />
+ <property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
<property name="Sensitive">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
- <property name="Label" translatable="yes">Craft</property>
+ <property name="Label" translatable="yes">Prev</property>
<property name="UseUnderline">True</property>
+ <signal name="Clicked" handler="OnBtnPrevClicked" />
</widget>
<packing>
- <property name="TopAttach">9</property>
- <property name="BottomAttach">10</property>
- <property name="LeftAttach">1</property>
- <property name="RightAttach">6</property>
+ <property name="TopAttach">7</property>
+ <property name="BottomAttach">8</property>
+ <property name="LeftAttach">2</property>
+ <property name="RightAttach">3</property>
<property name="AutoSize">True</property>
<property name="XOptions">Fill</property>
<property name="YOptions">Fill</property>