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.Threading.Tasks;
- using System.Windows.Forms;
- namespace Digger
- {
- public enum DrawPriority
- {
- Player = 1,
- Terrain = 2
- };
- public class Terrain : ICreature
- {
- public CreatureCommand Act(int x, int y)
- {
- return new CreatureCommand();
- }
- public bool DeadInConflict(ICreature conflictedObject)
- {
- return true;
- }
- public int GetDrawingPriority()
- {
- return (int)DrawPriority.Terrain;
- }
- public string GetImageFileName()
- {
- return "Terrain.png";
- }
- }
- public class Player : ICreature
- {
- public CreatureCommand Act(int x, int y)
- {
- var deltaX = 0;
- var deltaY = 0;
- if (Game.KeyPressed == Keys.Up)
- deltaY -= 1;
- if (Game.KeyPressed == Keys.Down)
- deltaY += 1;
- if (Game.KeyPressed == Keys.Right)
- deltaX += 1;
- if (Game.KeyPressed == Keys.Left)
- deltaX -= 1;
- var newX = x + deltaX;
- var newY = y + deltaY;
- if (newX >= Game.MapWidth || newX < 0)
- deltaX = 0;
- if (newY >= Game.MapHeight || newY < 0)
- deltaY = 0;
- return new CreatureCommand
- {
- DeltaX = deltaX,
- DeltaY = deltaY
- };
- }
- public bool DeadInConflict(ICreature conflictedObject)
- {
- return false;
- }
- public int GetDrawingPriority()
- {
- return (int)DrawPriority.Player;
- }
- public string GetImageFileName()
- {
- return "Digger.png";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement