Exemple #1
0
    public void AddFish(FishType type, int count)
    {
        ShipHold found = FindHold(type);

        if (found == null)
        {
            found = GetFirstEmpty();

            if (found == null)
            {
                Debug.Log("Everything is full !!!");
            }
        }

        if (found != null)
        {
            found.Fill(type, count);
        }
    }
Exemple #2
0
    public void PayFish(FishType type, int count)
    {
        int paid = 0;

        for (int i = _holds.Count - 1; i >= 0; i--)
        {
            ShipHold hold = _holds[i];

            if (hold.Contains(type))
            {
                if (hold.fishCount + paid >= count)
                {
                    hold.Remove(count - paid);
                    return;
                }
                else
                {
                    paid += hold.fishCount;
                    hold.RemoveAll();
                }
            }
        }
    }