Exemplo n.º 1
0
        // PRIVATE UTILITIES

        private void ApplyMove(Move move)
        {
            if (move.IsStep())                  // update the board if this unit is moving position
            {
                var origin = World[Unit.Position];
                if (origin.Occupant == Unit)                 // NullReferenceException here indicates a move from a bad position
                {
                    origin.Occupant = null;
                }

                var destination = World[move.Destination];
                destination.Occupant = Unit;
                if (destination.HasObjective())
                {
                    // TODO: refactor into WorldController for mechanical refinement
                    Unit.Owner.TakeObjective(destination.Objective);
                }
            }
            Unit.ApplyMove(move);
        }