Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
- namespace Quest
- {
- abstract class Weapon : Mover
- {
- // protected Game game;
- private bool pickedUp;
- public bool PickedUp { get { return pickedUp; } }
- //private Point Location { get { return location; } }
- public Weapon(Game game, Point location) : base(game, location)
- {
- //this.game = game;
- //this.location = location;
- pickedUp = false;
- }
- public void PickUpWeapon() { pickedUp = true; }
- public abstract string Name { get; }
- public abstract void Attack(Direction direction, Random random);
- protected bool DamageEnemy(Direction direction, int radius,
- int damage, Random random)
- {
- Point target = game.PlayerLocation;
- for (int distance = 0; distance < radius; distance++)
- {
- foreach (Enemy enemy in game.Enemies)
- {
- if (Nearby(enemy.Location, target, radius))
- {
- enemy.Hit(damage, random);
- return true;
- }
- }
- target = Move(direction, target, game.Boundaries);
- }
- return false;
- }
- public Point Move(Direction direction, Point target, Rectangle boundaries) {
- Point newLocation = target;
- /*
- switch (direction) {
- case Direction.Up:
- if (newLocation.Y >= boundaries.Top)
- newLocation.Y -= MoveInterval;
- break;
- case Direction.Down:
- if (newLocation.Y + MoveInterval >= boundaries.Bottom)
- newLocation.Y += MoveInterval;
- break;
- case Direction.Left:
- if (newLocation.X - MoveInterval >= boundaries.Left)
- newLocation.X -= MoveInterval;
- break;
- case Direction.Right:
- if (newLocation.X + MoveInterval <= boundaries.Right)
- newLocation.X += MoveInterval;
- break;
- default: break;
- }
- */
- return newLocation; //this is not correct
- }
- public bool Nearby(Point locationToCheck, Point target, int distance)
- {
- if (Math.Abs(target.X - locationToCheck.X) < distance &&
- (Math.Abs(target.Y - locationToCheck.Y) < distance))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement