@@ -31,13 +31,70 @@ public PickUp(Item item, string type, int count)
public Item item;
public string type;
public int count;

public void OnPickup()
{
Random rng = new Random();
bool done = false;

GameData data = Application.GetData();

data.inventory.Add(this.item, this.count);
data.level.pickUps.Remove(this);
while(!done)
{
this.item = ItemLibrary.Get().items[rng.Next(0, ItemLibrary.Get().items.Count)];

//Sequence spawn conditions
if (item.type == "ammo")
{
Console.WriteLine("AMMO FOUND");
//Check if inventory has weapon, if not re-roll
for (int i = 0; i < data.inventory.content.Count; i++)
{
if (data.inventory.content[i].item.type == "weap")
{
Console.WriteLine("WEAPON FOUND");
Weapon temp = (Weapon)data.inventory.content[i].item;

if (temp.ammo == temp.maxAmmo)
continue;

temp.ammo += (int)(temp.clipsize * 1.5);

if (temp.ammo > temp.maxAmmo)
temp.ammo = temp.maxAmmo;

data.inventory.content[i].item = temp;
}
}
}

else if (item.type == "med")
{
//Console.WriteLine("MEDKIT FOUND");
data.combatlog.Add(DateTime.Now.Hour + ":" + DateTime.Now.Minute + " Medkit found. Player health restored");
data.player.health = data.player.maxHealth;
}

else if (item.type == "weap")
{
for (int i = 0; i < data.inventory.content.Count; i++)
{
if (data.inventory.content[i].item.name == this.item.name)
{
//
}
}
}

else
{
data.inventory.Add(this.item, this.count);
}

done = true;
}

data.level.pickUps.Remove(this);
Console.WriteLine("item picked up " + item.name);
}

@@ -45,4 +45,18 @@ public static double Distance(Vector2 a, Vector2 b)

return result;
}

public static Vector2 Equalize(Vector2 a, Vector2 b)
{
//throw new NotImplementedException();

Vector2 result = a;

if (a.x < b.x) result.x = result.x + 1;
if (a.x > b.x) result.x = result.x - 1;
if (a.y < b.y) result.y = result.y + 1;
if (a.y > b.y) result.y = result.y - 1;

return result;
}
}
@@ -11,23 +11,25 @@ public Weapon()
this.name = "base_weap";
this.type = "none";
this.damage = 3;
this.range = 3;
this.range = 20;
this.accuracy = 1;
this.ammo = -1;
this.ammo = 2;
this.clipsize = -1;
this.ammotype = "none";
this.damagetype = "none";
this.penetration = 0;
}

public Weapon(string n, string t, int d, float r, float a, int ammo, int clip, string ammotype, string damagetype, float pen)
public Weapon(string n, string t, int d, float r, float a, int ammo, int maxAmmo, int clip, string ammotype, string damagetype, float pen)
{
this.name = n;
this.type = t;
this.damage = d;
this.range = r;
this.accuracy = a;
this.ammo = ammo;
this.currentammo = 0;
this.maxAmmo = maxAmmo;
this.clipsize = clip;
this.ammotype = ammotype;
this.damagetype = damagetype;
@@ -38,6 +40,8 @@ public Weapon(string n, string t, int d, float r, float a, int ammo, int clip, s
public float range;
public float accuracy;
public int ammo;
public int currentammo;
public int maxAmmo;
public int clipsize;
public string ammotype;
public string damagetype;
@@ -52,6 +56,12 @@ public void Attack()
return;
}

if (currentammo <= 0)
{
Console.WriteLine("no ammo");
return;
}

for (int i = 0; i < data.level.structure.GetLength(0); i++)
{
for (int j = 0; j < data.level.structure.GetLength(1); j++)
@@ -67,6 +77,8 @@ public void Attack()
{
data.combat = false;
}

ammo -= 1;
}
}
}
@@ -86,7 +98,18 @@ public void Attack(Vector2 target)

public void Reload()
{
// TODO implement here
if (ammo <= 0) return;
if (ammo >= clipsize)
{
currentammo = clipsize;
ammo -= clipsize;
}

if (ammo > 0 && ammo < clipsize)
{
currentammo = ammo;
ammo = 0;
}
}

public Actor CheckTarget(Vector2 target)
@@ -98,7 +121,14 @@ public Actor CheckTarget(Vector2 target)
for (int i = 0; i < data.collision.Count; i++)
{
if (data.collision[i].position.x == target.x && data.collision[i].position.y == target.y)
{
{
if ((ConsolePseudoRaycast.CastRay(new Vector2(data.player.position.x, data.player.position.y), new Vector2(target.x, target.y))))
{
//ConsoleView.errorMessage = "target obscured (RayCast)";
Console.WriteLine("target obscured (RayCast)");
return null;
}
/**/
targetExists = true;
actor = data.collision[i];
}
@@ -108,6 +138,7 @@ public Actor CheckTarget(Vector2 target)
{
return actor;
}

return null;
}

Binary file not shown.
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>