Home Game Development Interaction between interfaces with C# Unity

Interaction between interfaces with C# Unity

0
Interaction between interfaces with C# Unity

[ad_1]

I’m making a Mindustry-type prototype. Some block (resembling miners) can output useful resource (with the IOutput interface), some block (resembling containers) can enter these useful resource (with IInput) and a few can do each.

All of them may have the IStorage interface (for storage) with AddToStorage and RemoveFromStorage strategies.

namespace Conveyor
{
    [System.Serializable]
    public class bulkItem
    {
        public int itemCount;
        public int id;

        public bulkItem(int iC, int i)
        {
            itemCount = iC; id = i;
        }
    }

    interface IBlockStorage
    {
        public int maxCapacity {get;}
        public List<bulkItem> gadgets {get; set;}

        public void InitializeStorage();
        public void AddToStorage(bulkItem merchandise);
        public void RemoveFromStorage(bulkItem merchandise);
    }
}

The difficulty is, the place ought to the script for transportation be hooked up?

Should the output blocks actively searches for enter blocks, then use RemoveFromStorage on itself, and AddToStorage on the enter blocks it discovered? Or vice-versa?

Or ought to there be an common InputOutputManager script someplace and remotely use AddToStorage and RemoveFromStorage to these enter/output blocks?

What can be probably the most code-efficient technique of doing this?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here