public virtual bool Contains(GameObject target) { return target.Velocity.X >= this.Velocity.X && target.Velocity.X <= this.Velocity.X + this.Width && target.Velocity.Y >= this.Velocity.Y && target.Velocity.Y <= this.Velocity.Y + this.Height; }
public virtual bool InAttackRange(GameObject target) { var attackRange1 = ( ((this.Velocity.X + this.Width * 1.1) >= target.Velocity.X) && ((this.Velocity.X + this.Width * 0.9) <= target.Velocity.X)) && ((this.Velocity.Y >= (target.Velocity.Y - this.Height / 2)) && (this.Velocity.Y <= (target.Velocity.Y + target.Height))); var attackRange2 = ( (this.Velocity.X <= (target.Velocity.X + target.Width * 1.1)) && (this.Velocity.X >= (target.Velocity.X + target.Width * 0.9))) && ((this.Velocity.Y >= (target.Velocity.Y - this.Height / 2)) && (this.Velocity.Y <= (target.Velocity.Y + target.Height))); if (target is Enemy) { if (this.SpriteRotation == 0) { return attackRange1; } return attackRange2; } if (target is IPlayer) { return attackRange1 || attackRange2; } return false; }
public void Intersect(GameObject target) { if (this.Velocity.X >= (target.Velocity.X - this.Width - BasicCharacterSpeed) && this.Velocity.X <= target.Velocity.X) { if (this.Velocity.Y < target.Velocity.Y + target.Height && this.Velocity.Y > target.Velocity.Y - this.Height) { this.Directions[0] = BlockedDirections.BlockedRight; } } if (this.Velocity.X <= target.Velocity.X + target.Width + BasicCharacterSpeed && this.Velocity.X >= target.Velocity.X) { if (this.Velocity.Y < target.Velocity.Y + target.Height && this.Velocity.Y > target.Velocity.Y - this.Height) { this.Directions[1] = BlockedDirections.BlockedLeft; } } if (this.Velocity.Y <= (target.Velocity.Y + target.Height + BasicCharacterSpeed) && this.Velocity.Y >= target.Velocity.Y) { if (this.Velocity.X > (target.Velocity.X - this.Width) && this.Velocity.X < (target.Velocity.X + target.Width)) { this.Directions[2] = BlockedDirections.BlockedUp; } } if (this.Velocity.Y >= (target.Velocity.Y - this.Height - BasicCharacterSpeed) && this.Velocity.Y <= target.Velocity.Y) { if (this.Velocity.X > (target.Velocity.X - this.Width) && this.Velocity.X < (target.Velocity.X + target.Width)) { this.Directions[3] = BlockedDirections.BlockedDown; } } }