Exemplo n.º 1
0
        public string Visit(Cell component)
        {
            IMovableComponent movable = component.GetMovableOccupant();     // If the cell has an occupant within it, we will display the occupant

            if (movable != null)
            {
                return(movable.Accept(this));        // We will refer to the appropriate implemntation
            }
            return(component.IsTarget()? ".": "_");  // Return that this is an empty cell
        }
Exemplo n.º 2
0
        public PlayerEntity(IMap currentMap, CharacterModel character, ISession session) : base(currentMap)
        {
            Session          = session;
            Character        = character;
            X                = character.MapX;
            Y                = character.MapY;
            MovableComponent = new BasicMovableComponent(this);

            TransferEntity(currentMap);
        }
Exemplo n.º 3
0
            public bool TryMakeMove(IMovableComponent component)
            {
                var parent = component.getParent(); // Checking if a move from the parent is possible

                if (!IsMoveValid(parent))
                {
                    return(false);                      // Return that worker can't move
                }
                var targetCell = NextComponent(parent); // Getting to the next location

                // Return if we can move to the mext cell (i.e. valid) and make move
                if (targetCell.Accept(this))
                {
                    // Downcast the traget Cell to be a cell (since this is the only option to move)
                    m_movementService.MoveComponent(parent, (Cell)targetCell);

                    return(true);
                }
                return(false);
            }
Exemplo n.º 4
0
 public void SetMovableOccupant(IMovableComponent movableOccupant)
 {
     m_movableOccupant = movableOccupant;
 }