Exemplo n.º 1
0
 public void CheckWorkforceEmptied(CommoditySO _type)
 {
     if (_type == workforce)
     {
         worker.PopWorkForce();
     }
 }
Exemplo n.º 2
0
    public Commodity SpawnCommodity(CommoditySO _type)
    {
        Commodity instatiatedCommodity = Instantiate(commodityPrefab, transform);

        instatiatedCommodity.InitializeProfile(_type);
        return(instatiatedCommodity);
    }
Exemplo n.º 3
0
 public void CheckAutoSell(CommoditySO _commodity)
 {
     if (typeToSell == _commodity)
     {
         ScenarioService.instance.OnNodeStep();
         ScenarioService.instance.onAutoSell -= CheckAutoSell;
     }
 }
Exemplo n.º 4
0
 public void CheckCommodityInspected(CommoditySO _commodity)
 {
     if (commoditiesToInspect.Contains(_commodity))
     {
         ScenarioService.instance.OnNodeStep();
         ScenarioService.instance.onCommodityInspected -= CheckCommodityInspected;
     }
 }
Exemplo n.º 5
0
 public void GetEdited(CommoditySO _workforce, List <int> _allowedIndices)
 {
     if (_allowedIndices.Contains(type.index) && profile.components.Count > 0)
     {
         List <CommodityProfile> tempProfiles = (from component in profile.components
                                                 select component).ToList();
         tempProfiles.Add(new CommodityProfile(_workforce));
         profile.components.Clear();
         TransferComponentsValue(tempProfiles);
     }
 }
Exemplo n.º 6
0
 public void CheckCommodityProduced(CommoditySO _commodity)
 {
     if (commoditiesToProduce.Contains(_commodity))
     {
         commoditiesToProduce.Remove(_commodity);
         if (commoditiesToProduce.Count == 0)
         {
             ScenarioService.instance.OnNodeStep();
             ScenarioService.instance.onProduceRegistered -= CheckCommodityProduced;
         }
     }
 }
Exemplo n.º 7
0
    public void ProduceCommodity()
    {
        Recipe recipe = CommoditiesService.instance.GetCommodityByComponents(loadedCommodities);

        if (recipe != null && productionTarget.loadedCommodity == null)
        {
            CommoditySO             producedCommoditySO = recipe.result;
            Commodity               produceInstance     = CommoditiesService.instance.SpawnCommodity(producedCommoditySO);
            List <CommodityProfile> profiles            = (from commodity in loadedCommodities
                                                           select commodity.profile).ToList();
            produceInstance.TransferComponentsValue(profiles);
            productionTarget.OnCommodityPlaced(produceInstance);
            List <Commodity> toRemove = new List <Commodity>();
            foreach (Commodity component in loadedCommodities)
            {
                if (!component.OnUsed())
                {
                    toRemove.Add(component);
                }
            }
            loadedCommodities = (loadedCommodities.Where(x => !toRemove.Contains(x))).ToList();
            onCommodityProduced?.Invoke(producedCommoditySO);
            CommoditiesService.instance.CheckRecipes(recipe);
        }
        else if (recipe == null)
        {
            print("No produce from: ");
            for (var i = 0; i < loadedCommodities.Count; i++)
            {
                print(loadedCommodities[i].type);
            }
            List <Commodity> workforces = (from commodity in loadedCommodities
                                           where commodity.type.index == 1
                                           select commodity).ToList();
            if (ScenarioService.instance.workforceIntroduced && workforces.Count == 0)
            {
                errorMessage.LaunchError("Nécessite une force de travail !");
            }
            else
            {
                errorMessage.LaunchError("Ingrédients incorrects !");
            }
        }
        else
        {
            errorMessage.LaunchError("Retirez le produit précédent !");
            print("Clear the production space");
        }
    }
Exemplo n.º 8
0
 public CommodityProfile(CommoditySO _type)
 {
     type                = _type;
     commodityName       = _type.commodityName;
     exchangeValue       = _type.exchangeValue;
     useValue            = _type.useValue;
     useValueDescription = _type.useValueDescription;
     isDurable           = _type.isDurable;
     usesAmount          = _type.usesAmount;
     initialUsesAmount   = _type.usesAmount;
     valuePerUse         = usesAmount != 0 ? exchangeValue / usesAmount : 0;
     icon                = _type.icon;
     sizeModifier        = _type.sizeModifier;
     color               = _type.color;
     components          = new List <CommodityProfile>();
 }
Exemplo n.º 9
0
 public void AddCommodity(CommoditySO _commodityType)
 {
     for (var i = 0; i < spawnTargets.Count; i++)
     {
         if (spawnTargets[i].loadedCommodity != null)
         {
             continue;
         }
         else
         {
             Commodity commodityInstance = CommoditiesService.instance.SpawnCommodity(_commodityType);
             commodityInstance.rect.position = spawnTargets[i].rect.position;
             spawnTargets[i].OnCommodityPlaced(commodityInstance, true);
             return;
         }
     }
 }
Exemplo n.º 10
0
    public void InitializeProfile(CommoditySO _type)
    {
        type                        = _type;
        profile.type                = _type;
        profile.commodityName       = type.commodityName;
        profile.exchangeValue       = type.exchangeValue;
        profile.useValue            = type.useValue;
        profile.useValueDescription = type.useValueDescription;
        profile.isDurable           = type.isDurable;
        profile.usesAmount          = type.usesAmount;
        profile.initialUsesAmount   = type.usesAmount;
        profile.valuePerUse         = profile.usesAmount != 0 ? profile.exchangeValue / profile.usesAmount : 0;
        profile.icon                = type.icon;
        icon.sprite                 = profile.icon;
        profile.sizeModifier        = type.sizeModifier;
        icon.transform.localScale   = Vector3.one * profile.sizeModifier;
        profile.color               = type.color;

        if (profile.isDurable)
        {
            SetUsesUI();
        }
    }
Exemplo n.º 11
0
 void ExchangeCommodities(CommoditySO firstCommodity, CommoditySO secondCommodity)
 {
     if (CanExchangeCommodities(firstCommodity, secondCommodity))
     {
     }
 }
Exemplo n.º 12
0
 bool CanExchangeCommodities(CommoditySO firstCommodity, CommoditySO secondCommodity)
 {
     return(firstCommodity.exchangeValue == secondCommodity.exchangeValue);
 }
Exemplo n.º 13
0
 public void OnCommodityInspected(CommoditySO _type)
 {
     onCommodityInspected?.Invoke(_type);
 }
Exemplo n.º 14
0
 public void OnAutoSell(CommoditySO _commodity)
 {
     onAutoSell?.Invoke(_commodity);
 }
Exemplo n.º 15
0
 public void RegisterProduce(CommoditySO _type)
 {
     onProduceRegistered?.Invoke(_type);
 }