/// <summary> /// Get the position relative to the player /// 1: Directly above the obstacle /// 2: Directly below the obstacle /// 3: On the same X and Y as the obstacle /// 4: Left and above the obstacle /// 5: Left and below the obstacle /// 6: Left and on the same Y as the obstacle /// 7: Right and above the obstacle /// 8: Right and above the obstacle /// 9: Right and on the same Y as the obstacle /// 0: Off the screen /// </summary> /// <returns> /// An integer /// </returns> // TODO: TestPlayer ==> Unit (when units have locations) public int GetPositionRelativeToUnit(Unit unit) { Rectangle location = unit.GetFeetHitbox(); // Check if player is on the same X as the obstacle if (location.X < bounds.X + bounds.Width && location.X + location.Width > bounds.X) { // Check if the unit is above, below or over the obstacle if (unit.location.Y + unit.texture.Height < bounds.Y) { return 1; } else if (unit.location.Y < bounds.Y + bounds.Height) { return 2; } else { return 3; } } else if (location.X + location.Width < bounds.X) { // Check if the unit is above, below or over the obstacle if (unit.location.Y + unit.texture.Height < bounds.Y) { return 4; } else if (unit.location.Y > bounds.Y + bounds.Height) { return 5; } else { return 6; } } else if (location.X > bounds.X + bounds.Width) { // Check if the unit is above, below or over the obstacle if (unit.location.Y + unit.texture.Height < bounds.Y) { return 7; } else if (unit.location.Y > bounds.Y + bounds.Height) { return 8; } else { return 9; } } return 0; }
public void AddTombstone(Unit enemy) { this.tombstones.AddLast(new Tombstone(enemy)); }
/// <summary> /// Adds a unit to the list of units /// </summary> /// <param name="unitToAdd">The unit to add to the baddieslist</param> public void AddUnit(Unit unitToAdd) { currentLevel.baddies.AddLast(unitToAdd); }
/// <summary> /// Removes the unit from the list of units /// </summary> /// <param name="unitToRemove">The baddie that needs to be removed</param> public void RemoveUnit(Unit unitToRemove) { if (currentLevel.baddies.Contains(unitToRemove)) { currentLevel.baddies.Remove(unitToRemove); } }
public void Hit(Unit source) { if (isHit || isInvunerable) { return; } this.health--; if (this.health < 0) { this.Die(); return; } ResetTongue(); isHit = true; jumping = false; falling = false; fallCount = 0.0; jumpCount = 0.0; if (source.location.X > this.location.X) { //hit left this.currentHitState = HitState.hitLeft; } else { //hit right this.currentHitState = HitState.hitRight; } }