2019-08-04 17:35:05 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2019-08-04 20:27:44 +02:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
2019-08-14 16:17:48 +02:00
|
|
|
|
namespace Saltosion.OneWeapon.Player {
|
2019-08-04 17:35:05 +02:00
|
|
|
|
public class PlayerFun : MonoBehaviour {
|
|
|
|
|
|
2019-08-14 16:17:48 +02:00
|
|
|
|
public PlayerController Player;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
public float MaxFun = 100;
|
|
|
|
|
public float FunDegradeSpeed = 5;
|
|
|
|
|
public float StandingStillMultiplier = 1.5f;
|
|
|
|
|
|
|
|
|
|
public float WeaponFun = 20;
|
2019-08-04 20:01:28 +02:00
|
|
|
|
public float EnemyExplosionFun = 6f;
|
|
|
|
|
public float FurnitureExplosionFun = 3f;
|
|
|
|
|
public float ShootingFunAmount = 0.5f;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
public float CurrentFun { private set; get; }
|
|
|
|
|
|
|
|
|
|
public bool DebugAdd10Fun = false;
|
2019-08-07 21:31:43 +02:00
|
|
|
|
public bool DebugSubtract10Fun = false;
|
|
|
|
|
public bool GodMode = false;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
public float CurrentDamageBoost { private set; get; }
|
|
|
|
|
|
|
|
|
|
void Start() {
|
2019-08-04 19:48:26 +02:00
|
|
|
|
CurrentFun = MaxFun * 0.75f;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update() {
|
2019-08-07 21:31:43 +02:00
|
|
|
|
// God mode hotkey
|
|
|
|
|
if (Input.GetButtonUp("GodModeToggle")) {
|
|
|
|
|
GodMode = !GodMode;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-04 17:35:05 +02:00
|
|
|
|
float Delta = FunDegradeSpeed * Time.deltaTime;
|
|
|
|
|
if (!Player.IsMoving) {
|
|
|
|
|
Delta *= StandingStillMultiplier;
|
|
|
|
|
}
|
2019-08-07 21:31:43 +02:00
|
|
|
|
float NewFun = CurrentFun;
|
|
|
|
|
if (!GodMode) {
|
|
|
|
|
NewFun -= Delta;
|
|
|
|
|
}
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
if (DebugAdd10Fun) {
|
|
|
|
|
NewFun += 10;
|
|
|
|
|
DebugAdd10Fun = false;
|
|
|
|
|
}
|
2019-08-07 21:31:43 +02:00
|
|
|
|
if (DebugSubtract10Fun) {
|
|
|
|
|
NewFun -= 10;
|
|
|
|
|
DebugSubtract10Fun = false;
|
|
|
|
|
}
|
2019-08-04 17:35:05 +02:00
|
|
|
|
|
|
|
|
|
CurrentFun = Mathf.Clamp(NewFun, 0, MaxFun);
|
|
|
|
|
|
|
|
|
|
CurrentDamageBoost = Mathf.Floor((CurrentFun / 100) * 12) / 12;
|
2019-08-04 20:27:44 +02:00
|
|
|
|
|
|
|
|
|
if (CurrentFun <= 0) {
|
2019-08-04 20:29:45 +02:00
|
|
|
|
SceneManager.LoadScene(3);
|
2019-08-04 20:27:44 +02:00
|
|
|
|
}
|
2019-08-04 17:35:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-04 20:01:28 +02:00
|
|
|
|
private void AddFun(float fun) {
|
2019-08-14 17:11:59 +02:00
|
|
|
|
float FunAdded = fun * (2 - (CurrentFun / MaxFun));
|
|
|
|
|
float NewFun = CurrentFun + FunAdded;
|
2019-08-04 17:35:05 +02:00
|
|
|
|
CurrentFun = Mathf.Min(MaxFun, NewFun);
|
2019-08-04 20:01:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-04 20:38:57 +02:00
|
|
|
|
public void TakeDamage() {
|
|
|
|
|
AddFun(-5f);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-14 21:31:58 +02:00
|
|
|
|
public void TakeExplosionDamage() {
|
|
|
|
|
AddFun(-10f);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-04 20:01:28 +02:00
|
|
|
|
public void ReceiveNewWeapon() {
|
|
|
|
|
AddFun(WeaponFun);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShootingFun() {
|
|
|
|
|
AddFun(ShootingFunAmount);
|
2019-08-04 17:35:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Explosion(bool isFurniture) {
|
|
|
|
|
float NewFun = CurrentFun;
|
|
|
|
|
if (isFurniture) {
|
2019-08-04 20:01:28 +02:00
|
|
|
|
AddFun(FurnitureExplosionFun);
|
2019-08-04 17:35:05 +02:00
|
|
|
|
} else {
|
2019-08-04 20:01:28 +02:00
|
|
|
|
AddFun(EnemyExplosionFun);
|
2019-08-04 17:35:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|