Skip to content
This repository has been archived by the owner on Mar 18, 2019. It is now read-only.

Commit

Permalink
Game Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Dec 13, 2013
1 parent 293b91c commit a794308
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 59 deletions.
36 changes: 35 additions & 1 deletion Game/Units/Types/Ai/Seven/ZackKamakazi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ namespace Game.Units
{
public class ZackKamakazi : Kamakazi
{
const bool near = true;
Unit _target;
int _move;

public ZackKamakazi(string id, StaticModel staticModel) : base(id, staticModel) { }

Expand All @@ -17,9 +19,11 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
if (IsDead == false)
{
// Targeting
if (_target == null || _target.IsDead)
#region Farthest
if (!near && (_target == null || _target.IsDead || _move > 20))
{
float longest = float.MinValue;
_move = 0;
octree.Traverse
(
(Unit current) =>
Expand All @@ -41,10 +45,39 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
}
);
}
#endregion
#region Nearest
else if (near && (_target == null || _target.IsDead || _move > 20))
{
_move = 0;
float nearest = float.MinValue;
octree.Traverse
(
(Unit current) =>
{
if ((current is KillemKamakazi || current is KillemMelee || current is KillemRanged) && !current.IsDead)
{
float length = (current.Position - Position).Length;
if (_target == null || _target.IsDead)
{
_target = current;
nearest = length;
}
else if (length < nearest)
{
_target = current;
nearest = length;
}
}
}
);
}
#endregion
// Attacking
else if (Foundations.Abs((Position - _target.Position).Length) < _attackRange / 2)
{
Attack(octree);
_move = 0;
}
// Moving
else
Expand All @@ -53,6 +86,7 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
Position.X += (direction.X / direction.Length) * MoveSpeed;
Position.Y += (direction.Y / direction.Length) * MoveSpeed;
Position.Z += (direction.Z / direction.Length) * MoveSpeed;
_move++;
}
StaticModel.Orientation.W += .1f;
}
Expand Down
51 changes: 5 additions & 46 deletions Game/Units/Types/Ai/Seven/ZackMelee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ZackMelee : Melee
Unit _target;
float _time = 0;
const float _delay = 4000;
int move;

public ZackMelee(string id, StaticModel staticModel) : base(id, staticModel) { _time = 0; }

Expand All @@ -22,54 +23,10 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
_time += elapsedTime;
if (IsDead == false)
{
// Targeting
/*if (_target == null || _target.IsDead)
{
float shortest = float.MaxValue;
octree.Traverse
(
(Unit current) =>
{
if ((current is KillemKamakazi || current is KillemMelee || current is KillemRanged) && !current.IsDead)
{
if (!(current is KillemKamakazi))
{
float length = (current.Position - Position).Length;
if (_target == null || _target.IsDead)
{
_target = current;
shortest = length;
}
else if (length < shortest)
{
_target = current;
shortest = length;
}
}
else
{
if (_target == null || _target.IsDead)
{
float length = (current.Position - Position).Length;
if (_target == null || _target.IsDead)
{
_target = current;
shortest = length;
}
else if (length < shortest)
{
_target = current;
shortest = length;
}
}
}
}
}
);
}*/
if (_target == null || _target.IsDead)
if (_target == null || _target.IsDead || move > 20)
{
float shortest = float.MaxValue;
move = 0;
octree.Traverse
(
(Unit current) =>
Expand Down Expand Up @@ -120,6 +77,7 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
Color.Red));
if (Attack(_target))
_target = null;
move = 0;
}
// Moving
else if (_time > _delay)
Expand All @@ -128,6 +86,7 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
Position.X += (direction.X / direction.Length) * MoveSpeed;
Position.Y += (direction.Y / direction.Length) * MoveSpeed;
Position.Z += (direction.Z / direction.Length) * MoveSpeed;
move++;
}
this.StaticModel.Orientation.W+=.1f;
}
Expand Down
6 changes: 5 additions & 1 deletion Game/Units/Types/Ai/Seven/ZackRanged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ZackRanged : Ranged
Unit _target;
float _time = 0;
const float _delay = 4000;
int move;

public ZackRanged(string id, StaticModel staticModel) : base(id, staticModel) { _time = 0; }

Expand All @@ -23,8 +24,9 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
if (IsDead == false)
{
// Targeting
if (_target == null || _target.IsDead)
if (_target == null || _target.IsDead || move > 20)
{
move = 0;
float shortest = float.MaxValue;
octree.Traverse
(
Expand Down Expand Up @@ -76,6 +78,7 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
Color.Yellow));
if (Attack(_target))
_target = null;
move = 0;
}
// Moving
else if (_time > _delay)
Expand All @@ -84,6 +87,7 @@ public override void AI(float elapsedTime, OctreeLinked<Unit, string> octree)
Position.X += (direction.X / direction.Length) * MoveSpeed;
Position.Y += (direction.Y / direction.Length) * MoveSpeed;
Position.Z += (direction.Z / direction.Length) * MoveSpeed;
move++;
}
this.StaticModel.Orientation.W+=.1f;
}
Expand Down
6 changes: 3 additions & 3 deletions Game/Units/Types/Kamakazi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public Explosion()

public abstract class Kamakazi : Unit
{
private const int _healthMin = 500;
private const int _healthMin = 700;
private const int _healthMax = 1000;
private const int _damageMin = 500;
private const int _damageMax = 700;
private const int _viewDistanceMin = 1;
private const int _viewDistanceMax = 10000;
private const int _moveSpeedMin = 60;
private const int _moveSpeedMax = 90;
private const int _attackRangeMin = 50;//50;
private const int _attackRangeMax = 70;//70;
private const int _attackRangeMin = 150;
private const int _attackRangeMax = 200;

private bool _exploded;

Expand Down
10 changes: 5 additions & 5 deletions Game/Units/Types/Melee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace Game.Units
{
public abstract class Melee : Unit
{
private const int _healthMin = 250;
private const int _healthMax = 500;
private const int _damageMin = 6;
private const int _damageMax = 12;
private const int _healthMin = 400;
private const int _healthMax = 700;
private const int _damageMin = 10;
private const int _damageMax = 20;
private const int _viewDistanceMin = 1;
private const int _viewDistanceMax = 10000;
private const int _moveSpeedMin = 50;
Expand All @@ -26,7 +26,7 @@ public Melee(string id, StaticModel staticModel) : base(id, staticModel)
_damage = random.Next(_damageMin, _damageMax);
_viewDistance = random.Next(_viewDistanceMin, _viewDistanceMax);
_moveSpeed = random.Next(_moveSpeedMin, _moveSpeedMax) / 20f;
_attackRange = 5;
_attackRange = 60;
}

protected bool Attack(Unit defending)
Expand Down
4 changes: 2 additions & 2 deletions Game/Units/Types/Ranged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public abstract class Ranged : Unit
{
private const int _healthMin = 50;
private const int _healthMax = 100;
private const int _damageMin = 4;
private const int _damageMax = 8;
private const int _damageMin = 3;
private const int _damageMax = 7;
private const int _viewDistanceMin = 1;
private const int _viewDistanceMax = 10000;
private const int _attackRangeMin = 400;
Expand Down
2 changes: 1 addition & 1 deletion SevenEngine/DataStructures/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public void RemoveFirst(Type removal)
newList[i] = _list[i];
_list = newList;
}
for (int i = index; i < _count; i++)
for (int i = index; i < _count - 1; i++)
_list[i] = _list[i + 1];
_count--;
WriterUnlock();
Expand Down

0 comments on commit a794308

Please sign in to comment.