private void Start() { playerTank = PlayerData.Instance.GetCurrentVehicleFuelTank(); Debug.Log(playerTank.GetFuelAmount()); maxBars = Mathf.CeilToInt(playerTank.GetFuelAmount() / FuelPerBar); Image fuelBarIcon = Resources.Load <Image>("UIPrefabs/FuelBarIcon"); fuelBars = new List <Image>(maxBars); for (int i = 0; i < maxBars; i++) { fuelBars.Add(Instantiate <Image>(fuelBarIcon, transform)); } currentBars = maxBars; }
// Update is called once per frame void Update() { _fuelIncText.text = "+" + (_fuelTank.GetFuelAmount()).ToString(); if (_fuelTank.ItemGetCheck() == true) { Debug.Log("Test"); _itemGetAnime.SetTrigger("ItemGet"); } }
void FixedUpdate() { int reqBars = Mathf.CeilToInt(playerTank.GetFuelAmount() / FuelPerBar); if (reqBars != currentBars) { for (int i = 0; i < fuelBars.Count; i++) { fuelBars[i].gameObject.SetActive(i < reqBars); } currentBars = reqBars; } }