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;
- using System.Windows.Media;
- namespace Digger
- {
- //Напишите здесь классы Player, Terrain и другие.
- class Terrain : ICreature
- {
- public CreatureCommand Act(int x, int y)
- {
- return new CreatureCommand()
- {
- DeltaX = 0,
- DeltaY = 0,
- TransformTo = this
- };
- }
- public bool DeadInConflict(ICreature conflictedObject)
- {
- return true;
- }
- public int GetDrawingPriority()
- {
- return 3;
- }
- public string GetImageFileName()
- {
- return "Terrain.png";
- }
- }
- class Player : ICreature
- {
- public string GetImageFileName()
- {
- return "Digger.png";
- }
- public int GetDrawingPriority()
- {
- return 1;
- }
- public CreatureCommand Act(int x, int y)
- {
- var move = new CreatureCommand();
- switch (Game.KeyPressed)
- {
- case Keys.Up:
- if (y >= 0)
- move.DeltaY--;
- break;
- case Keys.Down:
- if (y <= Game.MapHeight)
- move.DeltaY++;
- break;
- case Keys.Right:
- if (x <= Game.MapWidth)
- move.DeltaX++;
- break;
- case Keys.Left:
- if (x >= 0)
- move.DeltaX--;
- break;
- }
- if (x + move.DeltaX >= Game.MapWidth || x + move.DeltaX < 0) move.DeltaX = 0;
- if (y + move.DeltaY >= Game.MapHeight || y + move.DeltaY < 0) move.DeltaY = 0;
- return move;
- }
- public bool DeadInConflict(ICreature conflictedObject)
- {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement