aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj1
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Game creatures/Animal.cs21
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Game creatures/Creatures.cs14
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Game creatures/Mob.cs39
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Game map/Biome.cs13
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Game map/Map.cs10
-rw-r--r--Bitspace 2.0/Bitspace 2.0/Program.cs4
7 files changed, 89 insertions, 13 deletions
diff --git a/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj b/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj
index 5f5e2e8..d66a26e 100644
--- a/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj
+++ b/Bitspace 2.0/Bitspace 2.0/Bitspace 2.0.csproj
@@ -43,6 +43,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Game creatures\Animal.cs" />
<Compile Include="Game creatures\Creatures.cs" />
<Compile Include="Game map\Biome.cs" />
<Compile Include="Game creatures\Player.cs" />
diff --git a/Bitspace 2.0/Bitspace 2.0/Game creatures/Animal.cs b/Bitspace 2.0/Bitspace 2.0/Game creatures/Animal.cs
new file mode 100644
index 0000000..bdfe09b
--- /dev/null
+++ b/Bitspace 2.0/Bitspace 2.0/Game creatures/Animal.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Bitspace_2._0.Game_creatures {
+ public class Animal : Mob {
+ public Animal(string name, char body, ConsoleColor color, int maxHealth)
+ : base(name, body, color, 20, maxHealth, 10, 0) { }
+
+ public Animal(string name, char body, ConsoleColor color, int maxHealth, int maxLungCapacity)
+ : base(name, body, color, 20, maxHealth, maxLungCapacity, 0) { }
+
+ public Animal(string name, char body, ConsoleColor color, int defaultMovementFactor, int maxHealth, int maxLungCapacity)
+ : base(name, body, color, defaultMovementFactor, maxHealth, maxLungCapacity, 0) { }
+
+ public Animal(string name, char body, ConsoleColor color, int defaultMovementFactor, int maxHealth, int maxLungCapacity, int maxArmour)
+ : base(name, body, color, defaultMovementFactor, maxHealth, maxLungCapacity, maxArmour) { }
+ }
+}
diff --git a/Bitspace 2.0/Bitspace 2.0/Game creatures/Creatures.cs b/Bitspace 2.0/Bitspace 2.0/Game creatures/Creatures.cs
index 025a727..8d81dc6 100644
--- a/Bitspace 2.0/Bitspace 2.0/Game creatures/Creatures.cs
+++ b/Bitspace 2.0/Bitspace 2.0/Game creatures/Creatures.cs
@@ -7,5 +7,19 @@ namespace Bitspace_2._0.Game_creatures {
public static Dictionary<string, Player> Players = new Dictionary<string, Player>() {
{ "Player1", new Player("The player", '@', ConsoleColor.White, 10) }
};
+
+ public static Dictionary<string, Animal> Animals = new Dictionary<string, Animal>() {
+ { "Smiley", new Animal("Smiley", 'U', ConsoleColor.Magenta, 5) }
+ };
+
+ public static void DoToAll(Action action) {
+ foreach(var pl in Players.Values) {
+ action.Invoke();
+ }
+ }
+
+ public static void DoToAllNonPlayers(Action action) {
+
+ }
}
}
diff --git a/Bitspace 2.0/Bitspace 2.0/Game creatures/Mob.cs b/Bitspace 2.0/Bitspace 2.0/Game creatures/Mob.cs
index a236046..544e8bd 100644
--- a/Bitspace 2.0/Bitspace 2.0/Game creatures/Mob.cs
+++ b/Bitspace 2.0/Bitspace 2.0/Game creatures/Mob.cs
@@ -45,6 +45,45 @@ namespace Bitspace_2._0.Game_creatures {
}
}
+ public void AffectedByBiome(Biome currBiome) {
+ this.Heal(currBiome.HealPoints);
+
+ if (this.CanSuffocate()) this.Suffocate();
+ else this.RecieveDamage(currBiome.DamagePoints);
+ }
+
+ public void Heal(int points) {
+ if (this.Health < this.MaxHealth) {
+ Health += points;
+ if (this.Health > this.MaxHealth) Health = MaxHealth;
+ }
+ }
+
+ public void RecieveDamage(int points) {
+ if (IsAlive()) {
+ if (points > this.Armour / 4) { //all damage under a fourth of the armor doesn't affect mob
+ this.Armour -= 2 / 3 * points;
+ //this.Health -= Math.Ceiling(Convert.ToDecimal(1.0 / 3.0 * points));
+ }
+ }
+ }
+
+ public void Suffocate() {
+ if (this.LungCapacity > 0) {
+ this.LungCapacity--;
+
+ if (this.LungCapacity < 0) this.LungCapacity = 0;
+ }
+ }
+
+ public bool IsAlive() {
+ return (this.Health > 0) ? true : false;
+ }
+
+ public bool CanSuffocate() {
+ return (this.LungCapacity > 0) ? true : false;
+ }
+
public Mob (string name, char body, ConsoleColor color, int maxHealth)
: this(name, body, color, 20, maxHealth, 10, 0) { }
diff --git a/Bitspace 2.0/Bitspace 2.0/Game map/Biome.cs b/Bitspace 2.0/Bitspace 2.0/Game map/Biome.cs
index 550857b..76d2124 100644
--- a/Bitspace 2.0/Bitspace 2.0/Game map/Biome.cs
+++ b/Bitspace 2.0/Bitspace 2.0/Game map/Biome.cs
@@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
namespace Bitspace_2._0.Game_map {
- class Biome {
+ public class Biome {
private string name;
private char ground;
@@ -13,8 +13,8 @@ namespace Bitspace_2._0.Game_map {
public bool Suffocate { get; private set; }
//these values are per game tick / every time they are called
- public int Damage { get; private set; }
- public int Heal { get; private set; }
+ public int DamagePoints { get; private set; }
+ public int HealPoints { get; private set; }
public Biome(string name, char ground, ConsoleColor color) : this(name, ground, color, false, 0, 0) { }
@@ -27,11 +27,8 @@ namespace Bitspace_2._0.Game_map {
this.Ground = ground;
this.Color = color;
this.Suffocate = suffocate;
- this.Damage = damage;
- }
-
- public void AffectMob() {
- //can be finished after implimenting mobs
+ this.DamagePoints = damage;
+ this.HealPoints = heal;
}
public string Name {
diff --git a/Bitspace 2.0/Bitspace 2.0/Game map/Map.cs b/Bitspace 2.0/Bitspace 2.0/Game map/Map.cs
index 7763554..a012185 100644
--- a/Bitspace 2.0/Bitspace 2.0/Game map/Map.cs
+++ b/Bitspace 2.0/Bitspace 2.0/Game map/Map.cs
@@ -62,16 +62,16 @@ namespace Bitspace_2._0.Game_map {
Biome currBiome;
if (randomNumber.Next(4) > 0) { // 3/4 chance that the biome will not hurt and will not suffocate
- currBiome = biomeDB.Values.Where(x => x.Damage == 0).ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.Damage == 0)));
+ currBiome = biomeDB.Values.Where(x => x.DamagePoints == 0).ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.DamagePoints == 0)));
}
else {
if (randomNumber.Next(5) > 0) { // 4/5 chance that the biome will hurt and suffocate
- currBiome = biomeDB.Values.Where(x => x.Damage > 0 && x.Suffocate)
- .ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.Damage > 0 && x.Suffocate)));
+ currBiome = biomeDB.Values.Where(x => x.DamagePoints > 0 && x.Suffocate)
+ .ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.DamagePoints > 0 && x.Suffocate)));
}
else { // 1/5 chance that the biome will hurt but won't suffocate
- currBiome = biomeDB.Values.Where(x => x.Damage > 0 && !x.Suffocate)
- .ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.Damage > 0 && !x.Suffocate)));
+ currBiome = biomeDB.Values.Where(x => x.DamagePoints > 0 && !x.Suffocate)
+ .ElementAt(randomNumber.Next(biomeDB.Values.Count(x => x.DamagePoints > 0 && !x.Suffocate)));
}
}
return currBiome;
diff --git a/Bitspace 2.0/Bitspace 2.0/Program.cs b/Bitspace 2.0/Bitspace 2.0/Program.cs
index 6ac34e0..6cbaf76 100644
--- a/Bitspace 2.0/Bitspace 2.0/Program.cs
+++ b/Bitspace 2.0/Bitspace 2.0/Program.cs
@@ -18,6 +18,10 @@ namespace Bitspace_2._0 {
Creatures.Players["Player1"].InputAction();
}
+ if (gameTick % 2 == 0) {
+ foreach (var currMob in )
+ }
+
Graphics.ReWriteScreen();
}
}