void Update() { UseItem(); HeldItem(); Color temp = matRend.color; temp.a = (mass - (int)type * 50f) / 100f; matRend.color = temp; if (mass <= type.GetPrevMaterial().GetMass()) { type = type.GetPrevMaterial(); SetMaterial(type.GetSprite()); } if (mass >= type.GetNextMaterial().GetMass()) { type = type.GetNextMaterial(); SetMaterial(type.GetSprite()); } }
void Update() { if (uiBar.Length > 0) { if (mass / 50f > 4f) { uiBar[4].fillAmount = (mass - 4 * 50f) / 50f; } else if (mass / 50f > 3f) { uiBar[3].fillAmount = (mass - 3 * 50f) / 50f; } else if (mass / 50f > 2f) { uiBar[2].fillAmount = (mass - 2 * 50f) / 50f; } else if (mass / 50f >= 1f) { uiBar[1].fillAmount = (mass - 1 * 50f) / 50f; } else if (mass / 50f > 0f) { uiBar[0].fillAmount = mass / 50f; } } if (mass <= type.GetPrevMaterial().GetMass()) { type = type.GetPrevMaterial(); rend.sprite = type.GetSprite(); } if (mass >= type.GetNextMaterial().GetMass()) { type = type.GetNextMaterial(); rend.sprite = type.GetSprite(); } //Mass resets after some time without laser hit if (cooldown > 0f) { cooldown -= Time.deltaTime; } else if (cooldown > -1f) { float rfr = (float)type * 50f; if (mass == rfr) { cooldown = 1f; return; } else if (mass < rfr) { mass += Time.deltaTime * 2f; } else if (mass > rfr) { mass -= Time.deltaTime * 2f; } } }