diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-01 11:21:46 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-01 11:21:46 +0300 |
| commit | e440dc03e118fc24a6625f256e683818451a4c6d (patch) | |
| tree | a5ac7fc2ab256eca0c3ec8050577119b65d665cc | |
| parent | 2303a769b1b8d8f710b1796696117070dc1cb155 (diff) | |
| download | Mundus-e440dc03e118fc24a6625f256e683818451a4c6d.tar Mundus-e440dc03e118fc24a6625f256e683818451a4c6d.tar.gz Mundus-e440dc03e118fc24a6625f256e683818451a4c6d.zip | |
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.
40 files changed, 261 insertions, 63 deletions
diff --git a/Mundus Build 30-04-2020 No3.exe b/Mundus Build 01-05-2020 No1.exe Binary files differindex 825b500..04e6ec1 100644 --- a/Mundus Build 30-04-2020 No3.exe +++ b/Mundus Build 01-05-2020 No1.exe 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
/// </summary> - 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 Binary files differdeleted file mode 100644 index 6d17a43..0000000 --- a/Mundus/Icons/Project files/1-4.xcf +++ /dev/null diff --git a/Mundus/Icons/Project files/2-4.xcf b/Mundus/Icons/Project files/2-4.xcf Binary files differdeleted file mode 100644 index 79c4283..0000000 --- a/Mundus/Icons/Project files/2-4.xcf +++ /dev/null diff --git a/Mundus/Icons/Project files/3-4.xcf b/Mundus/Icons/Project files/3-4.xcf Binary files differdeleted file mode 100644 index bebbb65..0000000 --- a/Mundus/Icons/Project files/3-4.xcf +++ /dev/null diff --git a/Mundus/Icons/Project files/4-4.xcf b/Mundus/Icons/Project files/4-4.xcf Binary files differdeleted file mode 100644 index ea63409..0000000 --- a/Mundus/Icons/Project files/4-4.xcf +++ /dev/null diff --git a/Mundus/Icons/Project files/blank_gear.xcf b/Mundus/Icons/Project files/UI_blank_gear.xcf Binary files differindex 1269dc8..1269dc8 100644 --- a/Mundus/Icons/Project files/blank_gear.xcf +++ b/Mundus/Icons/Project files/UI_blank_gear.xcf diff --git a/Mundus/Icons/Project files/blank_hand.xcf b/Mundus/Icons/Project files/UI_blank_hand.xcf Binary files differindex f972876..f972876 100644 --- a/Mundus/Icons/Project files/blank_hand.xcf +++ b/Mundus/Icons/Project files/UI_blank_hand.xcf diff --git a/Mundus/Icons/Project files/blank_multiplication.xcf b/Mundus/Icons/Project files/UI_blank_multiplication.xcf Binary files differindex 49bdcfe..49bdcfe 100644 --- a/Mundus/Icons/Project files/blank_multiplication.xcf +++ b/Mundus/Icons/Project files/UI_blank_multiplication.xcf diff --git a/Mundus/Icons/Project files/UI_energy.xcf b/Mundus/Icons/Project files/UI_energy.xcf Binary files differnew file mode 100644 index 0000000..28ee5e3 --- /dev/null +++ b/Mundus/Icons/Project files/UI_energy.xcf diff --git a/Mundus/Icons/Project files/UI_hearth.xcf b/Mundus/Icons/Project files/UI_hearth.xcf Binary files differnew file mode 100644 index 0000000..c05fd08 --- /dev/null +++ b/Mundus/Icons/Project files/UI_hearth.xcf diff --git a/Mundus/Icons/UI/Energy/energy_0.png b/Mundus/Icons/UI/Energy/energy_0.png Binary files differnew file mode 100644 index 0000000..3b0966f --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_0.png diff --git a/Mundus/Icons/UI/Energy/energy_1.png b/Mundus/Icons/UI/Energy/energy_1.png Binary files differnew file mode 100644 index 0000000..77c3433 --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_1.png diff --git a/Mundus/Icons/UI/Energy/energy_2.png b/Mundus/Icons/UI/Energy/energy_2.png Binary files differnew file mode 100644 index 0000000..9a97592 --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_2.png diff --git a/Mundus/Icons/UI/Energy/energy_3.png b/Mundus/Icons/UI/Energy/energy_3.png Binary files differnew file mode 100644 index 0000000..f5660af --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_3.png diff --git a/Mundus/Icons/UI/Energy/energy_4.png b/Mundus/Icons/UI/Energy/energy_4.png Binary files differnew file mode 100644 index 0000000..35a1e68 --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_4.png diff --git a/Mundus/Icons/UI/Energy/energy_5.png b/Mundus/Icons/UI/Energy/energy_5.png Binary files differnew file mode 100644 index 0000000..6cb0370 --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_5.png diff --git a/Mundus/Icons/UI/Energy/energy_6.png b/Mundus/Icons/UI/Energy/energy_6.png Binary files differnew file mode 100644 index 0000000..0c04962 --- /dev/null +++ b/Mundus/Icons/UI/Energy/energy_6.png diff --git a/Mundus/Icons/UI/Hearth/2-4.png b/Mundus/Icons/UI/Hearth/2-4.png Binary files differdeleted file mode 100644 index ac1120c..0000000 --- a/Mundus/Icons/UI/Hearth/2-4.png +++ /dev/null diff --git a/Mundus/Icons/UI/Hearth/hearth0.png b/Mundus/Icons/UI/Hearth/hearth0.png Binary files differnew file mode 100644 index 0000000..237cae0 --- /dev/null +++ b/Mundus/Icons/UI/Hearth/hearth0.png diff --git a/Mundus/Icons/UI/Hearth/1-4.png b/Mundus/Icons/UI/Hearth/hearth1.png Binary files differindex c518bee..b592dda 100644 --- a/Mundus/Icons/UI/Hearth/1-4.png +++ b/Mundus/Icons/UI/Hearth/hearth1.png diff --git a/Mundus/Icons/UI/Hearth/hearth2.png b/Mundus/Icons/UI/Hearth/hearth2.png Binary files differnew file mode 100644 index 0000000..0588c8a --- /dev/null +++ b/Mundus/Icons/UI/Hearth/hearth2.png diff --git a/Mundus/Icons/UI/Hearth/3-4.png b/Mundus/Icons/UI/Hearth/hearth3.png Binary files differindex af0e680..9ae9a7b 100644 --- a/Mundus/Icons/UI/Hearth/3-4.png +++ b/Mundus/Icons/UI/Hearth/hearth3.png diff --git a/Mundus/Icons/UI/Hearth/4-4.png b/Mundus/Icons/UI/Hearth/hearth4.png Binary files differindex 3afbd5c..28c245f 100644 --- a/Mundus/Icons/UI/Hearth/4-4.png +++ b/Mundus/Icons/UI/Hearth/hearth4.png 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 @@ <EmbeddedResource Include="Icons\UI\Blanks\blank_hand.png" />
<EmbeddedResource Include="Icons\UI\Blanks\blank_gear.png" />
<EmbeddedResource Include="Icons\UI\Blanks\empty.png" />
- <EmbeddedResource Include="Icons\UI\Hearth\4-4.png" />
- <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\UI\Blanks\blank_multiplication.png" />
<EmbeddedResource Include="Icons\Land\Tools\wooden_axe.png" />
<EmbeddedResource Include="Icons\Land\Tools\wooden_pickaxe.png" />
@@ -84,6 +80,18 @@ <EmbeddedResource Include="Icons\Land\Mobs\L_cow.png" />
<EmbeddedResource Include="Icons\Land\Tools\wooden_longsword.png" />
<EmbeddedResource Include="Icons\Land\Tools\rock_longsword.png" />
+ <EmbeddedResource Include="Icons\UI\Hearth\hearth1.png" />
+ <EmbeddedResource Include="Icons\UI\Hearth\hearth3.png" />
+ <EmbeddedResource Include="Icons\UI\Hearth\hearth2.png" />
+ <EmbeddedResource Include="Icons\UI\Hearth\hearth4.png" />
+ <EmbeddedResource Include="Icons\UI\Hearth\hearth0.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_0.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_1.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_2.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_3.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_4.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_5.png" />
+ <EmbeddedResource Include="Icons\UI\Energy\energy_6.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="gtk-gui\generated.cs" />
@@ -182,6 +190,7 @@ <Folder Include="Service\Tiles\Crafting\" />
<Folder Include="Service\Tiles\Items\Presets\" />
<Folder Include="Views\Windows\GameWindows\" />
+ <Folder Include="Icons\UI\Hearth\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
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; /// <summary> /// 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 { /// <param name="mapYPos">YPos of target mob</param> /// <param name="mapXPos">XPos of target mob</param> 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 /// </summary> + /// <returns><c>true</c> If mob was able to fight <c>false</c> otherwise.</returns> /// <param name="mob">Mob that will fight</param> /// <param name="selPlace">Inventory place of the selected item (item will be checked if its a valid tool)</param> /// <param name="selIndex">Inventory index of the selected item place (item will be checked if its a valid tool)</param> /// <param name="mapYPos">YPos of target mob</param> /// <param name="mapXPos">XPos of target mob</param> - 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 { /// </summary> /// <returns>stock_id of hearth icon</returns> /// <param name="index">Health bar index</param> - 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; + } + + /// <summary> + /// Returns the stock_id of the energy icon that must be used on the given position of the energy bar + /// </summary> + /// <returns>stock_id of energy icon</returns> + /// <param name="index">Energy bar index</param> + 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); + } + /// <summary> /// Returns the name of the superlayer the player is curently on /// </summary> 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; } +
/// <summary>
/// Note: player has an rndMovementQualifier of -1 and drops first item in the hotbar
/// </summary> - 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];
} +
+ /// <summary>
+ /// Removes energy from player. If energy gets below 0 it will start taking health
+ /// </summary>
+ /// <param name="value">Energy points to drain from player (will do nothing if value less than 0</param> + 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; + } + } + }
+
+ /// <summary>
+ /// Restores energy from player. If energy is maxed out (WI.SelWin.Size * 6) it starts healing the player
+ /// </summary>
+ /// <param name="value">Energy points to restore energy (will do nothing if value less than 0</param>
+ 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 { }
/// <summary>
- /// Removes health from structure
+ /// Removes health from mob
/// </summary>
- /// <returns>Whether the mobtile can still be damaged</returns>
+ /// <returns>Whether the mob can still be damaged</returns>
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 /// </summary> 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 @@ <property name="Image">resource:Mundus.Icons.UI.Blanks.empty.png</property> </source> </icon-set> - <icon-set id="hearth_4-4"> + <icon-set id="hearth_4"> <source> - <property name="Image">resource:Mundus.Icons.UI.Hearth.4-4.png</property> + <property name="Image">resource:Mundus.Icons.UI.Hearth.hearth4.png</property> </source> </icon-set> - <icon-set id="hearth_3-4"> + <icon-set id="hearth_3"> <source> - <property name="Image">resource:Mundus.Icons.UI.Hearth.3-4.png</property> + <property name="Image">resource:Mundus.Icons.UI.Hearth.hearth3.png</property> </source> </icon-set> - <icon-set id="hearth_2-4"> + <icon-set id="hearth_2"> <source> - <property name="Image">resource:Mundus.Icons.UI.Hearth.2-4.png</property> + <property name="Image">resource:Mundus.Icons.UI.Hearth.hearth2.png</property> </source> </icon-set> - <icon-set id="hearth_1-4"> + <icon-set id="hearth_1"> <source> - <property name="Image">resource:Mundus.Icons.UI.Hearth.1-4.png</property> + <property name="Image">resource:Mundus.Icons.UI.Hearth.hearth1.png</property> </source> </icon-set> <icon-set id="L_stick"> @@ -172,6 +172,46 @@ <property name="Image">resource:Mundus.Icons.Land.Tools.rock_longsword.png</property> </source> </icon-set> + <icon-set id="hearth_0"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Hearth.hearth0.png</property> + </source> + </icon-set> + <icon-set id="energy_0"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_0.png</property> + </source> + </icon-set> + <icon-set id="energy_1"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_1.png</property> + </source> + </icon-set> + <icon-set id="energy_2"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_2.png</property> + </source> + </icon-set> + <icon-set id="energy_3"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_3.png</property> + </source> + </icon-set> + <icon-set id="energy_4"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_4.png</property> + </source> + </icon-set> + <icon-set id="energy_5"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_5.png</property> + </source> + </icon-set> + <icon-set id="energy_6"> + <source> + <property name="Image">resource:Mundus.Icons.UI.Energy.energy_6.png</property> + </source> + </icon-set> </icon-factory> <widget class="Gtk.Window" id="Mundus.Views.Windows.NewGameWindow" design-size="581 275"> <property name="MemberName" /> |
