From e440dc03e118fc24a6625f256e683818451a4c6d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 1 May 2020 11:21:46 +0300 Subject: Implimented energy bar (icons and functionality). For each action you take (move, use tools or place structures) will take some value from the energy bar. When it's at 0 it starts to take health for every action. You can only heal after full energy. Depends on game difficulty. Changed structure for health (hearth) icons. Updated executable. --- Mundus Build 01-05-2020 No1.exe | Bin 0 -> 1647616 bytes Mundus Build 30-04-2020 No3.exe | Bin 1608192 -> 0 bytes Mundus/Data/Difficulty.cs | 4 +- Mundus/Data/SuperLayers/Mobs/MI.cs | 4 +- Mundus/Data/Windows/WI.cs | 2 +- Mundus/Icons/Project files/1-4.xcf | Bin 3686 -> 0 bytes Mundus/Icons/Project files/2-4.xcf | Bin 3535 -> 0 bytes Mundus/Icons/Project files/3-4.xcf | Bin 3337 -> 0 bytes Mundus/Icons/Project files/4-4.xcf | Bin 3075 -> 0 bytes Mundus/Icons/Project files/UI_blank_gear.xcf | Bin 0 -> 2700 bytes Mundus/Icons/Project files/UI_blank_hand.xcf | Bin 0 -> 1616 bytes .../Project files/UI_blank_multiplication.xcf | Bin 0 -> 1593 bytes Mundus/Icons/Project files/UI_energy.xcf | Bin 0 -> 5706 bytes Mundus/Icons/Project files/UI_hearth.xcf | Bin 0 -> 5360 bytes Mundus/Icons/Project files/blank_gear.xcf | Bin 2700 -> 0 bytes Mundus/Icons/Project files/blank_hand.xcf | Bin 1616 -> 0 bytes .../Icons/Project files/blank_multiplication.xcf | Bin 1593 -> 0 bytes Mundus/Icons/UI/Energy/energy_0.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_1.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_2.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_3.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_4.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_5.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Energy/energy_6.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Hearth/1-4.png | Bin 4339 -> 0 bytes Mundus/Icons/UI/Hearth/2-4.png | Bin 4339 -> 0 bytes Mundus/Icons/UI/Hearth/3-4.png | Bin 4339 -> 0 bytes Mundus/Icons/UI/Hearth/4-4.png | Bin 4339 -> 0 bytes Mundus/Icons/UI/Hearth/hearth0.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Hearth/hearth1.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Hearth/hearth2.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Hearth/hearth3.png | Bin 0 -> 4339 bytes Mundus/Icons/UI/Hearth/hearth4.png | Bin 0 -> 4339 bytes Mundus/Mundus.csproj | 17 +++++-- Mundus/Service/GameGenerator.cs | 2 +- .../Generators/LandSuperLayerGenerator.cs | 2 +- .../Service/Tiles/Mobs/Controllers/MobFighting.cs | 12 +++-- .../Service/Tiles/Mobs/Controllers/MobMovement.cs | 7 ++- .../Tiles/Mobs/Controllers/MobStatsController.cs | 43 +++++++++++++--- .../Tiles/Mobs/Controllers/MobTerraforming.cs | 33 ++++++++---- Mundus/Service/Tiles/Mobs/LandMobs/Player.cs | 43 ++++++++++++++-- Mundus/Service/Tiles/Mobs/MobTile.cs | 9 ++-- .../Views/Windows/GameWindows/LargeGameWindow.cs | 19 ++++++- .../Views/Windows/GameWindows/MediumGameWindow.cs | 17 ++++++- .../Views/Windows/GameWindows/SmallGameWindow.cs | 22 ++++++-- Mundus/gtk-gui/generated.cs | 32 +++++++++--- Mundus/gtk-gui/gui.stetic | 56 ++++++++++++++++++--- 47 files changed, 261 insertions(+), 63 deletions(-) create mode 100644 Mundus Build 01-05-2020 No1.exe delete mode 100644 Mundus Build 30-04-2020 No3.exe delete mode 100644 Mundus/Icons/Project files/1-4.xcf delete mode 100644 Mundus/Icons/Project files/2-4.xcf delete mode 100644 Mundus/Icons/Project files/3-4.xcf delete mode 100644 Mundus/Icons/Project files/4-4.xcf create mode 100644 Mundus/Icons/Project files/UI_blank_gear.xcf create mode 100644 Mundus/Icons/Project files/UI_blank_hand.xcf create mode 100644 Mundus/Icons/Project files/UI_blank_multiplication.xcf create mode 100644 Mundus/Icons/Project files/UI_energy.xcf create mode 100644 Mundus/Icons/Project files/UI_hearth.xcf delete mode 100644 Mundus/Icons/Project files/blank_gear.xcf delete mode 100644 Mundus/Icons/Project files/blank_hand.xcf delete mode 100644 Mundus/Icons/Project files/blank_multiplication.xcf create mode 100644 Mundus/Icons/UI/Energy/energy_0.png create mode 100644 Mundus/Icons/UI/Energy/energy_1.png create mode 100644 Mundus/Icons/UI/Energy/energy_2.png create mode 100644 Mundus/Icons/UI/Energy/energy_3.png create mode 100644 Mundus/Icons/UI/Energy/energy_4.png create mode 100644 Mundus/Icons/UI/Energy/energy_5.png create mode 100644 Mundus/Icons/UI/Energy/energy_6.png delete mode 100644 Mundus/Icons/UI/Hearth/1-4.png delete mode 100644 Mundus/Icons/UI/Hearth/2-4.png delete mode 100644 Mundus/Icons/UI/Hearth/3-4.png delete mode 100644 Mundus/Icons/UI/Hearth/4-4.png create mode 100644 Mundus/Icons/UI/Hearth/hearth0.png create mode 100644 Mundus/Icons/UI/Hearth/hearth1.png create mode 100644 Mundus/Icons/UI/Hearth/hearth2.png create mode 100644 Mundus/Icons/UI/Hearth/hearth3.png create mode 100644 Mundus/Icons/UI/Hearth/hearth4.png diff --git a/Mundus Build 01-05-2020 No1.exe b/Mundus Build 01-05-2020 No1.exe new file mode 100644 index 0000000..04e6ec1 Binary files /dev/null and b/Mundus Build 01-05-2020 No1.exe differ diff --git a/Mundus Build 30-04-2020 No3.exe b/Mundus Build 30-04-2020 No3.exe deleted file mode 100644 index 825b500..0000000 Binary files a/Mundus Build 30-04-2020 No3.exe and /dev/null differ diff --git a/Mundus/Data/Difficulty.cs b/Mundus/Data/Difficulty.cs index d109ab9..3ab9020 100644 --- a/Mundus/Data/Difficulty.cs +++ b/Mundus/Data/Difficulty.cs @@ -1,11 +1,11 @@ using System; namespace Mundus.Data { public static class Difficulty { - public const int Peaceful = -5; + public const int Peaceful = -10; public const int Easy = 0; public const int Normal = 10; public const int Hard = 40; - public const int Insane = 200; + public const int Insane = 128; public static int SelDifficulty { get; set; } } diff --git a/Mundus/Data/SuperLayers/Mobs/MI.cs b/Mundus/Data/SuperLayers/Mobs/MI.cs index 45cf99a..3e9cdeb 100644 --- a/Mundus/Data/SuperLayers/Mobs/MI.cs +++ b/Mundus/Data/SuperLayers/Mobs/MI.cs @@ -10,8 +10,8 @@ namespace Mundus.Data.Superlayers.Mobs { /// Creates the instances of the universally accessed mobs. /// Note: player has a health of 4 * inventorySize /// - public static void CreateInstances(int inventorySize) { - Player = new Player("player", 4 * inventorySize, 5, LI.Land, inventorySize); + public static void CreateInstances() { + Player = new Player("player", 5, LI.Land); Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenAxe()); Player.Inventory.AppendToHotbar(ToolPresets.GetAWoodenPickaxe()); } diff --git a/Mundus/Data/Windows/WI.cs b/Mundus/Data/Windows/WI.cs index 566539c..3d43480 100644 --- a/Mundus/Data/Windows/WI.cs +++ b/Mundus/Data/Windows/WI.cs @@ -3,7 +3,7 @@ using Mundus.Views.Windows.GameWindows; namespace Mundus.Data.Windows { public static class WI { //stands for Window Instances - public const string BuildName = "Build 30-04-2020 No3"; + public const string BuildName = "Build 01-05-2020 No1"; public static IGameWindow SelWin { get; set; } diff --git a/Mundus/Icons/Project files/1-4.xcf b/Mundus/Icons/Project files/1-4.xcf deleted file mode 100644 index 6d17a43..0000000 Binary files a/Mundus/Icons/Project files/1-4.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/2-4.xcf b/Mundus/Icons/Project files/2-4.xcf deleted file mode 100644 index 79c4283..0000000 Binary files a/Mundus/Icons/Project files/2-4.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/3-4.xcf b/Mundus/Icons/Project files/3-4.xcf deleted file mode 100644 index bebbb65..0000000 Binary files a/Mundus/Icons/Project files/3-4.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/4-4.xcf b/Mundus/Icons/Project files/4-4.xcf deleted file mode 100644 index ea63409..0000000 Binary files a/Mundus/Icons/Project files/4-4.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/UI_blank_gear.xcf b/Mundus/Icons/Project files/UI_blank_gear.xcf new file mode 100644 index 0000000..1269dc8 Binary files /dev/null and b/Mundus/Icons/Project files/UI_blank_gear.xcf differ diff --git a/Mundus/Icons/Project files/UI_blank_hand.xcf b/Mundus/Icons/Project files/UI_blank_hand.xcf new file mode 100644 index 0000000..f972876 Binary files /dev/null and b/Mundus/Icons/Project files/UI_blank_hand.xcf differ diff --git a/Mundus/Icons/Project files/UI_blank_multiplication.xcf b/Mundus/Icons/Project files/UI_blank_multiplication.xcf new file mode 100644 index 0000000..49bdcfe Binary files /dev/null and b/Mundus/Icons/Project files/UI_blank_multiplication.xcf differ diff --git a/Mundus/Icons/Project files/UI_energy.xcf b/Mundus/Icons/Project files/UI_energy.xcf new file mode 100644 index 0000000..28ee5e3 Binary files /dev/null and b/Mundus/Icons/Project files/UI_energy.xcf differ diff --git a/Mundus/Icons/Project files/UI_hearth.xcf b/Mundus/Icons/Project files/UI_hearth.xcf new file mode 100644 index 0000000..c05fd08 Binary files /dev/null and b/Mundus/Icons/Project files/UI_hearth.xcf differ diff --git a/Mundus/Icons/Project files/blank_gear.xcf b/Mundus/Icons/Project files/blank_gear.xcf deleted file mode 100644 index 1269dc8..0000000 Binary files a/Mundus/Icons/Project files/blank_gear.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/blank_hand.xcf b/Mundus/Icons/Project files/blank_hand.xcf deleted file mode 100644 index f972876..0000000 Binary files a/Mundus/Icons/Project files/blank_hand.xcf and /dev/null differ diff --git a/Mundus/Icons/Project files/blank_multiplication.xcf b/Mundus/Icons/Project files/blank_multiplication.xcf deleted file mode 100644 index 49bdcfe..0000000 Binary files a/Mundus/Icons/Project files/blank_multiplication.xcf and /dev/null differ diff --git a/Mundus/Icons/UI/Energy/energy_0.png b/Mundus/Icons/UI/Energy/energy_0.png new file mode 100644 index 0000000..3b0966f Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_0.png differ diff --git a/Mundus/Icons/UI/Energy/energy_1.png b/Mundus/Icons/UI/Energy/energy_1.png new file mode 100644 index 0000000..77c3433 Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_1.png differ diff --git a/Mundus/Icons/UI/Energy/energy_2.png b/Mundus/Icons/UI/Energy/energy_2.png new file mode 100644 index 0000000..9a97592 Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_2.png differ diff --git a/Mundus/Icons/UI/Energy/energy_3.png b/Mundus/Icons/UI/Energy/energy_3.png new file mode 100644 index 0000000..f5660af Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_3.png differ diff --git a/Mundus/Icons/UI/Energy/energy_4.png b/Mundus/Icons/UI/Energy/energy_4.png new file mode 100644 index 0000000..35a1e68 Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_4.png differ diff --git a/Mundus/Icons/UI/Energy/energy_5.png b/Mundus/Icons/UI/Energy/energy_5.png new file mode 100644 index 0000000..6cb0370 Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_5.png differ diff --git a/Mundus/Icons/UI/Energy/energy_6.png b/Mundus/Icons/UI/Energy/energy_6.png new file mode 100644 index 0000000..0c04962 Binary files /dev/null and b/Mundus/Icons/UI/Energy/energy_6.png differ diff --git a/Mundus/Icons/UI/Hearth/1-4.png b/Mundus/Icons/UI/Hearth/1-4.png deleted file mode 100644 index c518bee..0000000 Binary files a/Mundus/Icons/UI/Hearth/1-4.png and /dev/null differ diff --git a/Mundus/Icons/UI/Hearth/2-4.png b/Mundus/Icons/UI/Hearth/2-4.png deleted file mode 100644 index ac1120c..0000000 Binary files a/Mundus/Icons/UI/Hearth/2-4.png and /dev/null differ diff --git a/Mundus/Icons/UI/Hearth/3-4.png b/Mundus/Icons/UI/Hearth/3-4.png deleted file mode 100644 index af0e680..0000000 Binary files a/Mundus/Icons/UI/Hearth/3-4.png and /dev/null differ diff --git a/Mundus/Icons/UI/Hearth/4-4.png b/Mundus/Icons/UI/Hearth/4-4.png deleted file mode 100644 index 3afbd5c..0000000 Binary files a/Mundus/Icons/UI/Hearth/4-4.png and /dev/null differ diff --git a/Mundus/Icons/UI/Hearth/hearth0.png b/Mundus/Icons/UI/Hearth/hearth0.png new file mode 100644 index 0000000..237cae0 Binary files /dev/null and b/Mundus/Icons/UI/Hearth/hearth0.png differ diff --git a/Mundus/Icons/UI/Hearth/hearth1.png b/Mundus/Icons/UI/Hearth/hearth1.png new file mode 100644 index 0000000..b592dda Binary files /dev/null and b/Mundus/Icons/UI/Hearth/hearth1.png differ diff --git a/Mundus/Icons/UI/Hearth/hearth2.png b/Mundus/Icons/UI/Hearth/hearth2.png new file mode 100644 index 0000000..0588c8a Binary files /dev/null and b/Mundus/Icons/UI/Hearth/hearth2.png differ diff --git a/Mundus/Icons/UI/Hearth/hearth3.png b/Mundus/Icons/UI/Hearth/hearth3.png new file mode 100644 index 0000000..9ae9a7b Binary files /dev/null and b/Mundus/Icons/UI/Hearth/hearth3.png differ diff --git a/Mundus/Icons/UI/Hearth/hearth4.png b/Mundus/Icons/UI/Hearth/hearth4.png new file mode 100644 index 0000000..28c245f Binary files /dev/null and b/Mundus/Icons/UI/Hearth/hearth4.png differ diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj index 4e8894b..d89ab1a 100644 --- a/Mundus/Mundus.csproj +++ b/Mundus/Mundus.csproj @@ -56,10 +56,6 @@ - - - - @@ -84,6 +80,18 @@ + + + + + + + + + + + + @@ -182,6 +190,7 @@ + diff --git a/Mundus/Service/GameGenerator.cs b/Mundus/Service/GameGenerator.cs index cfedc13..81fbf8d 100644 --- a/Mundus/Service/GameGenerator.cs +++ b/Mundus/Service/GameGenerator.cs @@ -37,7 +37,7 @@ namespace Mundus.Service { } WI.SelWin.SetDefaults(); - MI.CreateInstances(WI.SelWin.Size); + MI.CreateInstances(); } public static void GameWindowInitialize() { diff --git a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs index d5412f1..ebcfd82 100644 --- a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs +++ b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs @@ -68,7 +68,7 @@ namespace Mundus.Service.SuperLayers.Generators { if (rnd.Next(0, 40 + Difficulty.SelDifficulty) == 1) { tiles[col, row] = StructurePresets.GetALBoulder(); } - if (rnd.Next(0, 10 + Difficulty.SelDifficulty) == 1) { + if (rnd.Next(0, 15 + Difficulty.SelDifficulty) == 1) { tiles[col, row] = StructurePresets.GetALTree(); } } diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs index f5ea123..cf17d37 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobFighting.cs @@ -1,4 +1,5 @@ using System.Linq; +using Mundus.Data; using Mundus.Data.Superlayers.Mobs; using Mundus.Data.Tiles; using Mundus.Service.Tiles.Items; @@ -24,7 +25,7 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { return mob.CurrSuperLayer.GetMobLayerTile(mapYPos, mapXPos) != null; } - + private const double TAKEN_ENERGY_FROM_FIGHTING = 0.5; /// /// The player tries to damage (or kill) mob on the specified map position /// Note: will fail of the player uses an invalid item @@ -34,7 +35,9 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { /// YPos of target mob /// XPos of target mob public static void PlayerTryFight(string selPlace, int selIndex, int mapYPos, int mapXPos) { - MobTryFight(MI.Player, selPlace, selIndex, mapYPos, mapXPos); + if (MobTryFight(MI.Player, selPlace, selIndex, mapYPos, mapXPos)) { + MI.Player.DrainEnergy(TAKEN_ENERGY_FROM_FIGHTING + (Difficulty.SelDifficulty / 80.0)); + } } // Checks if the mob has a proper fighting item selected @@ -48,12 +51,13 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { /// The given mob tries to damage (or kill) mob on the specified map position /// Note: will fail of the given mob uses an invalid item /// + /// true If mob was able to fight false otherwise. /// Mob that will fight /// Inventory place of the selected item (item will be checked if its a valid tool) /// Inventory index of the selected item place (item will be checked if its a valid tool) /// YPos of target mob /// XPos of target mob - public static void MobTryFight(MobTile mob, string selPlace, int selIndex, int mapYPos, int mapXPos) { + public static bool MobTryFight(MobTile mob, string selPlace, int selIndex, int mapYPos, int mapXPos) { if (MobCanFight(mob, selPlace, selIndex, mapYPos, mapXPos)) { Tool selTool = (Tool)Inventory.GetPlayerItem(selPlace, selIndex); MobTile targetMob = mob.CurrSuperLayer.GetMobLayerTile(mapYPos, mapXPos); @@ -74,6 +78,7 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { } else if (mob.GetType() == typeof(Player)) { LogController.AddMessage($"Player did {damagePoints} damage to \"{targetMob.stock_id}\" (H:{targetMob.Health}) "); } + return true; } else if (mob.GetType() == typeof(Player)) { LogController.AddMessage($"You need a tool class of atleast {targetMob.Defense} to fight this mob"); @@ -85,6 +90,7 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { else if (mob.GetType() == typeof(Player)) { // Inventory.GetPlayerItem(selPlace, selIndex).GetType() != typeof(Tool) || ((Tool)Inventory.GetPlayerItem(selPlace, selIndex)).Type != ToolTypes.Sword LogController.AddMessage($"You need a Tool of type {ToolTypes.Sword} to fight with other mobs"); } + return false; } } } diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs index 1a92e51..404e8e3 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobMovement.cs @@ -48,9 +48,14 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { } } } - + + private const double TAKEN_ENERGY_FROM_MOVEMENT = 0.1; public static void MovePlayer(int yPos, int xPos, int mapSize) { ChangeMobPosition(MI.Player, yPos, xPos, mapSize); + + if (MI.Player.YPos == yPos && MI.Player.XPos == xPos) { + MI.Player.DrainEnergy(TAKEN_ENERGY_FROM_MOVEMENT + (Difficulty.SelDifficulty / 80.0)); + } } private static void ChangeMobPosition(MobTile mob, int yPos, int xPos) { diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs index 6a47ca2..7e886cf 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobStatsController.cs @@ -14,14 +14,14 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { /// /// stock_id of hearth icon /// Health bar index - public static string GetPlayerHearth(int index) { - string stock_id = "empty"; + public static string GetPlayerHearthStock(int index) { + string stock_id = "hearth_0"; int diff = GetPlayerHealth() - index * 4; - if (diff >= 4) stock_id = "hearth_4-4"; - else if (diff == 1) stock_id = "hearth_1-4"; - else if (diff == 2) stock_id = "hearth_2-4"; - else if (diff == 3) stock_id = "hearth_3-4"; + if (diff >= 4) stock_id = "hearth_4"; + else if (diff == 1) stock_id = "hearth_1"; + else if (diff == 2) stock_id = "hearth_2"; + else if (diff == 3) stock_id = "hearth_3"; return stock_id; } @@ -40,6 +40,37 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { MI.Player.Heal(healthPoints); } + public static int GetPlayerEnergy() { + return (int)MI.Player.Energy; + } + + /// + /// Returns the stock_id of the energy icon that must be used on the given position of the energy bar + /// + /// stock_id of energy icon + /// Energy bar index + public static string GetPlayerEnergyStock(int index) { + string stock_id = "energy_0"; + + int diff = GetPlayerEnergy() - index * 6; + if (diff >= 6) stock_id = "energy_6"; + else if (diff == 1) stock_id = "energy_1"; + else if (diff == 2) stock_id = "energy_2"; + else if (diff == 3) stock_id = "energy_3"; + else if (diff == 4) stock_id = "energy_4"; + else if (diff == 5) stock_id = "energy_5"; + + return stock_id; + } + + public static void DrainEnergyPlayer(double energyPoints) { + MI.Player.DrainEnergy(energyPoints); + } + + public static void RestoreEnergyPlayer(double energyPoints) { + MI.Player.RestoreEnergy(energyPoints); + } + /// /// Returns the name of the superlayer the player is curently on /// diff --git a/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs b/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs index fc2ea32..59bdb48 100644 --- a/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs +++ b/Mundus/Service/Tiles/Mobs/Controllers/MobTerraforming.cs @@ -1,4 +1,5 @@ using System.Linq; +using Mundus.Data; using Mundus.Data.Superlayers.Mobs; using Mundus.Data.SuperLayers; using Mundus.Data.Tiles; @@ -53,20 +54,25 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { MI.Player.CurrSuperLayer.GetGroundLayerTile(yPos, xPos) != null; } + private const double ENERGY_TAKEN_FROM_DESTROYING = 0.6; private static void PlayerDestroyAt(int mapYPos, int mapXPos, string place, int index) { var selectedTool = (Tool)MI.Player.Inventory.GetItemTile(place, index); // Only shovels can destroy ground layer tiles, but not when there is something over the ground tile if (selectedTool.Type == ToolTypes.Shovel && MI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos) == null) { - PlayerTryDestroyGroundAt(mapYPos, mapXPos, selectedTool); + if (PlayerTryDestroyGroundAt(mapYPos, mapXPos, selectedTool)) { + MI.Player.DrainEnergy(ENERGY_TAKEN_FROM_DESTROYING + (Difficulty.SelDifficulty / 80.0)); + } } // Don't try to destroy structure if there is no structure else if (MI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos) != null) { - PlayerTryDestroyStructureAt(mapYPos, mapXPos, selectedTool); + if (PlayerTryDestroyStructureAt(mapYPos, mapXPos, selectedTool)) { + MI.Player.DrainEnergy(ENERGY_TAKEN_FROM_DESTROYING + (Difficulty.SelDifficulty / 80.0)); + } } } - private static void PlayerTryDestroyGroundAt(int mapYPos, int mapXPos, Tool shovel) { + private static bool PlayerTryDestroyGroundAt(int mapYPos, int mapXPos, Tool shovel) { var selectedGround = MI.Player.CurrSuperLayer.GetGroundLayerTile(mapYPos, mapXPos); // Ground tiles that should be unbreakable have a negative required shovel class @@ -85,17 +91,19 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { MI.Player.Inventory.AppendToItems(new GroundTile(selectedGround)); } - LogController.AddMessage($"Player destroyed \"{selectedGround.stock_id}\" from layer \"{MI.Player.CurrSuperLayer}\" at Y:{mapYPos}, X:{mapXPos}"); + LogController.AddMessage($"Player destroyed \"{selectedGround.stock_id}\" from layer \"{MI.Player.CurrSuperLayer}\" at Y:{mapYPos}, X:{mapXPos}"); + return true; } else if (selectedGround.ReqShovelClass > shovel.Class) { LogController.AddMessage($"Ground \"{selectedGround.stock_id}\" requires minimum shovel class of: {selectedGround.ReqShovelClass}"); } else { // selectedGround.ReqSHovelClass < 0 LogController.AddMessage($"This ground cannot be destroyed."); - } + } + return false; } - private static void PlayerTryDestroyStructureAt(int mapYPos, int mapXPos, Tool tool) { + private static bool PlayerTryDestroyStructureAt(int mapYPos, int mapXPos, Tool tool) { var selStructure = MI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos); if (selStructure.ReqToolType == tool.Type && selStructure.ReqToolClass <= tool.Class) { @@ -122,14 +130,16 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { } else { LogController.AddMessage($"Player did {damagePoints} damage to \"{selStructure.stock_id}\" (H:{selStructure.Health})"); - } + } + return true; } else if (selStructure.ReqToolType != tool.Type) { LogController.AddMessage($"Structure \"{selStructure.stock_id}\" requires tool type: {selStructure.ReqToolType}"); } else { // selStructure.ReqToolClass > tool.Class LogController.AddMessage($"Structure \"{selStructure.stock_id}\" requires minimum tool class of: {selStructure.ReqToolClass}"); - } + } + return false; } // Ground can be placed if there isnt a structure on an empty ground layer spot @@ -138,10 +148,12 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { MI.Player.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) == null; } + private const double ENERGY_TAKEN_FROM_PLACING_GROUND = 0.4; private static void PlayerPlaceGroundAt(int yPos, int xPos, string inventoryPlace, int inventoryIndex) { GroundTile toPlace = (GroundTile)MI.Player.Inventory.GetItemTile(inventoryPlace, inventoryIndex); MI.Player.CurrSuperLayer.SetGroundAtPosition(toPlace, yPos, xPos); + MI.Player.DrainEnergy(ENERGY_TAKEN_FROM_PLACING_GROUND + (Difficulty.SelDifficulty / 80.0)); LogController.AddMessage($"Set ground \"{toPlace.stock_id}\" on layer \"{MI.Player.CurrSuperLayer}\" at Y:{yPos}, X:{xPos}"); } @@ -150,7 +162,8 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { private static bool PlayerCanBuildStructureAt(int yPos, int xPos) { return MI.Player.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) == null; } - + + private const double ENERGY_TAKEN_FROM_BUILDING_STRUCTURE = 0.5; private static void PlayerBuildStructureAt(int yPos, int xPos, string inventoryPlace, int inventoryIndex) { Structure toBuild = (Structure)MI.Player.Inventory.GetItemTile(inventoryPlace, inventoryIndex); @@ -168,6 +181,8 @@ namespace Mundus.Service.Tiles.Mobs.Controllers { LogController.AddMessage($"Set structure \"{toBuild.stock_id}\" on layer \"{MI.Player.CurrSuperLayer}\" at Y:{yPos}, X:{xPos}"); } + + MI.Player.DrainEnergy(ENERGY_TAKEN_FROM_BUILDING_STRUCTURE + (Difficulty.SelDifficulty / 80.0)); } } } diff --git a/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs b/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs index bf102e4..ddec45a 100644 --- a/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs +++ b/Mundus/Service/Tiles/Mobs/LandMobs/Player.cs @@ -1,15 +1,50 @@ -using Mundus.Data.SuperLayers; +using System; +using Mundus.Data.SuperLayers; +using Mundus.Data.Windows; using Mundus.Service.Tiles.Items; namespace Mundus.Service.Tiles.Mobs.LandMobs { - public class Player : MobTile { + public class Player : MobTile { + public double Energy { get; private set; } + /// /// Note: player has an rndMovementQualifier of -1 and drops first item in the hotbar /// - public Player(string stock_id, int health, int defence, ISuperLayer currentSuperLayer, int inventorySize) - : base(stock_id, health, defence, currentSuperLayer, inventorySize, null, -1) + public Player(string stock_id, int defence, ISuperLayer currentSuperLayer) + : base(stock_id, WI.SelWin.Size * 4, defence, currentSuperLayer, WI.SelWin.Size, null, -1) { + this.Energy = WI.SelWin.Size * 6; this.DroppedUponDeath = (Material)this.Inventory.Hotbar[0]; } + + /// + /// Removes energy from player. If energy gets below 0 it will start taking health + /// + /// Energy points to drain from player (will do nothing if value less than 0 + public void DrainEnergy(double value) { + if (value > 0) { + this.Energy -= value; + + if (this.Energy < 0) { + this.TakeDamage((int)Math.Ceiling(Math.Abs(this.Energy))); + this.Energy = 0; + } + } + } + + /// + /// Restores energy from player. If energy is maxed out (WI.SelWin.Size * 6) it starts healing the player + /// + /// Energy points to restore energy (will do nothing if value less than 0 + public void RestoreEnergy(double value) { + if (value > 0) { + this.Energy += value; + + if (this.Energy > WI.SelWin.Size * 6) { + this.Heal((int)Math.Ceiling(Energy - WI.SelWin.Size * 6)); + this.Energy = WI.SelWin.Size * 6; + } + } + } } } diff --git a/Mundus/Service/Tiles/Mobs/MobTile.cs b/Mundus/Service/Tiles/Mobs/MobTile.cs index ed2d5fe..66f6793 100644 --- a/Mundus/Service/Tiles/Mobs/MobTile.cs +++ b/Mundus/Service/Tiles/Mobs/MobTile.cs @@ -1,6 +1,7 @@ using Gtk; using Mundus.Data; using Mundus.Data.SuperLayers; +using Mundus.Data.Windows; using Mundus.Service.Tiles.Items; namespace Mundus.Service.Tiles.Mobs { @@ -34,9 +35,9 @@ namespace Mundus.Service.Tiles.Mobs { } /// - /// Removes health from structure + /// Removes health from mob /// - /// Whether the mobtile can still be damaged + /// Whether the mob can still be damaged public bool TakeDamage(int damagePoints) { this.Health -= damagePoints; return this.Health > 0; @@ -49,8 +50,8 @@ namespace Mundus.Service.Tiles.Mobs { public void Heal(int healthPoints) { this.Health += healthPoints; - if (this.Health > MapSizes.CurrSize / 5 * 4) { - this.Health = MapSizes.CurrSize / 5 * 4; + if (this.Health > WI.SelWin.Size * 4) { + this.Health = WI.SelWin.Size * 4; } } } diff --git a/Mundus/Views/Windows/GameWindows/LargeGameWindow.cs b/Mundus/Views/Windows/GameWindows/LargeGameWindow.cs index abe4913..55e02ea 100644 --- a/Mundus/Views/Windows/GameWindows/LargeGameWindow.cs +++ b/Mundus/Views/Windows/GameWindows/LargeGameWindow.cs @@ -203,11 +203,26 @@ namespace Mundus.Views.Windows.GameWindows { } public void PrintMainMenu() { - //Print lungs + //Print energy + for (int i = 0; i < Size; i++) { + string iName = MobStatsController.GetPlayerEnergyStock(i); + + switch (i) { + case 0: imgS1.SetFromStock(iName, IconSize.Dnd); break; + case 1: imgS2.SetFromStock(iName, IconSize.Dnd); break; + case 2: imgS3.SetFromStock(iName, IconSize.Dnd); break; + case 3: imgS4.SetFromStock(iName, IconSize.Dnd); break; + case 4: imgS5.SetFromStock(iName, IconSize.Dnd); break; + case 5: imgS6.SetFromStock(iName, IconSize.Dnd); break; + case 6: imgS7.SetFromStock(iName, IconSize.Dnd); break; + case 7: imgS8.SetFromStock(iName, IconSize.Dnd); break; + case 8: imgS9.SetFromStock(iName, IconSize.Dnd); break; + } + } //Print health for (int i = 0; i < Size; i++) { - string iName = MobStatsController.GetPlayerHearth(i); + string iName = MobStatsController.GetPlayerHearthStock(i); switch (i) { case 0: imgS10.SetFromStock(iName, IconSize.Dnd); break; diff --git a/Mundus/Views/Windows/GameWindows/MediumGameWindow.cs b/Mundus/Views/Windows/GameWindows/MediumGameWindow.cs index 6f52768..398d059 100644 --- a/Mundus/Views/Windows/GameWindows/MediumGameWindow.cs +++ b/Mundus/Views/Windows/GameWindows/MediumGameWindow.cs @@ -174,11 +174,24 @@ namespace Mundus.Views.Windows.GameWindows { } public void PrintMainMenu() { - //Print lungs + //Print energy + for (int i = 0; i < Size; i++) { + string iName = MobStatsController.GetPlayerEnergyStock(i); + + switch (i) { + case 0: imgS1.SetFromStock(iName, IconSize.Dnd); break; + case 1: imgS2.SetFromStock(iName, IconSize.Dnd); break; + case 2: imgS3.SetFromStock(iName, IconSize.Dnd); break; + case 3: imgS4.SetFromStock(iName, IconSize.Dnd); break; + case 4: imgS5.SetFromStock(iName, IconSize.Dnd); break; + case 5: imgS6.SetFromStock(iName, IconSize.Dnd); break; + case 6: imgS7.SetFromStock(iName, IconSize.Dnd); break; + } + } //Print health for (int i = 0; i < Size; i++) { - string iName = MobStatsController.GetPlayerHearth(i); + string iName = MobStatsController.GetPlayerHearthStock(i); switch (i) { case 0: imgS8.SetFromStock(iName, IconSize.Dnd); break; diff --git a/Mundus/Views/Windows/GameWindows/SmallGameWindow.cs b/Mundus/Views/Windows/GameWindows/SmallGameWindow.cs index bf07401..5af2939 100644 --- a/Mundus/Views/Windows/GameWindows/SmallGameWindow.cs +++ b/Mundus/Views/Windows/GameWindows/SmallGameWindow.cs @@ -170,11 +170,22 @@ namespace Mundus.Views.Windows.GameWindows { /// Prints the lung capacity, health, hotbar items and event log /// public void PrintMainMenu() { - //Print lungs + //Print energy + for (int i = 0; i < Size; i++) { + string iName = MobStatsController.GetPlayerEnergyStock(i); + + switch (i) { + case 0: imgS1.SetFromStock(iName, IconSize.Dnd); break; + case 1: imgS2.SetFromStock(iName, IconSize.Dnd); break; + case 2: imgS3.SetFromStock(iName, IconSize.Dnd); break; + case 3: imgS4.SetFromStock(iName, IconSize.Dnd); break; + case 4: imgS5.SetFromStock(iName, IconSize.Dnd); break; + } + } //Print health for (int i = 0; i < Size; i++) { - string iName = MobStatsController.GetPlayerHearth(i); + string iName = MobStatsController.GetPlayerHearthStock(i); switch (i) { case 0: imgS6.SetFromStock(iName, IconSize.Dnd); break; @@ -365,7 +376,8 @@ namespace Mundus.Views.Windows.GameWindows { protected void OnBtnIG1Clicked(object sender, EventArgs e) { //Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.Hotbar[0] = LandPresets.Boulder(); - MobStatsController.DamagePlayer(1); + //MobStatsController.DamagePlayer(1); + MobStatsController.DrainEnergyPlayer(0.5); //Service.Crafting.CraftingController.FindAvalableItems(); PrintMainMenu(); } @@ -373,8 +385,8 @@ namespace Mundus.Views.Windows.GameWindows { protected void OnBtnIG2Clicked(object sender, EventArgs e) { //Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.Hotbar[1] = new Service.Tiles.Items.Tool("blank_hand", Mundus.Data.Tiles.ToolTypes.Pickaxe, 1); //Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.Hotbar[0] = new Service.Tiles.Items.Tool("blank_hand", Mundus.Data.Tiles.ToolTypes.Axe, 1); - - MobStatsController.HealPlayer(1); + MobStatsController.RestoreEnergyPlayer(0.5); + //MobStatsController.HealPlayer(1); PrintMainMenu(); } diff --git a/Mundus/gtk-gui/generated.cs b/Mundus/gtk-gui/generated.cs index 9bf48c2..67b7372 100644 --- a/Mundus/gtk-gui/generated.cs +++ b/Mundus/gtk-gui/generated.cs @@ -30,14 +30,14 @@ namespace Stetic w1.Add("L_tree", w9); global::Gtk.IconSet w10 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Blanks.empty.png")); w1.Add("empty", w10); - global::Gtk.IconSet w11 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.4-4.png")); - w1.Add("hearth_4-4", w11); - global::Gtk.IconSet w12 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.3-4.png")); - w1.Add("hearth_3-4", w12); - global::Gtk.IconSet w13 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.2-4.png")); - w1.Add("hearth_2-4", w13); - global::Gtk.IconSet w14 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.1-4.png")); - w1.Add("hearth_1-4", w14); + global::Gtk.IconSet w11 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.hearth4.png")); + w1.Add("hearth_4", w11); + global::Gtk.IconSet w12 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.hearth3.png")); + w1.Add("hearth_3", w12); + global::Gtk.IconSet w13 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.hearth2.png")); + w1.Add("hearth_2", w13); + global::Gtk.IconSet w14 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.hearth1.png")); + w1.Add("hearth_1", w14); global::Gtk.IconSet w15 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Materials.L_stick.png")); w1.Add("L_stick", w15); global::Gtk.IconSet w16 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Tools.rock_pickaxe.png")); @@ -78,6 +78,22 @@ namespace Stetic w1.Add("wooden_longsword", w33); global::Gtk.IconSet w34 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.Land.Tools.rock_longsword.png")); w1.Add("rock_longsword", w34); + global::Gtk.IconSet w35 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Hearth.hearth0.png")); + w1.Add("hearth_0", w35); + global::Gtk.IconSet w36 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_0.png")); + w1.Add("energy_0", w36); + global::Gtk.IconSet w37 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_1.png")); + w1.Add("energy_1", w37); + global::Gtk.IconSet w38 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_2.png")); + w1.Add("energy_2", w38); + global::Gtk.IconSet w39 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_3.png")); + w1.Add("energy_3", w39); + global::Gtk.IconSet w40 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_4.png")); + w1.Add("energy_4", w40); + global::Gtk.IconSet w41 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_5.png")); + w1.Add("energy_5", w41); + global::Gtk.IconSet w42 = new global::Gtk.IconSet(global::Gdk.Pixbuf.LoadFromResource("Mundus.Icons.UI.Energy.energy_6.png")); + w1.Add("energy_6", w42); w1.AddDefault(); } } diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic index 2105dd7..093fae4 100644 --- a/Mundus/gtk-gui/gui.stetic +++ b/Mundus/gtk-gui/gui.stetic @@ -52,24 +52,24 @@ resource:Mundus.Icons.UI.Blanks.empty.png - + - resource:Mundus.Icons.UI.Hearth.4-4.png + resource:Mundus.Icons.UI.Hearth.hearth4.png - + - resource:Mundus.Icons.UI.Hearth.3-4.png + resource:Mundus.Icons.UI.Hearth.hearth3.png - + - resource:Mundus.Icons.UI.Hearth.2-4.png + resource:Mundus.Icons.UI.Hearth.hearth2.png - + - resource:Mundus.Icons.UI.Hearth.1-4.png + resource:Mundus.Icons.UI.Hearth.hearth1.png @@ -172,6 +172,46 @@ resource:Mundus.Icons.Land.Tools.rock_longsword.png + + + resource:Mundus.Icons.UI.Hearth.hearth0.png + + + + + resource:Mundus.Icons.UI.Energy.energy_0.png + + + + + resource:Mundus.Icons.UI.Energy.energy_1.png + + + + + resource:Mundus.Icons.UI.Energy.energy_2.png + + + + + resource:Mundus.Icons.UI.Energy.energy_3.png + + + + + resource:Mundus.Icons.UI.Energy.energy_4.png + + + + + resource:Mundus.Icons.UI.Energy.energy_5.png + + + + + resource:Mundus.Icons.UI.Energy.energy_6.png + + -- cgit v1.2.3