// Initialize this worldspace canvas as a player's worldspace canvas. public void InitializeAsPlayerCanvas(Character p) { // Hide ammo Text. ammoText.DOFade(0f, 0f); // Hide enemy HP bar. EnemyHPBarPanel.GetComponent <CanvasGroup>().DOFade(0f, 0.3f); // Show player bars. PlayerHPBarPanel.GetComponent <CanvasGroup>().DOFade(1f, 0.3f); PlayerAmmoBarPanel.GetComponent <CanvasGroup>().DOFade(1f, 0.3f); // Set player bar colors. // Set HP bar color. WSCPlayerHPIcon.DOColor(PlayerHPColor, 0f); WSCPlayerHPBar.DOColor(PlayerHPColor, 0f); // Set Ammo bar color. (based on player's current weapon color.) Color targetColor = HUDController.instance.WeaponPM.RetrieveCorrespondingWeaponColor(p.Weapon); WSCPlayerAmmoIcon.DOColor(targetColor, 0f); WSCPlayerAmmoBar.DOColor(targetColor, 0f); // Perform initial update. UpdateAsPlayerCanvas(p); }
// Update this worldspace canvas as a player canvas. public void UpdateAsPlayerCanvas(Character p) { // Update player HP. WSCPlayerHPBar.DOFillAmount(p.Health / p.MaxHealth, 0.3f); // Update player Ammo. WSCPlayerAmmoBar.DOFillAmount((float)p.Weapon.AmmoInClip / p.Weapon.ClipSize, 0.05f); }