Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Решается задача:
- * https://ulearn.me/Course/BasicProgramming/Praktika_Zemlya_i_Digger__b4fba55d-b35d-4366-b3e3-e1d7f53268b1
- * Автор решения: Шарафеев Равиль, 11-808
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Digger {
- public class Player : ICreature {
- public string GetImageFileName() {
- return "Digger.png";
- }
- public int GetDrawingPriority() {
- return 1;
- }
- public CreatureCommand Act(int x, int y) {
- Keys keys = Game.KeyPressed;
- //Если нажата кнопка перемещения и перемещение возможно, то передает изменение нужной координаты
- if (keys == Keys.Left || keys == Keys.A) {
- if (x > 0) {
- return new CreatureCommand() { DeltaX = -1 };
- }
- }
- if (keys == Keys.Up || keys == Keys.W) {
- if (y > 0) {
- return new CreatureCommand() { DeltaY = -1 };
- }
- }
- if (keys == Keys.Right || keys == Keys.D) {
- if (x < Game.MapWidth - 1) {
- return new CreatureCommand() { DeltaX = 1 };
- }
- }
- if (keys == Keys.Down || keys == Keys.S) {
- if (y < Game.MapHeight - 1) {
- return new CreatureCommand() { DeltaY = 1 };
- }
- }
- return new CreatureCommand();
- }
- public bool DeadInConflict(ICreature conflictedObject) {
- return false;
- }
- }
- public class Terrain : ICreature {
- public string GetImageFileName() {
- return "Terrain.png";
- }
- public int GetDrawingPriority() {
- return 0;
- }
- public CreatureCommand Act(int x, int y) {
- return new CreatureCommand();
- }
- //возвращает false, если сталкивается с игроком
- public bool DeadInConflict(ICreature conflictedObject) {
- return
- conflictedObject.GetType() == typeof(Player);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement