Archive Browser
Download aitest.zip, last updated 19/06/2010 (11.27 KB)
Download- md5: 9764f053887f43bd6b0b57f7db7496fa
using System;
using System.Drawing;
namespace AiTest
{
abstract class Sprite
{
#region Public Abstract Methods
public abstract void Move();
#endregion Public Abstract Methods
#region Public Methods
public Tile GetAdjacentTile(Direction direction)
{
Tile result;
switch (direction)
{
case Direction.Up:
result = this.Map.Tiles[this.Location.X, this.Location.Y - 1];
break;
case Direction.Left:
result = this.Map.Tiles[this.Location.X + 1, this.Location.Y];
break;
case Direction.Down:
result = this.Map.Tiles[this.Location.X, this.Location.Y + 1];
break;
case Direction.Right:
result = this.Map.Tiles[this.Location.X - 1, this.Location.Y];
break;
default:
throw new ArgumentException();
}
return result;
}
public Direction GetNewDirection(Direction turnDirection)
{
Direction result;
switch (turnDirection)
{
case Direction.Left:
result = this.Direction - 1;
if (result < Direction.Up)
result = Direction.Right;
break;
case Direction.Right:
result = this.Direction + 1;
if (result > Direction.Right)
result = Direction.Up;
break;
default:
throw new ArgumentException();
}
return result;
}
#endregion Public Methods
#region Public Properties
public abstract Color Color { get; }
public Direction Direction { get; set; }
public Point Location { get; set; }
public Map Map { get; set; }
#endregion Public Properties
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate