예제 #1
0
    public Waypoint GetRandomWeightedWaypoint()
    {
        float          weightsSum           = WeightsSum;
        float          randomWeight         = Random.Range(0f, weightsSum);
        float          currentWeightsSum    = 0f;
        WaypointRecord randomWeightedRecord = weightedWaypointsRecords.List.Find(record =>
        {
            currentWeightsSum += record.weight;
            return(currentWeightsSum >= randomWeight);
        });

        return(randomWeightedRecord?.waypoint);
    }
예제 #2
0
    public void Remove(Waypoint waypoint)
    {
        WaypointRecord recordToRemove = weightedWaypointsRecords.List.Find(record => record.waypoint == waypoint);

        weightedWaypointsRecords.List.Remove(recordToRemove);
    }