2019-08-04 16:18:01 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
using UnityEngine.UI;
|
2019-08-22 20:12:10 +02:00
|
|
|
|
using TMPro;
|
2019-08-14 16:17:48 +02:00
|
|
|
|
using Saltosion.OneWeapon.Player;
|
2019-08-22 20:12:10 +02:00
|
|
|
|
using Saltosion.OneWeapon.Guns;
|
2019-08-22 21:27:48 +02:00
|
|
|
|
using Saltosion.OneWeapon.Utils;
|
2019-08-04 16:18:01 +02:00
|
|
|
|
|
2019-08-14 16:17:48 +02:00
|
|
|
|
namespace Saltosion.OneWeapon.GUI {
|
2019-08-04 16:18:01 +02:00
|
|
|
|
public class HUDController : MonoBehaviour {
|
|
|
|
|
|
2019-08-22 20:12:10 +02:00
|
|
|
|
|
|
|
|
|
[Header("General")]
|
|
|
|
|
public PlayerController Player;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
public PlayerFun PlayerFun;
|
|
|
|
|
public RawImage FunMeter;
|
2019-08-22 20:12:10 +02:00
|
|
|
|
public Image GunImage;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
2019-08-22 20:12:10 +02:00
|
|
|
|
[Header("Gore Texts")]
|
|
|
|
|
public TMP_Text DamageTextGore;
|
|
|
|
|
public TMP_Text FunTextGore;
|
|
|
|
|
public TMP_Text GunTextGore;
|
2019-08-04 16:18:01 +02:00
|
|
|
|
|
2019-08-22 20:12:10 +02:00
|
|
|
|
[Header("Fun Texts")]
|
|
|
|
|
public TMP_Text DamageTextFun;
|
|
|
|
|
public TMP_Text FunTextFun;
|
|
|
|
|
public TMP_Text GunTextFun;
|
2019-08-04 20:23:39 +02:00
|
|
|
|
|
2019-08-22 21:27:48 +02:00
|
|
|
|
[Header("Kill Streak stuff")]
|
|
|
|
|
public GameObject KillStreakTransform;
|
|
|
|
|
public TMP_Text KSNumberGore;
|
|
|
|
|
public TMP_Text KSNumberFun;
|
|
|
|
|
public RawImage StreakMeter;
|
|
|
|
|
|
2019-08-04 20:23:39 +02:00
|
|
|
|
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!" };
|
|
|
|
|
|
2019-08-22 20:12:10 +02:00
|
|
|
|
private Gun LastGun;
|
2019-08-04 16:18:01 +02:00
|
|
|
|
|
2019-08-22 20:12:10 +02:00
|
|
|
|
void Start() {
|
|
|
|
|
GunTextGore.text = "";
|
|
|
|
|
GunTextFun.text = "";
|
2019-08-04 16:18:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update() {
|
2019-08-22 21:27:48 +02:00
|
|
|
|
/// Fun Bar
|
2019-08-04 17:35:05 +02:00
|
|
|
|
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;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
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];
|
2019-08-04 16:18:01 +02:00
|
|
|
|
|
2019-08-22 21:27:48 +02:00
|
|
|
|
/// Gun HUD
|
2019-08-22 20:12:10 +02:00
|
|
|
|
if (Player.Gun != LastGun) {
|
|
|
|
|
LastGun = Player.Gun;
|
|
|
|
|
if (LastGun == null) {
|
|
|
|
|
GunTextGore.text = "";
|
|
|
|
|
GunTextFun.text = "";
|
|
|
|
|
GunImage.color = new Color(0, 0, 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
GunTextGore.text = LastGun.Name;
|
|
|
|
|
GunTextFun.text = LastGun.Name;
|
|
|
|
|
GunImage.sprite = LastGun.GunSprite;
|
|
|
|
|
GunImage.color = new Color(1, 1, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-22 21:27:48 +02:00
|
|
|
|
|
|
|
|
|
/// Kill Streak
|
|
|
|
|
if (PlayerFun.KillStreak < 2) {
|
|
|
|
|
KillStreakTransform.SetActive(false);
|
|
|
|
|
} else {
|
|
|
|
|
KillStreakTransform.SetActive(true);
|
|
|
|
|
string Number = PlayerFun.KillStreak.ToString();
|
|
|
|
|
KSNumberFun.text = Number;
|
|
|
|
|
KSNumberGore.text = Number;
|
|
|
|
|
|
|
|
|
|
float StreakPercent = (PlayerFun.CurrentKillStreakTime / PlayerFun.KillStreakTimer);
|
|
|
|
|
Scale = StreakMeter.transform.localScale;
|
|
|
|
|
Scale.x = StreakPercent;
|
|
|
|
|
StreakMeter.transform.localScale = Scale;
|
|
|
|
|
|
|
|
|
|
GoreColor = StreakMeter.color;
|
|
|
|
|
FunColor = StreakMeter.color;
|
|
|
|
|
|
|
|
|
|
GoreColor.r = 1;
|
|
|
|
|
GoreColor.g = 1 - StreakPercent;
|
|
|
|
|
GoreColor.b = 1 - StreakPercent;
|
|
|
|
|
|
|
|
|
|
FunColor.r = 1;
|
|
|
|
|
FunColor.g = 1;
|
|
|
|
|
FunColor.b = 1 - StreakPercent;
|
|
|
|
|
|
|
|
|
|
if (Options.CensorGore) {
|
|
|
|
|
StreakMeter.color = FunColor;
|
|
|
|
|
} else {
|
|
|
|
|
StreakMeter.color = GoreColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-04 16:18:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|