public void SetSliders() { float damage = 0f; PowerupManager car = controller.GetCar().GetComponent <PowerupManager>(); Slider slider = transform.Find("FrontSlider").GetComponent <Slider>(); damage = car.GetWeaponDamage(WeaponMount.Grill); slider.value = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 1, 0.3f); slider = transform.Find("RearSlider").GetComponent <Slider>(); damage = car.GetWeaponDamage(WeaponMount.Hitch); slider.value = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 1, 0.3f); slider = transform.Find("RoofSlider").GetComponent <Slider>(); damage = car.GetWeaponDamage(WeaponMount.Roof); slider.value = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 1, 0.3f); slider = transform.Find("DoorSlider").GetComponent <Slider>(); damage = car.GetWeaponDamage(WeaponMount.Doors); slider.value = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 1, 0.3f); slider = transform.Find("WheelSlider").GetComponent <Slider>(); damage = car.GetWeaponDamage(WeaponMount.Wheels); slider.value = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 1, 0.3f); }
public void ShowPotentialWeapon(WeaponMount weaponLocation, float damage) { Slider slider; PowerupManager car = controller.GetCar().GetComponent <PowerupManager>(); switch (weaponLocation) { case WeaponMount.Grill: slider = transform.Find("FrontSlider").GetComponent <Slider>(); break; case WeaponMount.Hitch: slider = transform.Find("RearSlider").GetComponent <Slider>(); break; case WeaponMount.Roof: slider = transform.Find("RoofSlider").GetComponent <Slider>(); break; case WeaponMount.Doors: slider = transform.Find("DoorSlider").GetComponent <Slider>(); break; default: slider = transform.Find("WheelSlider").GetComponent <Slider>(); break; } float newPosition = GarageSlider.SliderPosition(GarageStats.minDamage, GarageStats.maxDamage, damage); if (newPosition > slider.value + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(0, 1, 0, 0.3f); } if (newPosition < slider.value + 0.00001f) { slider.transform.Find("Fill Area").Find("Fill").GetComponent <Image>().color = new Color(1, 0, 0, 0.3f); } slider.value = newPosition; }
public void UpdateButtons(List <GameObject> items) { int index = 1; Transform element = transform.Find("Slot0"); Select(element.gameObject); PowerupMain main; GarageItemButton gIB = element.gameObject.AddComponent <GarageItemButton>(); ButtonScripts scripts = element.gameObject.GetComponent <ButtonScripts>(); GarageSlider slider = GameObject.Find("GarageUI").transform.Find("StatSliders").GetComponent <GarageSlider>(); gIB.slider = slider; gIB.Unequipper(gameObject.name); element.GetComponent <Button>().onClick.AddListener(scripts.UnequipItem); foreach (GameObject item in items) { main = item.GetComponent <PowerupMain>(); element = gameObject.transform.Find("Slot" + index); element.Find("Text").GetComponent <Text>().text = item.gameObject.name; element.Find("Image").GetComponent <Image>().sprite = item.GetComponent <SpriteRenderer>().sprite; if (main.IsOwned()) { element.Find("Image").GetComponent <Image>().color = Color.white; element.Find("Text").GetComponent <Text>().color = Color.white; } else { element.Find("Image").GetComponent <Image>().color = Color.black; element.Find("Text").GetComponent <Text>().color = Color.black; } if (!main.IsChecked()) { main.Check(); StatPack stats = item.GetComponent <PowerupStats>().GetPack(); if (stats != null) { SendStats(stats, item.GetComponent <PowerupAttachable>()); } } if (main.IsEquipped()) { Select(element.gameObject); } scripts = element.gameObject.GetComponent <ButtonScripts>(); gIB = element.gameObject.AddComponent <GarageItemButton>(); scripts.SetItem(item); element.GetComponent <Button>().onClick.AddListener(scripts.EquipItem); slider = GameObject.Find("GarageUI").transform.Find("StatSliders").GetComponent <GarageSlider>(); gIB.slider = slider; gIB.item = item; element.GetComponent <Button>().onClick.AddListener(slider.SetSlidersOnNewEquip); index++; } for (; index < 5; index++) { element = gameObject.transform.Find("Slot" + index); element.gameObject.SetActive(false); } }
void Start() { sliderController = transform.Find("StatSliders").GetComponent <GarageSlider>(); UpdateEquips(); sliderController.SetSlidersOnOpen(); }