Exemplo n.º 1
0
 void assignQuota(float unit)
 {
     Debug.Log("Assigning quota...");
     foreach (GameObject harbor in harbors)
     {
         foreach (Transform boat in harbor.transform)
         {
             BoatTileMovement b = boat.gameObject.GetComponent <BoatTileMovement>();
             b.quota = b.capacity * unit;
             b.keepFishingQuota(grid.resourceTiles.ElementAt(UnityEngine.Random.Range(0, grid.resourceTiles.Count)).Key);
         }
     }
 }
Exemplo n.º 2
0
    public float calculateTotalCapacity()
    {
        float capacity = 0f;

        foreach (GameObject harbor in harbors)
        {
            foreach (Transform boat in harbor.transform)
            {
                BoatTileMovement b = boat.gameObject.GetComponent <BoatTileMovement>();
                capacity += b.capacity; // * b.efficiency;
            }
        }

        return(capacity);
    }
Exemplo n.º 3
0
    public void getFish(GameObject vessel, float quota)
    {
        float fish      = 0f;
        float totalFish = 0f;
        bool  enough    = false;

        for (int i = 0; i < boatsFishing.Count; i++)
        {
            BoatTileMovement boat = boatsFishing[i].GetComponent <BoatTileMovement>();

            float maxCatch = boat.efficiency * boat.capacity * 15 > quota ? boat.efficiency * boat.capacity * 15 : quota;
            totalFish += maxCatch;
        }

        enough = currentResource > totalFish ? true : false;

        BoatTileMovement vesselComp = vessel.GetComponent <BoatTileMovement>();

        if (enough)
        {
            float luck         = Random.Range(currentResource / carryCapacity, ((currentResource / carryCapacity) + 1f) / 2);
            float maxCatch     = vesselComp.efficiency * vesselComp.capacity * 15 * luck;
            float allowedCatch = quota;
            vesselComp.currentCatch = quota > maxCatch ? maxCatch : quota;
            currentResource        -= vesselComp.currentCatch;
        }
        else
        {
            float maxCatch     = currentResource / boatsFishing.Count;
            float allowedCatch = quota;
            vesselComp.currentCatch = maxCatch < quota ? maxCatch : quota;
            currentResource        -= vesselComp.currentCatch;
        }

        boatsFishing.Remove(vessel);
    }