Example #1
0
    public void getFish(GameObject vessel)
    {
        float fish      = 0f;
        float totalFish = 0f;
        bool  enough    = false;

        for (int i = 0; i < boatsFishing.Count; i++)
        {
            VesselBehavior boat = boatsFishing[i].GetComponent <VesselBehavior>();
            totalFish += boat.efficiency * boat.capacity * 15;
        }

        enough = currentResource > totalFish ? true : false;

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

        if (enough)
        {
            float luck = Random.Range(currentResource / carryCapacity, ((currentResource / carryCapacity) + 1f) / 2);

            vesselComp.currentCatch = vesselComp.efficiency * vesselComp.capacity * 15 * luck;
            currentResource        -= vesselComp.currentCatch;//vesselComp.efficiency * vesselComp.capacity * 15;
        }
        else
        {
            vesselComp.currentCatch = currentResource / boatsFishing.Count;
            currentResource        -= currentResource / boatsFishing.Count;
        }

        boatsFishing.Remove(vessel);
    }
Example #2
0
    public mEntity getFish(GameObject vessel)
    {
        float   fish      = 0f;
        float   totalFish = 0f;
        bool    enough    = false;
        mEntity currentCatch;

        for (int i = 0; i < boatsFishing.Count; i++)
        {
            VesselBehavior boat = boatsFishing[i].GetComponent <VesselBehavior>();
            totalFish += boat.efficiency * boat.capacity * 15;
        }

        enough = currentResource > totalFish ? true : false;

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

        if (enough)
        {
            float luck = Random.Range(currentResource / carryCapacity, ((currentResource / carryCapacity) + 1f) / 2);
            vesselComp.entities.GetComponent <Catch>(out currentCatch);

            vesselComp.currentCatch = vesselComp.efficiency * vesselComp.capacity * 15 * luck;

            Catch      catchComp = currentCatch.getComponent <Catch>();
            Efficiency eff       = vesselComp.entities.GetComponent <Efficiency>();
            ByCatch    bycatch   = currentCatch.getComponent <ByCatch>();


            catchComp.size   = vesselComp.efficiency * vesselComp.capacity * 15 * luck;
            bycatch.size     = Random.Range(.1f, .2f) * catchComp.size;
            currentResource -= vesselComp.currentCatch;    //vesselComp.efficiency * vesselComp.capacity * 15;
        }
        else
        {
            vesselComp.entities.GetComponent <Catch>(out currentCatch);

            vesselComp.currentCatch = currentResource / boatsFishing.Count;

            Catch   catchComp = currentCatch.getComponent <Catch>();
            ByCatch bycatch   = currentCatch.getComponent <ByCatch>();
            bycatch.size = Random.Range(.1f, .2f) * catchComp.size;

            vesselComp.currentCatch = currentResource / boatsFishing.Count;
            currentResource        -= currentResource / boatsFishing.Count;
        }

        boatsFishing.Remove(vessel);

        return(currentCatch);
    }