Skip to content

Commit

Permalink
resolving pr issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Perdue committed Mar 14, 2022
1 parent d13be7e commit 77a19ca
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 128 deletions.
52 changes: 22 additions & 30 deletions Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public Push(int x, int y)
public int Y { get; set; }
public int currX { get; set; }
public int currY { get; set; }
public bool isPushed() { return !(X == 0 && Y == 0); }
public void reset() { X = 0; Y = 0; currX = 1; currY = 1; }
public void setPush(int x, int y)
public bool IsPushed() { return !(X == 0 && Y == 0); }
public void Reset() { X = 0; Y = 0; currX = 1; currY = 1; }
public void SetPush(int x, int y)
{
X = x;
Y = y;
Expand All @@ -40,15 +40,15 @@ public void setPush(int x, int y)
}
}

public void doneXPush()
public void DoneXPush()
{
if (currX < 0) { currX--; } else { currX++; }
}
public void doneYPush()
public void DoneYPush()
{
if (currY < 0) { currY--; } else { currY++; }
}
public void checkPush()
public void CheckPush()
{
if (Math.Abs(currX) == Math.Abs(X))
{
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Character : GameObject
public Character()
{
soundDone = new Timer(0.25f);
soundDone.OnTick += soundCooldown;
soundDone.OnTick += SoundCooldown;
soundDone.Loop = false;
}

Expand Down Expand Up @@ -136,36 +136,28 @@ public float[] mouseDirection()
var mouseTile = Scene.GridToTileLocation(gridPos);
var currentTile = Scene.GridToTileLocation(Position);
if (currentTile.X - mouseTile.X > 0)
{
direction[0] = 1;
}
if (currentTile.X - mouseTile.X < 0)
{
direction[0] = -1;
}
if (currentTile.Y - mouseTile.Y > 0)
{
direction[1] = 1;
}
if (currentTile.Y - mouseTile.Y < 0)
{
direction[1] = -1;
}
return direction;
}


public void PushSelf(int x, int y)
{
pushStats.setPush(x, y);
pushStats.SetPush(x, y);
}

public void soundCooldown()
public void SoundCooldown()
{
soundPlaying = false;
}

public void onDamage(float damage, float[] attackDirection, int pushAmt)
public void OnDamage(float damage, float[] attackDirection, int pushAmt)
{
health -= damage;
PushSelf(-(int)(attackDirection[0] * pushAmt), -(int)(attackDirection[1] * pushAmt));
Expand All @@ -179,7 +171,7 @@ public void onDamage(float damage, float[] attackDirection, int pushAmt)
}
}

public void scanAndPickUpEntities()
public void ScanAndPickUpEntities()
{
var entities = Scene.GameObjects.Where(x => x is Entity).ToList();
foreach (Entity entity in entities)
Expand Down Expand Up @@ -207,42 +199,42 @@ public override void Update(GameTime delta)
soundDone.Update(delta);
// Code to pick up entities
if (weapon == null)
scanAndPickUpEntities();
ScanAndPickUpEntities();

// Code to move/push
pushStats.checkPush();
if (pushStats.isPushed())
pushStats.CheckPush();
if (pushStats.IsPushed())
{
pushEffect(time);
PushEffect(time);
} else
{
attacking = false;
}
}

public void pushEffect(float time)
public void PushEffect(float time)
{
pushStats.checkPush();
if (pushStats.isPushed() == true)
pushStats.CheckPush();
if (pushStats.IsPushed() == true)
{
float xPushAmt = 0;
float yPushAmt = 0;
if (pushStats.X != 0)
{
xPushAmt = pushStats.currX * time * speed;
pushStats.doneXPush();
pushStats.DoneXPush();
}
if (pushStats.Y != 0)
{
yPushAmt = pushStats.currY * time * speed;
pushStats.doneYPush();
pushStats.DoneYPush();
}
if (attacking)
{
if (!weapon.checkAttack(new Vector2(Position.X + xPushAmt, Position.Y + yPushAmt),!isEnemy))
if (!weapon.CheckAttack(new Vector2(Position.X + xPushAmt, Position.Y + yPushAmt),!isEnemy))
{
attacking = false;
pushStats.reset();
pushStats.Reset();
}
}
Position = new Vector2(Position.X + xPushAmt, Position.Y + yPushAmt);
Expand Down
18 changes: 9 additions & 9 deletions Characters/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ private void newPath(Point destination, Point currentTile)
}
}

private bool playerInView(int distance, bool flag)
private bool playerInView(int distance, bool checkPixels)
{
Point playerTile = Scene.GridToTileLocation(player.Position);
Point currentTile = Scene.GridToTileLocation(Position);
if (flag)
if (checkPixels)
{
playerTile = new Point((int)player.Position.X, (int)player.Position.Y);
currentTile = new Point((int)Position.X, (int)Position.Y);
Expand All @@ -304,7 +304,7 @@ private void createPath()
}
}

public float[] playerDirection()
public float[] PlayerDirection()
{
var direction = new float[2] { 0, 0 };
var playerTile = Scene.GridToTileLocation(player.Position);
Expand All @@ -330,11 +330,11 @@ public float[] playerDirection()

private void attack()
{
if (playerInView(37,true) && player.pushStats.isPushed() == false && player.attacking == false && !attacking)
if (playerInView(37,true) && player.pushStats.IsPushed() == false && player.Attacking == false && !attacking)
{
if (weapon != null)
{
attackDirection = playerDirection();
attackDirection = PlayerDirection();
weapon.Attack(false, false);
}
}
Expand All @@ -343,12 +343,12 @@ private void attack()
private void heavyAttack()
{

if (playerInView(120, true) && player.pushStats.isPushed() == false && player.attacking == false)
if (playerInView(120, true) && player.pushStats.IsPushed() == false && player.Attacking == false)
{
if (weapon != null)
{
attacking = true;
float[] prepareDirection = playerDirection();
float[] prepareDirection = PlayerDirection();
float xMovement = -prepareDirection[0];
float yMovement = -prepareDirection[1];
Position = new Vector2(Position.X + xMovement, Position.Y + yMovement);
Expand All @@ -365,7 +365,7 @@ public override void Update(GameTime delta)
{
TileEngine.Instance.Sound.PlaySound(TileEngine.Instance.Sound.LoadSound("Sound/enemyDeath.wav"));
Scene = null;
player.score += scoreValue;
player.Score += scoreValue;
}
else
{
Expand All @@ -388,7 +388,7 @@ public override void Update(GameTime delta)

sprite.Rotation = angleA;
}
if (!pushStats.isPushed() && attacking)
if (!pushStats.IsPushed() && attacking)
{
attacking = false;
}
Expand Down
Loading

0 comments on commit 77a19ca

Please sign in to comment.