BloodAndGore/Assets/Scripts/GUI/HUDController.cs

66 lines
2.2 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
2019-08-14 16:17:48 +02:00
using Saltosion.OneWeapon.Player;
2019-08-14 16:17:48 +02:00
namespace Saltosion.OneWeapon.GUI {
public class HUDController : MonoBehaviour {
public PlayerFun PlayerFun;
public RawImage FunMeter;
public Text DamageTextGore;
public Text DamageTextFun;
2019-08-04 20:23:39 +02:00
public Text FunTextGore;
public Text FunTextFun;
private string[] GoreTexts = new string[] { "I'm gonna die of boredom!", "Ultra lame!", "Oof, boring!", "That's cool!", "Holy fuck!", "Bloody awesome!" };
private string[] FunTexts = new string[] { "I'm gonna fall asleep!", "You should try doing something!", "There aren't enough flowers", "Now that's pretty!", "You're doing great!", "Faboulous!" };
void Start() {
}
void Update() {
float FunPercent = (PlayerFun.CurrentFun / PlayerFun.MaxFun);
Vector3 Scale = FunMeter.transform.localScale;
Scale.x = FunPercent;
FunMeter.transform.localScale = Scale;
Rect UVRect = FunMeter.uvRect;
UVRect.width = FunPercent;
FunMeter.uvRect = UVRect;
float FunLevel = Mathf.Floor(FunPercent * 6) / 6;
Color Color = FunMeter.color;
Color.g = FunLevel;
Color.r = 1 - FunLevel;
FunMeter.color = Color;
int FunPercentNumber = (int)Mathf.Round(PlayerFun.CurrentDamageBoost * 100);
string Text = "+" + FunPercentNumber + "%";
DamageTextGore.text = Text;
DamageTextFun.text = Text;
Color GoreColor = DamageTextGore.color;
GoreColor.g = 1 - PlayerFun.CurrentDamageBoost;
GoreColor.b = 1 - PlayerFun.CurrentDamageBoost;
DamageTextGore.color = GoreColor;
2019-08-04 20:23:39 +02:00
FunTextGore.color = GoreColor;
Color FunColor = DamageTextFun.color;
FunColor.b = 1 - PlayerFun.CurrentDamageBoost;
DamageTextFun.color = FunColor;
2019-08-04 20:23:39 +02:00
FunTextFun.color = FunColor;
2019-08-04 20:38:57 +02:00
int FunLevelInt = (int)Mathf.Clamp(Mathf.Floor(FunPercent * 6), 0, 5);
2019-08-04 20:23:39 +02:00
FunTextGore.text = GoreTexts[FunLevelInt];
FunTextFun.text = FunTexts[FunLevelInt];
}
}
}