Esempio n. 1
0
    public bool AddResources(CL_Storage ResourcesToAdd)
    {
        if (IsStorageFull())
        {
            if (ResourceList.Count > 0)
            {
                foreach (var itemToAdd in ResourcesToAdd.ResourceList)
                {
                    CL_Resource ResourceFound = ResourceList.Find(f => f.ResourceName == itemToAdd.ResourceName);

                    if (ResourceFound != null)
                    {
                        ResourceFound.AddResource(itemToAdd);
                        continue;
                    }
                    else
                    {
                        ResourceList.Add(itemToAdd);
                    }
                }
            }
            else
            {
                ResourceList = ResourcesToAdd.ResourceList;
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
Esempio n. 2
0
    public bool HasResource(CL_Storage ResourceToTake)
    {
        if (ResourceList.Count > 0)
        {
            foreach (var itemToTake in ResourceToTake.ResourceList)
            {
                CL_Resource ResourceFound = ResourceList.Find(f => f.ResourceName == itemToTake.ResourceName);

                if (ResourceFound != null)
                {
                    if (ResourceFound.Quantity >= itemToTake.Quantity)
                    {
                        continue;
                    }
                }
                return(false);
            }
            return(true);
        }
        else
        {
            Debug.Log("This is Empty!");
            return(false);
        }
    }
Esempio n. 3
0
    public bool TakeResources(CL_Storage ResourceToTake)
    {
        if (HasResource(ResourceToTake))
        {
            if (ResourceList.Count > 0)
            {
                foreach (var itemToTake in ResourceToTake.ResourceList)
                {
                    CL_Resource ResourceFound = ResourceList.Find(f => f.ResourceName == itemToTake.ResourceName);

                    if (ResourceFound != null)
                    {
                        ResourceFound.TakeResource(itemToTake);
                        if (ResourceFound.Quantity <= 0)
                        {
                            ResourceList.Remove(ResourceFound);
                        }
                        continue;
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
        return(false);
    }
Esempio n. 4
0
    public bool AddResources(CL_Resource ResourceToAdd)
    {
        CL_Storage NewStorage = new CL_Storage(new List <CL_Resource>()
        {
            ResourceToAdd
        });

        return(AddResources(NewStorage));
    }
Esempio n. 5
0
    public bool AddResources(SO_ResourceBase ResourceToAdd)
    {
        CL_Storage NewStorage = new CL_Storage(new List <CL_Resource>()
        {
            new CL_Resource(ResourceToAdd)
        });

        return(AddResources(NewStorage));
    }
Esempio n. 6
0
    public bool HasResource(CL_Resource ResourceToAdd)
    {
        CL_Storage newStorage = new CL_Storage(new List <CL_Resource>()
        {
            ResourceToAdd
        });

        return(HasResource(newStorage));
    }
Esempio n. 7
0
    public bool TakeResources(CL_Resource ResourceToAdd)
    {
        CL_Storage newStorage = new CL_Storage(new List <CL_Resource>()
        {
            ResourceToAdd
        });

        return(TakeResources(newStorage));
    }
Esempio n. 8
0
    public bool AddResources(List <CL_Resource> ResourcesToAdd)
    {
        CL_Storage NewStorage = new CL_Storage(ResourcesToAdd);

        return(AddResources(NewStorage));
    }
Esempio n. 9
0
    public bool HasResource(List <CL_Resource> ResourcesToTake)
    {
        CL_Storage newStorage = new CL_Storage(ResourcesToTake);

        return(HasResource(newStorage));
    }
Esempio n. 10
0
    public bool TakeResources(List <CL_Resource> ResourcesToTake)
    {
        CL_Storage newStorage = new CL_Storage(ResourcesToTake);

        return(TakeResources(newStorage));
    }