using ProjectFighterJet.Drawnings; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectFighterJet.MovementStrategy; public class MoveableStormtrooper : IMoveableObject { private DrawningJet? _drawningjet; public MoveableStormtrooper(DrawningJet drawningjet) { _drawningjet = drawningjet; } public ObjectParameters? GetObjectPosition { get { if (_drawningjet == null || _drawningjet.EntityJet == null || !_drawningjet.GetPosX.HasValue || !_drawningjet.GetPosY.HasValue) { return null; } return new ObjectParameters(_drawningjet.GetPosX.Value, _drawningjet.GetPosY.Value, _drawningjet.GetWidth, _drawningjet.GetHeight); } } public int GetStep => (int)(_drawningjet?.EntityJet?.Step ?? 0); public bool TryMoveObject(MovementDirection direction) { if (_drawningjet == null || _drawningjet.EntityJet == null) { return false; } return _drawningjet.MoveTransport(GetDirectionType(direction)); } /// /// Конвертация из MovementDirection в DirectionType /// /// MovementDirection /// DirectionType private static DirectionType GetDirectionType(MovementDirection direction) { return direction switch { MovementDirection.Left => DirectionType.Left, MovementDirection.Right => DirectionType.Right, MovementDirection.Up => DirectionType.Up, MovementDirection.Down => DirectionType.Down, _ => DirectionType.Unknow, }; } }