aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-04-29 09:32:35 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-04-29 09:32:35 +0300
commit0959949f6c675cb26b18a36e991d001629d0b266 (patch)
tree3f48618ec8ac92d3d8e412461fef97640dcca048
parent1a5c97cc9435f443065107a70ee51f1d45942435 (diff)
downloadMundus-0959949f6c675cb26b18a36e991d001629d0b266.tar
Mundus-0959949f6c675cb26b18a36e991d001629d0b266.tar.gz
Mundus-0959949f6c675cb26b18a36e991d001629d0b266.zip
Implimented difficulty (changes map geenration rates). Updated executable.
-rw-r--r--Mundus Build 29-04-2020 No2.exe (renamed from Mundus Build 29-04-2020 No1.exe)bin954368 -> 955904 bytes
-rw-r--r--Mundus/Data/Difficulty.cs12
-rw-r--r--Mundus/Data/Tiles/ToolTypes.cs6
-rw-r--r--Mundus/Data/Windows/WI.cs2
-rw-r--r--Mundus/Mundus.csproj1
-rw-r--r--Mundus/Service/GameGenerator.cs15
-rw-r--r--Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs10
-rw-r--r--Mundus/Views/Windows/NewGameWindow.cs20
-rw-r--r--Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs5
-rw-r--r--Mundus/gtk-gui/gui.stetic5
10 files changed, 68 insertions, 8 deletions
diff --git a/Mundus Build 29-04-2020 No1.exe b/Mundus Build 29-04-2020 No2.exe
index d60c607..df4db7d 100644
--- a/Mundus Build 29-04-2020 No1.exe
+++ b/Mundus Build 29-04-2020 No2.exe
Binary files differ
diff --git a/Mundus/Data/Difficulty.cs b/Mundus/Data/Difficulty.cs
new file mode 100644
index 0000000..d109ab9
--- /dev/null
+++ b/Mundus/Data/Difficulty.cs
@@ -0,0 +1,12 @@
+using System;
+namespace Mundus.Data {
+ public static class Difficulty {
+ public const int Peaceful = -5;
+ public const int Easy = 0;
+ public const int Normal = 10;
+ public const int Hard = 40;
+ public const int Insane = 200;
+
+ public static int SelDifficulty { get; set; }
+ }
+}
diff --git a/Mundus/Data/Tiles/ToolTypes.cs b/Mundus/Data/Tiles/ToolTypes.cs
index 3548af7..1acbb9d 100644
--- a/Mundus/Data/Tiles/ToolTypes.cs
+++ b/Mundus/Data/Tiles/ToolTypes.cs
@@ -1,7 +1,7 @@
namespace Mundus.Data.Tiles {
public static class ToolTypes {
- public static int Shovel = 0;
- public static int Axe = 1;
- public static int Pickaxe = 2;
+ public const int Shovel = 0;
+ public const int Axe = 1;
+ public const int Pickaxe = 2;
}
}
diff --git a/Mundus/Data/Windows/WI.cs b/Mundus/Data/Windows/WI.cs
index 71f24d4..a0ed399 100644
--- a/Mundus/Data/Windows/WI.cs
+++ b/Mundus/Data/Windows/WI.cs
@@ -2,7 +2,7 @@
namespace Mundus.Data.Windows {
public static class WI { //stands for Window Instances
- public const string BuildName = "Build 29-04-2020 No1";
+ public const string BuildName = "Build 29-04-2020 No2";
public static IGameWindow SelWin { get; set; }
diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj
index 4f4c787..f3af57b 100644
--- a/Mundus/Mundus.csproj
+++ b/Mundus/Mundus.csproj
@@ -151,6 +151,7 @@
<Compile Include="Service\Mobs\Controllers\MobStatsController.cs" />
<Compile Include="Service\Mobs\Controllers\MobTerraforming.cs" />
<Compile Include="Service\Mobs\LandMobs\Player.cs" />
+ <Compile Include="Data\Difficulty.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\" />
diff --git a/Mundus/Service/GameGenerator.cs b/Mundus/Service/GameGenerator.cs
index 61c08e9..94e26fe 100644
--- a/Mundus/Service/GameGenerator.cs
+++ b/Mundus/Service/GameGenerator.cs
@@ -46,5 +46,20 @@ namespace Mundus.Service {
WI.SelWin.PrintMainMenu();
WI.SelWin.Show();
}
+
+ /// <summary>
+ /// Sets the game difficulty (that affects map generation).
+ /// </summary>
+ /// <param name="value">Must be "peaceful", "easy", "normal", "hard" or "insane"</param>
+ public static void SetDifficulty(string value) {
+ switch(value.ToLower()) {
+ case "peaceful": Difficulty.SelDifficulty = Difficulty.Peaceful; break;
+ case "easy": Difficulty.SelDifficulty = Difficulty.Easy; break;
+ case "normal": Difficulty.SelDifficulty = Difficulty.Normal; break;
+ case "hard": Difficulty.SelDifficulty = Difficulty.Hard; break;
+ case "insane": Difficulty.SelDifficulty = Difficulty.Insane; break;
+ default: throw new ArgumentException($"Invalid difficulty value {value}. Must be \"peaceful\", \"easy\", \"normal\", \"hard\" or \"insane\"");
+ }
+ }
}
}
diff --git a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
index d34bd9a..7644958 100644
--- a/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
+++ b/Mundus/Service/SuperLayers/Generators/LandSuperLayerGenerator.cs
@@ -1,4 +1,5 @@
using System;
+using Mundus.Data;
using Mundus.Data.Superlayers.Mobs;
using Mundus.Data.SuperLayers;
using Mundus.Service.Mobs.LandMobs;
@@ -29,7 +30,7 @@ namespace Mundus.Service.SuperLayers.Generators {
MI.Player.XPos = y;
tiles[y, x] = MI.Player;
}
- else if (rnd.Next(0, 20) == 1) {
+ else if (rnd.Next(0, 20 + Difficulty.SelDifficulty) == 1) {
tiles[y, x] = LandMobsPresets.GetACow();
tiles[y, x].YPos = y;
tiles[y, x].XPos = x;
@@ -46,7 +47,8 @@ namespace Mundus.Service.SuperLayers.Generators {
for(int col = 0; col < size; col++) {
for(int row = 0; row < size; row++) {
- if (rnd.Next(0, 200) == 1) {
+ // Holes in the ground should be more common with higher difficulties
+ if (rnd.Next(0, 210 - Difficulty.SelDifficulty) == 1) {
tiles[col, row] = null;
}
else {
@@ -63,10 +65,10 @@ namespace Mundus.Service.SuperLayers.Generators {
for (int col = 0; col < size; col++) {
for (int row = 0; row < size; row++) {
if (LI.Land.GetGroundLayerTile(col, row) != null) {
- if (rnd.Next(0, 50) == 1) {
+ if (rnd.Next(0, 40 + Difficulty.SelDifficulty) == 1) {
tiles[col, row] = StructurePresets.GetALBoulder();
}
- if (rnd.Next(0, 10) == 1) {
+ if (rnd.Next(0, 10 + Difficulty.SelDifficulty) == 1) {
tiles[col, row] = StructurePresets.GetALTree();
}
}
diff --git a/Mundus/Views/Windows/NewGameWindow.cs b/Mundus/Views/Windows/NewGameWindow.cs
index 61999d7..d1e9bec 100644
--- a/Mundus/Views/Windows/NewGameWindow.cs
+++ b/Mundus/Views/Windows/NewGameWindow.cs
@@ -121,5 +121,25 @@ namespace Mundus.Views.Windows {
GameGenerator.GameWindowSizeSetup(gameWindow);
}
+
+ protected void OnRbPeacefulToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("peaceful");
+ }
+
+ protected void OnRbEasyToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("easy");
+ }
+
+ protected void OnRbNormalToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("normal");
+ }
+
+ protected void OnRbHardToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("hard");
+ }
+
+ protected void OnRbInsaneToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("insane");
+ }
}
}
diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
index 81f98a1..13f023a 100644
--- a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
+++ b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
@@ -458,8 +458,13 @@ namespace Mundus.Views.Windows
this.Show();
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
this.rbSmall.Toggled += new global::System.EventHandler(this.OnRbSmallToggled);
+ this.rbPeaceful.Toggled += new global::System.EventHandler(this.OnRbPeacefulToggled);
+ this.rbNormal.Toggled += new global::System.EventHandler(this.OnRbNormalToggled);
this.rbMedium.Toggled += new global::System.EventHandler(this.OnRbMediumToggled);
this.rbLarge.Toggled += new global::System.EventHandler(this.OnRbLargeToggled);
+ this.rbInsane.Toggled += new global::System.EventHandler(this.OnRbInsaneToggled);
+ this.rbHard.Toggled += new global::System.EventHandler(this.OnRbHardToggled);
+ this.rbEasy.Toggled += new global::System.EventHandler(this.OnRbEasyToggled);
this.rbCreative.Toggled += new global::System.EventHandler(this.OnRbCreativeToggled);
this.btnGenerate.Clicked += new global::System.EventHandler(this.OnBtnGenerateClicked);
this.btnBack.Clicked += new global::System.EventHandler(this.OnBtnBackClicked);
diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic
index 5220cf1..9f2ff87 100644
--- a/Mundus/gtk-gui/gui.stetic
+++ b/Mundus/gtk-gui/gui.stetic
@@ -558,6 +558,7 @@
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
<property name="Group">Difficulty</property>
+ <signal name="Toggled" handler="OnRbEasyToggled" />
</widget>
<packing>
<property name="TopAttach">3</property>
@@ -585,6 +586,7 @@
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
<property name="Group">Difficulty</property>
+ <signal name="Toggled" handler="OnRbHardToggled" />
</widget>
<packing>
<property name="TopAttach">3</property>
@@ -612,6 +614,7 @@
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
<property name="Group">Difficulty</property>
+ <signal name="Toggled" handler="OnRbInsaneToggled" />
</widget>
<packing>
<property name="TopAttach">3</property>
@@ -777,6 +780,7 @@
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
<property name="Group">Difficulty</property>
+ <signal name="Toggled" handler="OnRbNormalToggled" />
</widget>
<packing>
<property name="TopAttach">3</property>
@@ -804,6 +808,7 @@
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
<property name="Group">Difficulty</property>
+ <signal name="Toggled" handler="OnRbPeacefulToggled" />
</widget>
<packing>
<property name="TopAttach">3</property>