R1
This commit is contained in:
parent
37252a4edc
commit
19ab6f65e3
258 changed files with 406592 additions and 0 deletions
53
Assets/Scripts/FearLevel.cs
Normal file
53
Assets/Scripts/FearLevel.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FearLevel : MonoBehaviour
|
||||
{
|
||||
private readonly int UP_SPEED = 2, DOWN_SPEED = 10;
|
||||
public GameObject fire, player;
|
||||
private float fearLevel = 0;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Vector2.Distance(player.transform.position, fire.transform.position) < (fire.GetComponent<FireScript>().GetFireIntensity() / 5) || player.GetComponent<PlayerTorch>().TorchIsActive())
|
||||
{
|
||||
if (fearLevel <= 0) return;
|
||||
DecrementLevel(Time.deltaTime * DOWN_SPEED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fearLevel >= 100)
|
||||
{
|
||||
Global.Dead();
|
||||
return;
|
||||
}
|
||||
IncrementLevel(Time.deltaTime * UP_SPEED);
|
||||
}
|
||||
Debug.Log(fearLevel + " " + fire.GetComponent<FireScript>().GetFireIntensity());
|
||||
}
|
||||
|
||||
public float GetFearLevel()
|
||||
{
|
||||
return fearLevel;
|
||||
}
|
||||
|
||||
public void DecrementLevel(float amount)
|
||||
{
|
||||
this.fearLevel -= amount;
|
||||
if (this.fearLevel < 0) this.fearLevel = 0;
|
||||
}
|
||||
|
||||
public void IncrementLevel(float amount)
|
||||
{
|
||||
this.fearLevel += amount;
|
||||
if (this.fearLevel > 100) this.fearLevel = 100;
|
||||
}
|
||||
}
|
Reference in a new issue