Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows.Forms;
- namespace Digger
- {
- public class Terrain : ICreature
- {
- public static int DrawingPriority = 1;
- string ICreature.GetImageFileName()
- {
- return "Terrain.png";
- }
- int ICreature.GetDrawingPriority()
- {
- return DrawingPriority;
- }
- CreatureCommand ICreature.Act(int x, int y)
- {
- return new CreatureCommand();
- }
- bool ICreature.DeadInConflict(ICreature conflictedObject)
- {
- return false;
- }
- }
- public class Player : ICreature
- {
- public static int DrawingPriority = 0;
- CreatureCommand ICreature.Act(int x, int y)
- {
- var move = GetMove();
- move.TransformTo = this;
- var isInMapMove = IsInMap(x + move.DeltaX, y + move.DeltaY);
- return isInMapMove ? move : new CreatureCommand();
- }
- private static CreatureCommand GetMove()
- {
- var key = Game.KeyPressed;
- switch (key)
- {
- case Keys.Left:
- return new CreatureCommand {DeltaX = -1};
- case Keys.Right:
- return new CreatureCommand {DeltaX = 1};
- case Keys.Up:
- return new CreatureCommand {DeltaY = -1};
- case Keys.Down:
- return new CreatureCommand {DeltaY = 1};
- default:
- return new CreatureCommand();
- }
- }
- private static bool IsInMap(int x, int y)
- {
- return x < Game.MapWidth && x >= 0 && y < Game.MapHeight && y >= 0;
- }
- bool ICreature.DeadInConflict(ICreature conflictedObject)
- {
- return false;
- }
- string ICreature.GetImageFileName()
- {
- return "Digger.png";
- }
- int ICreature.GetDrawingPriority()
- {
- return DrawingPriority;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement