Beispiel #1
0
    public int getLimit(Ressource ressource)
    {
        RessourceTank rT = getStruct(ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            return(rT.numberLimit);
        }
        return(-1);
    }
Beispiel #2
0
 public void copy(RessourceTank rt)
 {
     rt.ressource         = ressource;
     rt.number            = number;
     rt.numberLimit       = numberLimit;
     rt.numberToConstruct = numberToConstruct;
     rt.numberToTransport = numberToTransport;
     rt.neededToTransport = neededToTransport;
     rt.neededToConstruct = neededToConstruct;
 }
Beispiel #3
0
    public int nbElementsTotal(Ressource ressource)
    {
        RessourceTank rT = getStruct(ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            return(rT.number);
        }
        else
        {
            return(0);
        }
    }
Beispiel #4
0
    public RessourceTank copy()
    {
        RessourceTank rt = new RessourceTank();

        rt.ressource         = ressource;
        rt.number            = number;
        rt.numberLimit       = numberLimit;
        rt.numberToConstruct = numberToConstruct;
        rt.numberToTransport = numberToTransport;
        rt.neededToTransport = neededToTransport;
        rt.neededToConstruct = neededToConstruct;
        return(rt);
    }
Beispiel #5
0
    public void remove(Ressource ressource)
    {
        RessourceTank rT = getStruct(ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            if (rT.number > 0)
            {
                rT.number = rT.number - 1;
            }
            rT.numberToTransport = rT.numberToTransport - 1;
        }
        //return false;
    }
Beispiel #6
0
    public void add(Ressource ressource)
    {
        RessourceTank rT = getStruct(ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            rT.number = rT.number + 1;
        }
        else
        {
            rT             = new RessourceTank();
            rT.ressource   = ressource;
            rT.number      = 1;
            rT.numberLimit = 2; // Limite le nombre de ressource à 99 par défaut
            ressourcesList.Add(rT);
        }
    }
Beispiel #7
0
    public void addSpecific(Ressource ressource, int number)
    {
        RessourceTank rT = getStruct(ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            rT.numberToTransport = number;
            rT.neededToTransport = true;
        }
        else
        {
            rT                   = new RessourceTank();
            rT.ressource         = ressource;
            rT.number            = 0;
            rT.numberToTransport = number;
            rT.neededToTransport = true;
            rT.numberLimit       = 99; // Limite le nombre de ressource à 99 par défaut
            ressourcesList.Add(rT);
        }
    }
Beispiel #8
0
    public void Recolt(Citizen citizen)
    {
        // if (citizen.ressources.Count != citizen.citizenSetting.inventorySize)
        //{
        //citizen.addRessource(Instantiate(ressource));
        RessourceTank rt = citizen.ressourcesToTransport.getStruct(structRessource.ressource);

        if (!rt.Equals(RessourceInventory.NULL))
        {
            if (rt.number < rt.numberLimit)
            {
                citizen.ressourcesToTransport.add(structRessource);
                if (citizen.ressourcesToTransport.ressourcesList.Count != 0)
                {
                    citizen.ressourcesToTransport.ressourcesList[0].neededToTransport = true;
                }
                numberRessource--;

                /*
                 * if (numberRessource <= 0)
                 * {
                 *  Destroy(gameObject);
                 * }*/
            }
        }
        else
        {
            citizen.ressourcesToTransport.add(structRessource);
            numberRessource--;

            /*
             * if (numberRessource <= 0)
             * {
             *  Destroy(gameObject);
             * }*/
        }
        //numberRessource--;
    }
Beispiel #9
0
    public void add(RessourceTank ressourceTank)
    {
        RessourceTank rT = getStruct(ressourceTank.ressource);

        if (!rT.Equals(RessourceInventory.NULL))
        {
            if (ressourceTank.numberToConstruct != -1)
            {
                rT.numberToTransport = ressourceTank.numberToConstruct;
                rT.numberLimit       = ressourceTank.numberToConstruct; // Limite le nombre de ressource à 99 par défaut
                rT.neededToTransport = true;
                //rT.number = 0;
            }
            else
            {
                rT.number = rT.number + 1;
            }
        }
        else
        {
            RessourceTank res = new RessourceTank();
            ressourceTank.copy(res);
            res.neededToTransport = true;
            res.ressource         = ressourceTank.ressource;
            res.numberToTransport = 1;
            res.numberLimit       = 5; // Limite le nombre de ressource à 99 par défaut
            res.number            = 1;
            if (ressourceTank.numberToConstruct != -1)
            {
                res.numberToTransport = ressourceTank.numberToConstruct;
                res.numberLimit       = ressourceTank.numberToConstruct; // Limite le nombre de ressource à 99 par défaut
                res.number            = 0;
            }
            Debug.Log(res.ressource);
            ressourcesList.Add(res);
        }
    }
Beispiel #10
0
    //public bool neededToCraft;

    public bool sameRessource(RessourceTank ressourceTank)
    {
        return(ressourceTank.ressource == ressource);
    }