BloodAndGore/Assets/Scripts/PlayerFun.cs

78 lines
2.0 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2019-08-04 20:27:44 +02:00
using UnityEngine.SceneManagement;
namespace Saltosion.OneWeapon {
public class PlayerFun : MonoBehaviour {
public Player Player;
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;
public float CurrentFun { private set; get; }
public bool DebugAdd10Fun = false;
public float CurrentDamageBoost { private set; get; }
void Start() {
CurrentFun = MaxFun * 0.75f;
}
void Update() {
float Delta = FunDegradeSpeed * Time.deltaTime;
if (!Player.IsMoving) {
Delta *= StandingStillMultiplier;
}
float NewFun = CurrentFun - Delta;
if (DebugAdd10Fun) {
NewFun += 10;
DebugAdd10Fun = false;
}
CurrentFun = Mathf.Clamp(NewFun, 0, MaxFun);
CurrentDamageBoost = Mathf.Floor((CurrentFun / 100) * 12) / 12;
2019-08-04 20:27:44 +02:00
if (CurrentFun <= 0) {
SceneManager.LoadScene(3);
2019-08-04 20:27:44 +02:00
}
}
2019-08-04 20:01:28 +02:00
private void AddFun(float fun) {
float NewFun = CurrentFun + fun;
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-04 20:01:28 +02:00
public void ReceiveNewWeapon() {
AddFun(WeaponFun);
}
public void ShootingFun() {
AddFun(ShootingFunAmount);
}
public void Explosion(bool isFurniture) {
float NewFun = CurrentFun;
if (isFurniture) {
2019-08-04 20:01:28 +02:00
AddFun(FurnitureExplosionFun);
} else {
2019-08-04 20:01:28 +02:00
AddFun(EnemyExplosionFun);
}
}
}
}