void Start() { _audioSource = GetComponent <AudioSource>(); _shootSound = _audioSource.clip; rb = GetComponent <Rigidbody>(); tf = GetComponent <Transform>(); bp = GetComponent <BatteryPower>(); powerLevelCylinder = bp.GetComponent <Transform>(); }
private void OnTriggerExit(Collider other) { if (other.tag == "ChargeAble" || other.tag == "Player") { _charging = false; if (Battery_1 == other.GetComponent <BatteryPower>()) { Battery_1 = null; } else { Battery_2 = null; } } }
private void OnTriggerEnter(Collider other) { if (other.tag == "ChargeAble" || other.tag == "Player") { _charging = true; if (Battery_1 == null) { Battery_1 = other.GetComponent <BatteryPower>(); } else { Battery_2 = other.GetComponent <BatteryPower>(); } StartCoroutine("Charge"); } }
void CheckBatteryPower() { int curBatteryValue = GetCurrentBatteryValue(); if (curBatteryValue != OldBatteryValue) { int percentNum = Mathf.CeilToInt(((float)curBatteryValue / MaxBatteryValue) * 100); BatteryPower curBatteryPower = GetBatteryPower(curBatteryValue); if (BatteryValueChangeCallback != null) { BatteryValueChangeCallback(percentNum, curBatteryPower); } OldBatteryValue = curBatteryValue; } }
private void Awake() { instance = this; }
private void BatteryValueChange(int percentNum, BatteryPower batteryPower) { SetBattery(percentNum); SetBatteryPower(percentNum); }