예제 #1
0
    void HandleUnlinkRequest(Improbable.Entity.Component.ResponseHandle <Controller.Commands.UnlinkDrone, UnlinkRequest, UnlinkResponse> handle)
    {
        DeliveryInfo droneInfo;

        if (deliveriesMap.TryGetValue(handle.Request.droneId, out droneInfo))
        {
            DestroyDrone(handle.Request.droneId, droneInfo.slot);
            DroneRetrieval(handle.Request.location.ToUnityVector());

            if (droneInfo.returning)
            {
                MetricsWriter.Send(new ControllerMetrics.Update()
                                   .SetFailedReturns(++failedReturns)
                                   .SetCosts(costs)
                                   .SetPenalties(penalties));
            }
            else
            {
                penalties += SimulationSettings.FailedDeliveryPenalty;
                MetricsWriter.Send(new ControllerMetrics.Update()
                                   .SetFailedDeliveries(++failedDeliveries)
                                   .SetCosts(costs)
                                   .SetPenalties(penalties));
            }

            UpdateDroneSlotsAndMap();
        }
        else
        {
            MetricsWriter.Send(new ControllerMetrics.Update().SetUnknownRequests(++unknownRequests));
        }

        handle.Respond(new UnlinkResponse());
    }
예제 #2
0
파일: Bitmap.cs 프로젝트: dtbinh/drone-sim
    private GridType getGridCell(int x, int z)
    {
        GridType gridCell;
        int      index = z * GridWidth + x;

        if (Grid.TryGetValue(index, out gridCell))
        {
            return(gridCell);
        }

        return(GridType.OUT);
    }