public void ModifyValue(int modifier) { value = Mathf.Clamp(value + modifier, 0, maxValue); bar.fillAmount = (float)value / maxValue; bar.color = Colorx.Slerp(new Color(0.75f, 0.1f, 0.1f), new Color(0.35f, 0.67f, 0.35f), bar.fillAmount); if (value <= 0) { gameOver.GameOver(gameObject.tag); } }
public void RollDice() { // Reset all dice foreach (PhysicsDie die in dice) { die.SetModifier(0); die.gameObject.SetActive(false); die.GetRenderer().material.color = Color.white; } // Apply modifiers - modifiers can stack! while (m_DiceScoreModifiers.Count > 0) { PhysicsDie dieToAffect = dice[Random.Range(0, diceToRoll + diceToRollModifier)]; dieToAffect.AddModifier(m_DiceScoreModifiers.Dequeue()); dieToAffect.GetRenderer().material.color = Colorx.Slerp(Color.white, dieToAffect.m_Modifier < 0 ? new Color(0.28f, 0.69f, 0.96f) : new Color(0.93f, 0.74f, 0.2f), Mathf.Clamp(Mathf.Abs(dieToAffect.m_Modifier) / (float)5, 0, 1)); } DiceManager.instance.SpawnDice(diceToRoll + diceToRollModifier); diceToRollModifier = 0; }
private void Awake() { value = startingValue; bar.fillAmount = (float)value / maxValue; bar.color = Colorx.Slerp(new Color(0.75f, 0.1f, 0.1f), new Color(0.35f, 0.67f, 0.35f), bar.fillAmount); }