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); } }
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(); }
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); }