103 lines
2.7 KiB
C#
103 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace Saltosion.OneWeapon.Player {
|
|
public class PlayerFun : MonoBehaviour {
|
|
|
|
public PlayerController Player;
|
|
|
|
public float MaxFun = 100;
|
|
public float FunDegradeSpeed = 5;
|
|
public float StandingStillMultiplier = 1.5f;
|
|
|
|
public float WeaponFun = 20;
|
|
public float EnemyExplosionFun = 6f;
|
|
public float FurnitureExplosionFun = 3f;
|
|
public float ShootingFunAmount = 0.5f;
|
|
|
|
public float CurrentFun { private set; get; }
|
|
|
|
public bool DebugAdd10Fun = false;
|
|
public bool DebugSubtract10Fun = false;
|
|
public bool GodMode = false;
|
|
|
|
public float CurrentDamageBoost { private set; get; }
|
|
|
|
void Start() {
|
|
CurrentFun = MaxFun * 0.75f;
|
|
}
|
|
|
|
void Update() {
|
|
// God mode hotkey
|
|
if (Input.GetButtonUp("GodModeToggle")) {
|
|
GodMode = !GodMode;
|
|
}
|
|
|
|
float Delta = FunDegradeSpeed * Time.deltaTime;
|
|
if (!Player.IsMoving) {
|
|
Delta *= StandingStillMultiplier;
|
|
}
|
|
float NewFun = CurrentFun;
|
|
if (!GodMode) {
|
|
NewFun -= Delta;
|
|
}
|
|
|
|
if (DebugAdd10Fun) {
|
|
NewFun += 10;
|
|
DebugAdd10Fun = false;
|
|
}
|
|
if (DebugSubtract10Fun) {
|
|
NewFun -= 10;
|
|
DebugSubtract10Fun = false;
|
|
}
|
|
|
|
CurrentFun = Mathf.Clamp(NewFun, 0, MaxFun);
|
|
|
|
CurrentDamageBoost = Mathf.Floor((CurrentFun / 100) * 12) / 12;
|
|
|
|
if (CurrentFun <= 0) {
|
|
SceneManager.LoadScene(3);
|
|
}
|
|
}
|
|
|
|
private void AddFun(float fun) {
|
|
float FunAdded = fun * (2 - (CurrentFun / MaxFun));
|
|
float NewFun = CurrentFun + FunAdded;
|
|
CurrentFun = Mathf.Min(MaxFun, NewFun);
|
|
}
|
|
|
|
public void TakeDamage() {
|
|
if (GodMode) {
|
|
return;
|
|
}
|
|
AddFun(-5f);
|
|
}
|
|
|
|
public void TakeExplosionDamage() {
|
|
if (GodMode) {
|
|
return;
|
|
}
|
|
AddFun(-10f);
|
|
}
|
|
|
|
public void ReceiveNewWeapon() {
|
|
AddFun(WeaponFun);
|
|
}
|
|
|
|
public void ShootingFun() {
|
|
AddFun(ShootingFunAmount);
|
|
}
|
|
|
|
public void Explosion(bool isFurniture) {
|
|
float NewFun = CurrentFun;
|
|
if (isFurniture) {
|
|
AddFun(FurnitureExplosionFun);
|
|
} else {
|
|
AddFun(EnemyExplosionFun);
|
|
}
|
|
}
|
|
}
|
|
}
|