Ejemplo n.º 1
0
    public IEnumerator Processing(MachineSlot mySlot)
    {
        float ttimer = coolDownTime;

        mySlot.fillImage.fillAmount = 1;

        while (mySlot.fillImage.fillAmount >= 0.01f)
        {
            if (isTurnedOn == false)
            {
                ttimer -= Time.deltaTime;
            }
            else
            {
                ttimer = coolDownTime;
                mySlot.fillImage.fillAmount = 1;
            }
            if (Interactor.instance.myCraftingMachine == this)
            {
                if (ttimer <= 0)
                {
                    mySlot.fillImage.fillAmount = 0;
                }
                else
                {
                    mySlot.fillImage.fillAmount = ttimer / coolDownTime;
                }
            }
            yield return(null);
        }
    }
Ejemplo n.º 2
0
    public IEnumerator Processing(Resipe myResipe, MachineSlot mySlot)
    {
        float ttimer = myResipe.timeToConvert;

        mySlot.fillImage.fillAmount = 1;

        while (mySlot.fillImage.fillAmount >= 0.01f)
        {
            if (isTurnedOn == true)
            {
                ttimer -= Time.deltaTime;
            }
            else
            {
                ttimer = myResipe.timeToConvert;
                mySlot.fillImage.fillAmount = 1;
            }
            if (Interactor.instance.myCraftingMachine == this)
            {
                if (ttimer <= 0)
                {
                    mySlot.fillImage.fillAmount = 0;
                }
                else
                {
                    mySlot.fillImage.fillAmount = ttimer / myResipe.timeToConvert;
                }
            }
            yield return(null);
        }
    }
Ejemplo n.º 3
0
        public void Purchase(int slotNumber, PaymentType paymentType)
        {
            MachineSlot slot         = _machineStatus.Slots.FirstOrDefault(s => s.SlotNumber == slotNumber);
            decimal     currentTotal = _machineStatus.Total[paymentType];

            //Only process the payment when requested slot is not empty
            if (slot != null && slot.IsEmpty == false)
            {
                slot.IsEmpty = true;
                _machineStatus.Total[paymentType] = currentTotal + slot.Price;
            }
        }
Ejemplo n.º 4
0
    public IEnumerator BurnProcessing(Resipe myResipe, MachineSlot mySlot)
    {
        float ttimer = myResipe.timeToConvert;

        mySlot.fillImage.fillAmount = 1;
        StartCoroutine(EcoEffect(myResipe.timeToConvert / 2));

        while (mySlot.fillImage.fillAmount >= 0.01f)
        {
            if (isTurnedOn == true)
            {
                EcoManager.instance.AddPollution(Mathf.RoundToInt(PollutionToAdd * (ttimer / myResipe.timeToConvert)));
                ttimer -= Time.deltaTime;
                EcoManager.instance.AddPollution(-Mathf.RoundToInt(PollutionToAdd * (ttimer / myResipe.timeToConvert)));
                if (Interactor.instance.myCraftingMachine == this)
                {
                    if (ttimer <= 0.01f)
                    {
                        mySlot.fillImage.fillAmount = 0;
                    }
                    else
                    {
                        mySlot.fillImage.fillAmount = ttimer / myResipe.timeToConvert;
                    }
                }
            }
            yield return(null);
        }

        for (int x = 0; x < productFuelSlots.Count; x++)
        {
            if (productFuelSlots[x] == null)
            {
                productFuelSlots[x] = Instantiate(burnSlotResipe.product);
                MachineSlot m = Interactor.instance.GetMachineSlot(true, x);
                if (Interactor.instance.myCraftingMachine == this)
                {
                    m.SetItem(burnSlotResipe.product);
                    Interactor.instance.burnSlot.RemoveItem();
                }
                StartCoroutine(Processing(m));
                burnSlot = null;
                mySlot.fillImage.fillAmount = 1;
                break;
            }
            else if (x == productFuelSlots.Count)
            {
                TurnOff();
            }
        }
        CheckResipe();
    }
Ejemplo n.º 5
0
    public void CheckResipe()
    {
        if (needsFuel == true && CheckFuelResipe() == false)
        {
            if (isTurnedOn == true)
            {
                TurnOff();
            }
            return;
        }
        else if (isTurnedOn == false)
        {
            return;
        }

        for (int i = 0; i < craftSlots.Count; i++)
        {
            for (int ii = 0; ii < validItems.Count; ii++)
            {
                if (craftSlots[i] != null && craftSlots[i].itemName == validItems[ii].ingredient.itemName)
                {
                    for (int x = 0; x < productSlots.Count; x++)
                    {
                        if (productSlots[x] == null)
                        {
                            productSlots[x] = Instantiate(validItems[ii].product);
                            MachineSlot r = Interactor.instance.GetMachineSlot(false, i);
                            r.RemoveItem();
                            craftSlots[i] = null;

                            MachineSlot m = Interactor.instance.GetMachineSlot(false, x);
                            StartCoroutine(Processing(validItems[ii], m));

                            if (Interactor.instance.myCraftingMachine == this)
                            {
                                m.SetItem(Instantiate(validItems[ii].product));
                                Interactor.instance.craftSlots[i].RemoveItem();
                            }
                            break;
                        }
                        else if (x == productSlots.Count - 1)
                        {
                            return;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 6
0
 bool CheckFuelResipe()
 {
     if (burnSlot != null)
     {
         return(true);
     }
     for (int i = 0; i < craftFuelSlots.Count; i++)
     {
         for (int ii = 0; ii < validFuelItems.Count; ii++)
         {
             if (craftFuelSlots[i] != null && craftFuelSlots[i].itemName == validFuelItems[ii].ingredient.itemName)
             {
                 for (int z = 0; z < productFuelSlots.Count; z++)
                 {
                     if (productFuelSlots[z] == null && burnSlot == null)
                     {
                         if (burnSlot == null)
                         {
                             burnSlot          = Instantiate(craftFuelSlots[i]);
                             craftFuelSlots[i] = null;
                             burnSlotResipe    = validFuelItems[ii];
                             MachineSlot m = Interactor.instance.burnSlot;
                             StartCoroutine(BurnProcessing(burnSlotResipe, m));
                             if (Interactor.instance.myCraftingMachine == this)
                             {
                                 m.SetItem(Instantiate(validFuelItems[ii].ingredient));
                                 Interactor.instance.craftFuelSlots[i].RemoveItem();
                             }
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }