public static StatPack Min(StatPack a, StatPack b) { StatPack c = new StatPack(); foreach (StatType type in System.Enum.GetValues(typeof(StatType))) { if (a.GetAdd(type) < b.GetAdd(type)) { c.SetAdd(type, a.GetAdd(type)); } else { c.SetAdd(type, b.GetAdd(type)); } if (a.GetMult(type) < b.GetMult(type)) { c.SetMult(type, a.GetMult(type)); } else { c.SetMult(type, b.GetMult(type)); } } return(c); }
public static StatPack ApplyToBase(StatPack baseStats, StatPack powerups) { StatPack result = new StatPack(); foreach (StatType type in System.Enum.GetValues(typeof(StatType))) { result.SetAdd(type, (baseStats.GetAdd(type) + powerups.GetAdd(type)) * (1 + powerups.GetMult(type))); } return(result); }
public static StatPack Instead(StatPack basePack, StatPack currentPack, StatPack newPack) { StatPack x = new StatPack(); foreach (StatType type in System.Enum.GetValues(typeof(StatType))) { x.SetAdd(type, (basePack.GetAdd(type) / (1 + currentPack.GetMult(type)) - currentPack.GetAdd(type) + newPack.GetAdd(type)) * (1 + newPack.GetMult(type))); } return(x); }
public void ReApplyStats(StatPack powerups) { StatPack newStats = StatPack.ApplyToBase(baseStats, powerups); maxHealth = newStats.GetAdd(StatPack.StatType.Health); maxNO2 = newStats.GetAdd(StatPack.StatType.Nitro); currentArmor = newStats.GetAdd(StatPack.StatType.Armor); controller.GetCar().GetComponent <Rigidbody2D>().mass = newStats.GetAdd(StatPack.StatType.Weight); controller.GetCar().GetComponent <Driving>().topSpeed = newStats.GetAdd(StatPack.StatType.TopSpeed); controller.GetCar().GetComponent <Driving>().staticCoefficientOfFriction = newStats.GetAdd(StatPack.StatType.Grip); controller.GetCar().GetComponent <Driving>().acceleration = newStats.GetAdd(StatPack.StatType.Acceleration); GarageStats.SetCurrentStats(newStats); }
public void ShowStatBars(StatPack pack, StatPack otherPack) { Slider slider; StatPack newStats; StatPack.StatType type; StatPack currentStats = GarageStats.currentStats; newStats = StatPack.Instead(GarageStats.currentStats, otherPack, pack); type = StatPack.StatType.Acceleration; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.Armor; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.Grip; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.Health; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.Nitro; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.TopSpeed; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); type = StatPack.StatType.Weight; slider = PickSlider(type); if (newStats.GetAdd(type) > currentStats.GetAdd(type) + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newStats.GetAdd(type) < currentStats.GetAdd(type) - 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = SliderPosition(GarageStats.MinStatValue(type), GarageStats.MaxStatValue(type), newStats.GetAdd(type)); }
public static float CurrentStatValue(StatPack.StatType type) { return(currentStats.GetAdd(type)); }
public static float MaxStatValue(StatPack.StatType stat) { return((baseStats.GetAdd(stat) + maxStats.GetAdd(stat)) * (1 + maxStats.GetMult(stat))); }