From 8525ea8c690e27fb2451ca67c622b0f6c01acb4a Mon Sep 17 00:00:00 2001 From: MasterGordon Date: Wed, 4 Jan 2023 13:42:11 +0100 Subject: [PATCH] Updated Iron visibility + Added Workbench recipe --- Mine2d/assets/blocks/iron-ore.png | Bin 255 -> 279 bytes Mine2d/assets/items/ingot-iron.png | Bin 191 -> 200 bytes Mine2d/assets/items/raw-iron.png | Bin 254 -> 284 bytes Mine2d/game/backend/interactor/Breaking.cs | 4 ++-- ...PlacePacket.cs => PlayerInteractPacket.cs} | 0 Mine2d/game/core/PlayerEntity.cs | 20 +++++++++--------- Mine2d/game/core/data/ItemStack.cs | 5 +++++ Mine2d/game/core/items/ItemRegistry.cs | 4 ++-- Mine2d/game/core/tiles/TileRegistry.cs | 10 +++------ Mine2d/game/core/tiles/Workbench.cs | 10 +++++++++ Mine2d/game/core/world/ChunkGenerator.cs | 2 +- .../frontend/inventory/WorkbenchInventory.cs | 2 +- 12 files changed, 34 insertions(+), 23 deletions(-) rename Mine2d/game/backend/network/packets/{PlacePacket.cs => PlayerInteractPacket.cs} (100%) diff --git a/Mine2d/assets/blocks/iron-ore.png b/Mine2d/assets/blocks/iron-ore.png index e54ea5a0d4c5e7187a2818514279eeec0752689e..b174eed33df617fa9eba3210562a5b53f2c8b016 100644 GIT binary patch delta 238 zcmV-1@l+x(BO4>DE0U{yq_XpCdm>bH-vU o$+qB(ra4L?A-$g#mKWL=Z(TuTZl;ieO8@`>07*qoM6N<$f?IZLg8%>k delta 214 zcmV;{04e{M0{;P!F@L#9L_t(Ijm=U!4udcZHKkJS!<>8g6qy;|8eD(@^sbeejmZ*{ zI}tf;pk-*)HzkhWCr*g|2Cer5K*w>^E4z*PJpcdz diff --git a/Mine2d/assets/items/ingot-iron.png b/Mine2d/assets/items/ingot-iron.png index b924e1d266fa3999e26656001d3a9d9db8487509..c2c4a540d271507fc62e98effa6961a1a3ba85e1 100644 GIT binary patch delta 159 zcmV;Q0AT;W0muQ6F@J(dL_t(Ijn$FM5r7~J1*1a;qyg)r0ZOoe)JFrM2TyTgcsLyO zoj7Ede29LZZKX)0HhY(H9?Jp`GG|ilg9Hj9=o2LgK?s~>M-YNlJE?YJ&cvMW4^u3( zSxsUs&pH|eUa~R@6nIfgT;k&jBDML}y#SqX5O|3JmI%Hko*4Aoxd7hQKSAB>y+Qy0 N002ovPDHLkV1l1PKY;)M delta 150 zcmV;H0BQfo0lxu|F@JeUL_t(Ijn$FM5x^h_L`lXHwoB`w%k9CO$RMEOG1-#`-jk2W z?{l3Lsp_zI?|ovn0uKTZl1WkuBIpw(t%53WmAir}n52*t00Q9su*E`~)g;#Ps-q9_L$_-jAFvJda1VE_OC07*qoM6N<$ Ef-P)DwEzGB diff --git a/Mine2d/assets/items/raw-iron.png b/Mine2d/assets/items/raw-iron.png index 589f665aaf8270711fee8c7ac8caaa528464977c..e0c487b35f869cdaf7ed087b69f3bc29ce931d8c 100644 GIT binary patch delta 243 zcmVM* tMIMi*TKH`e-y`uo=JS#K{Q94-@&I1$OLb!raKZop002ovPDHLkV1jqaaw7l$ delta 213 zcmV;`04o2S0{#JzF@Ly8L_t(IjqQ;w4ue1tMjzD#HL9YAK<_mOL8CWF&QOg;H{1i= zLsTI~H7iNBiVZ)Dt7+0t?QZ71nask^C)q!=#sH98>s6K41wOE}hnJmZssXsyOH9 z`#v<>jMExJZmnMfB7&+i&ofQa9F~6i3+tUs(-eiHg1zWk6#fkU=S%qj&4f%!quus3 P00000NkvXXu0mjf;R0i& diff --git a/Mine2d/game/backend/interactor/Breaking.cs b/Mine2d/game/backend/interactor/Breaking.cs index 0cfb674..381c3cb 100644 --- a/Mine2d/game/backend/interactor/Breaking.cs +++ b/Mine2d/game/backend/interactor/Breaking.cs @@ -39,8 +39,8 @@ public class Breaking { var tileRegistry = ctx.TileRegistry; var hardness = tileRegistry.GetTile(tileId).Hardness; - var hardnessBonus = Math.Min(1, player.GetHarvestLevel() / hardness); - player.MiningCooldown = 50 - (player.GetMiningSpeed() * hardnessBonus); + var hardnessBonus = Math.Min(1, player.GetHarvestLevel() / (double)hardness); + player.MiningCooldown = (int)(50 - (player.GetMiningSpeed() * hardnessBonus)); if(tile.Hits == 0) { ctx.GameState.World.Cracks.Enqueue(new CrackQueueEntry { diff --git a/Mine2d/game/backend/network/packets/PlacePacket.cs b/Mine2d/game/backend/network/packets/PlayerInteractPacket.cs similarity index 100% rename from Mine2d/game/backend/network/packets/PlacePacket.cs rename to Mine2d/game/backend/network/packets/PlayerInteractPacket.cs diff --git a/Mine2d/game/core/PlayerEntity.cs b/Mine2d/game/core/PlayerEntity.cs index afd1466..4c07d9b 100644 --- a/Mine2d/game/core/PlayerEntity.cs +++ b/Mine2d/game/core/PlayerEntity.cs @@ -76,8 +76,8 @@ public class PlayerEntity bool hasCollision; do { - var pL = player.Position + new Vector2(0, -8); - var pL2 = player.Position + new Vector2(0, -24); + var pL = player.Position + new Vector2(3, -2); + var pL2 = player.Position + new Vector2(3, -24); hasCollision = (world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL)) || (world.HasChunkAt(pL2) && world.GetChunkAt(pL2).HasSolidTileAt(pL2)); @@ -89,8 +89,8 @@ public class PlayerEntity } while (hasCollision); do { - var pR = player.Position + new Vector2(14, -8); - var pR2 = player.Position + new Vector2(14, -24); + var pR = player.Position + new Vector2(12, -2); + var pR2 = player.Position + new Vector2(12, -24); hasCollision = (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR)) || (world.HasChunkAt(pR2) && world.GetChunkAt(pR2).HasSolidTileAt(pR2)); @@ -102,8 +102,8 @@ public class PlayerEntity } while (hasCollision); do { - var pL = player.Position + new Vector2(0, 0); - var pR = player.Position + new Vector2(14, 0); + var pL = player.Position + new Vector2(3, 0); + var pR = player.Position + new Vector2(12, 0); hasCollision = (world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL)) || (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR)); @@ -115,8 +115,8 @@ public class PlayerEntity } while (hasCollision); do { - var pL = player.Position + new Vector2(0, -28); - var pR = player.Position + new Vector2(14, -28); + var pL = player.Position + new Vector2(3, -28); + var pR = player.Position + new Vector2(12, -28); hasCollision = (world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL)) || (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR)); @@ -129,8 +129,8 @@ public class PlayerEntity { var groundCheckPosition = player.Position - new Vector2(0, -1f); - var pL = groundCheckPosition + new Vector2(0, 0); - var pR = groundCheckPosition + new Vector2(14, 0); + var pL = groundCheckPosition + new Vector2(3, 0); + var pR = groundCheckPosition + new Vector2(12, 0); movement.IsGrounded = (world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL)) || (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR)); } diff --git a/Mine2d/game/core/data/ItemStack.cs b/Mine2d/game/core/data/ItemStack.cs index 7ec90b1..9bf4aa6 100644 --- a/Mine2d/game/core/data/ItemStack.cs +++ b/Mine2d/game/core/data/ItemStack.cs @@ -36,4 +36,9 @@ public class ItemStack { return Context.Get().ItemRegistry.GetItem(this.Id).GetKind(); } + + public ItemStack Clone() + { + return new ItemStack(this.Id, this.Count); + } } diff --git a/Mine2d/game/core/items/ItemRegistry.cs b/Mine2d/game/core/items/ItemRegistry.cs index 79c3db0..9f87eed 100644 --- a/Mine2d/game/core/items/ItemRegistry.cs +++ b/Mine2d/game/core/items/ItemRegistry.cs @@ -39,8 +39,8 @@ public class ItemRegistry // Pickaxes this.Register(ItemId.PickaxeBasic, new PickaxeItem(ItemId.PickaxeBasic, "Basic Pickaxe", "items.pickaxe-basic", 15, 4)); this.Register(ItemId.PickaxeStone, new PickaxeItem(ItemId.PickaxeStone, "Stone Pickaxe", "items.pickaxe-stone", 25, 6)); - this.Register(ItemId.PickaxeIron, new PickaxeItem(ItemId.PickaxeIron, "Iron Pickaxe", "items.pickaxe-iron", 40, 7)); - this.Register(ItemId.PickaxeGold, new PickaxeItem(ItemId.PickaxeGold, "Gold Pickaxe", "items.pickaxe-gold", 60, 8)); + this.Register(ItemId.PickaxeIron, new PickaxeItem(ItemId.PickaxeIron, "Iron Pickaxe", "items.pickaxe-iron", 30, 7)); + this.Register(ItemId.PickaxeGold, new PickaxeItem(ItemId.PickaxeGold, "Gold Pickaxe", "items.pickaxe-gold", 35, 9)); // Materials this.Register(ItemId.CopperWire, new Item(ItemId.CopperWire, "Copper Wire", "items.copper-wire" )); this.Register(ItemId.Silicon, new Item(ItemId.Silicon, "Silicon", "items.silicon" )); diff --git a/Mine2d/game/core/tiles/TileRegistry.cs b/Mine2d/game/core/tiles/TileRegistry.cs index 8adcb6f..3f26e97 100644 --- a/Mine2d/game/core/tiles/TileRegistry.cs +++ b/Mine2d/game/core/tiles/TileRegistry.cs @@ -33,17 +33,13 @@ public class TileRegistry public void RegisterTile() { this.Tiles.Add(1, new Tile("stone", "stone", 5, ItemId.Stone)); - this.Tiles.Add(2, new OreTile("ore1", new[] { "stone", "ore1" }, 5)); - this.Tiles.Add(3, new OreTile("ore2", new[] { "stone", "ore2" }, 7)); - this.Tiles.Add(4, new OreTile("ore3", new[] { "stone", "ore3" }, 8)); - this.Tiles.Add(5, new OreTile("ore4", new[] { "stone", "ore4" }, 10)); this.Tiles.Add(6, new Workbench("workbench", "workbench", 10)); this.Tiles.Add(7, new OreTile("iron-ore", new[] { "stone", "iron-ore" }, 6, ItemId.RawIron)); this.Tiles.Add(8, new OreTile("copper-ore", new[] { "stone", "copper-ore" }, 6, ItemId.RawCopper)); - this.Tiles.Add(9, new OreTile("tin-ore", new[] { "stone", "tin-ore" }, 6, ItemId.RawTin)); + this.Tiles.Add(9, new OreTile("tin-ore", new[] { "stone", "tin-ore" }, 7, ItemId.RawTin)); this.Tiles.Add(10, new OreTile("silver-ore", new[] { "stone", "silver-ore" }, 7, ItemId.RawSilver)); - this.Tiles.Add(11, new OreTile("gold-ore", new[] { "stone", "gold-ore" }, 8, ItemId.RawGold)); - this.Tiles.Add(12, new OreTile("lead-ore", new[] { "stone", "lead-ore" }, 9, ItemId.RawLead)); + this.Tiles.Add(12, new OreTile("lead-ore", new[] { "stone", "lead-ore" }, 8, ItemId.RawLead)); + this.Tiles.Add(11, new OreTile("gold-ore", new[] { "stone", "gold-ore" }, 9, ItemId.RawGold)); this.Tiles.Add(13, new OreTile("platinum-ore", new[] { "stone", "platinum-ore" }, 10, ItemId.RawPlatinum)); this.Tiles.Add(14, new OreTile("cobalt-ore", new[] { "stone", "cobalt-ore" }, 11, ItemId.RawCobalt)); this.Tiles.Add(15, new OreTile("tungsten-ore", new[] { "stone", "tungsten-ore" }, 15, ItemId.RawTungsten)); diff --git a/Mine2d/game/core/tiles/Workbench.cs b/Mine2d/game/core/tiles/Workbench.cs index 9db5698..02f04c9 100644 --- a/Mine2d/game/core/tiles/Workbench.cs +++ b/Mine2d/game/core/tiles/Workbench.cs @@ -134,6 +134,16 @@ public class Workbench : Tile new ItemStack(ItemId.Fuse, 1), } }); + Recipes.Add(new Recipe + { + Result = new ItemStack(ItemId.Workbench, 1), + Ingredients = new List + { + new ItemStack(ItemId.Stone, 1), + new ItemStack(ItemId.Fuse, 1), + new ItemStack(ItemId.CopperWire, 3), + } + }); } public override bool IsSolid() diff --git a/Mine2d/game/core/world/ChunkGenerator.cs b/Mine2d/game/core/world/ChunkGenerator.cs index 69038c5..5b76aea 100644 --- a/Mine2d/game/core/world/ChunkGenerator.cs +++ b/Mine2d/game/core/world/ChunkGenerator.cs @@ -65,7 +65,7 @@ public class ChunkGenerator else { fill.Id = (int)WG.GetRandomOreAt(j + (y * 32)); - if (new Random().NextInt64(0, 130) < 1) + if (new Random().NextInt64(0, 100) < 1) { fill.Id = (int)Tiles.CoalOre; } diff --git a/Mine2d/game/frontend/inventory/WorkbenchInventory.cs b/Mine2d/game/frontend/inventory/WorkbenchInventory.cs index a160b4a..815b521 100644 --- a/Mine2d/game/frontend/inventory/WorkbenchInventory.cs +++ b/Mine2d/game/frontend/inventory/WorkbenchInventory.cs @@ -82,7 +82,7 @@ public class WorkbenchInventory : Inventory { player.Inventory.RemoveItemStack(i); } - player.Inventory.PickupItemStack(r.Result); + player.Inventory.PickupItemStack(r.Result.Clone()); } }