/
dashytka
/
Digger
Обзор
Документация
Войти
/
dashytka
/
Digger
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
c
54 строки
1 KB
dashytka
create c#
12 дек 2025, 17:04
12 дек 2025, 17:04
cd30cbd
Код
Авторство
О чём код?
using System; using Avalonia.Input; using Digger.Architecture; namespace Digger; public class Terrain : ICreature { public string GetImageFileName() => "Terrain.png"; public int GetDrawingPriority() => 3; public CreatureCommand Act(int x, int y) { var command = new CreatureCommand { DeltaX = 0, DeltaY = 0 }; return command; } public bool DeadInConflict(ICreature other) => true; } public class Player : ICreature { public string GetImageFileName() => "Digger.png"; public int GetDrawingPriority() => 2; public CreatureCommand Act(int x, int y) { var command = new CreatureCommand { DeltaX = 0, DeltaY = 0 }; if (Game.KeyPressed == Key.Left) command.DeltaX = -1; else if (Game.KeyPressed == Key.Right) command.DeltaX = 1; else if (Game.KeyPressed == Key.Up) command.DeltaY = -1; else if (Game.KeyPressed == Key.Down) command.DeltaY = 1; var nextX = x + command.DeltaX; var nextY = y + command.DeltaY; if (nextX < 0 || nextX >= Game.MapWidth || nextY < 0 || nextY >= Game.MapHeight) { command.DeltaX = 0; command.DeltaY = 0; } return command; } public bool DeadInConflict(ICreature other) => false; }