aboutsummaryrefslogtreecommitdiff
path: root/Bitspace
diff options
context:
space:
mode:
authorSyndamia <kami02882@gmail.com>2019-05-15 20:38:21 +0300
committerSyndamia <kami02882@gmail.com>2019-05-15 20:38:21 +0300
commitd1d0a12527e7d7c0fa43910499d8cc849f0af7f9 (patch)
treeb5de22fed94e3cd63550a3a922e72b3fb07afed4 /Bitspace
parentae174d115f5139bccbc3362f69902e7f624f221f (diff)
downloadShower-d1d0a12527e7d7c0fa43910499d8cc849f0af7f9.tar
Shower-d1d0a12527e7d7c0fa43910499d8cc849f0af7f9.tar.gz
Shower-d1d0a12527e7d7c0fa43910499d8cc849f0af7f9.zip
Mobs now pick up broken items by them, fixed bug where non player mobs don't treat placed walk over items on top of damaging biomes as safe
Diffstat (limited to 'Bitspace')
-rw-r--r--Bitspace/Bitspace/Mob.cs9
-rw-r--r--Bitspace/Bitspace/Program.cs14
-rw-r--r--Bitspace/Bitspace/Weapon.cs5
-rw-r--r--Bitspace/Game.exebin31232 -> 32768 bytes
4 files changed, 21 insertions, 7 deletions
diff --git a/Bitspace/Bitspace/Mob.cs b/Bitspace/Bitspace/Mob.cs
index 475d83d..387f8e5 100644
--- a/Bitspace/Bitspace/Mob.cs
+++ b/Bitspace/Bitspace/Mob.cs
@@ -107,6 +107,15 @@ namespace Game
Console.WriteLine(rightAngle);
}
+ public void AddItemToInventory(Weapon toAdd)
+ {
+ if (ItemsList.Count(i => i.Name == toAdd.Name) == 1) ItemsList.Single(i => i.Name == toAdd.Name).Amount++;
+ else
+ {
+ ItemsList.Add(new Weapon(toAdd.Name, toAdd.MaxHealth, toAdd.HealthDamage, toAdd.BreakDamage, toAdd.SkinLeft, toAdd.SkinRight, toAdd.SkinUp, toAdd.SkinDown, toAdd.Color, toAdd.Placable, toAdd.WalkOver, toAdd.Amount));
+ }
+ }
+
public string Stats()
{
return $"{Name} | Health: {Health} | Armour: {Armour} | Air: {new string('O', LungCapacity)}\r\nX: {XPos} | Y: {YPos}";
diff --git a/Bitspace/Bitspace/Program.cs b/Bitspace/Bitspace/Program.cs
index 7156953..40672b2 100644
--- a/Bitspace/Bitspace/Program.cs
+++ b/Bitspace/Bitspace/Program.cs
@@ -32,8 +32,8 @@ namespace Game
private static Dictionary<string, Weapon> itemDict = new Dictionary<string, Weapon>()
{
{ "Stick", new Weapon("Stick", 3, 5, 1, '-', '|', false, false, 1) },
- { "Wall", new Weapon("Wall", 10, 3, 0, 'i', ConsoleColor.Yellow, true, false, 20) },
- { "Bridge", new Weapon("Bridge", 2, 1, 0, 'H', ConsoleColor.Cyan, true, true, 15) }
+ { "Wall", new Weapon("Wall", 10, 3, 0, 'i', ConsoleColor.Yellow, true, false, 120) },
+ { "Bridge", new Weapon("Bridge", 2, 1, 0, 'H', ConsoleColor.Cyan, true, true, 120) }
};
private static Dictionary<string, ConsoleKey> keyBindingsDict = new Dictionary<string, ConsoleKey>()
@@ -158,7 +158,7 @@ namespace Game
{
int movementChooser = rndDirection.Next(20); //number is bigger than cases, so mob has a higher chance of staying at the same place rather than movning
- if (biomeDict.Values.Where(b => b.Floor == map[mob.YPos][mob.XPos]).Single().Damage > 0)
+ if (biomeDict.Values.Where(b => b.Floor == map[mob.YPos][mob.XPos]).Single().Damage > 0 && !objectMapObjectsInfo.Any(o => o.XPos == mob.XPos && o.YPos == mob.YPos && o.WalkOver))
{
//this so if a mob is presented with more than one viable option, it doesn't always do the same thing
byte[] randomOrder = new byte[] { 1, 2, 3, 4};
@@ -191,10 +191,10 @@ namespace Game
switch (movementChooser)
{
- case 1: if (mob.YPos > 0 && objectMap[mob.YPos - 1][mob.XPos] == '\0') mob.YPos--; break;
- case 2: if (mob.YPos < map.Length - 1 && objectMap[mob.YPos + 1][mob.XPos] == '\0') mob.YPos++; break;
- case 3: if (mob.XPos > 0 && objectMap[mob.YPos][mob.XPos - 1] == '\0') mob.XPos--; break;
- case 4: if (mob.XPos < map.Length * 2 - 1 && objectMap[mob.YPos][mob.XPos + 1] == '\0') mob.XPos++; break;
+ case 1: if (mob.YPos > 0 && (objectMap[mob.YPos - 1][mob.XPos] == '\0' || objectMapObjectsInfo.Single(o => o.XPos == mob.XPos && o.YPos == mob.YPos - 1).WalkOver)) mob.YPos--; break;
+ case 2: if (mob.YPos < map.Length - 1 && (objectMap[mob.YPos + 1][mob.XPos] == '\0' || objectMapObjectsInfo.Single(o => o.XPos == mob.XPos && o.YPos == mob.YPos + 1).WalkOver)) mob.YPos++; break;
+ case 3: if (mob.XPos > 0 && (objectMap[mob.YPos][mob.XPos - 1] == '\0' || objectMapObjectsInfo.Single(o => o.XPos == mob.XPos - 1 && o.YPos == mob.YPos).WalkOver)) mob.XPos--; break;
+ case 4: if (mob.XPos < map.Length * 2 - 1 && (objectMap[mob.YPos][mob.XPos + 1] == '\0' || objectMapObjectsInfo.Single(o => o.XPos == mob.XPos + 1 && o.YPos == mob.YPos).WalkOver)) mob.XPos++; break;
}
}
}
diff --git a/Bitspace/Bitspace/Weapon.cs b/Bitspace/Bitspace/Weapon.cs
index 5f73021..7769847 100644
--- a/Bitspace/Bitspace/Weapon.cs
+++ b/Bitspace/Bitspace/Weapon.cs
@@ -12,6 +12,7 @@ namespace Game
private int yPos;
private string name;
+ private int maxHealth;
private int health;
private ushort healthDamage;
@@ -81,6 +82,8 @@ namespace Game
if (fightingMob.Name == "Player") obj.BrokenByPlayer = true;
obj.Health -= breakDamage;
+
+ if (obj.Health <= 0) fightingMob.AddItemToInventory(obj);
}
}
}
@@ -133,6 +136,7 @@ namespace Game
public Weapon(string name, int health, ushort healthDamage, ushort breakDamage, char skinLeft, char skinRight, char skinUp, char skinDown, ConsoleColor color, bool placable, bool walkOver, byte amount, int xPos, int yPos)
{
Health = health;
+ MaxHealth = Health;
HealthDamage = healthDamage;
BreakDamage = breakDamage;
SkinLeft = skinLeft;
@@ -163,5 +167,6 @@ namespace Game
public int Health { get => health; set => health = value; }
public ushort BreakDamage { get => breakDamage; set => breakDamage = value; }
public bool WalkOver { get => walkOver; set => walkOver = value; }
+ public int MaxHealth { get => maxHealth; set => maxHealth = value; }
}
}
diff --git a/Bitspace/Game.exe b/Bitspace/Game.exe
index 1636066..0b84f12 100644
--- a/Bitspace/Game.exe
+++ b/Bitspace/Game.exe
Binary files differ