123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using System.Collections;
- public class Threat
- {
- public int id;
- public float time;
- public float value = -1f;
- public Threat(int id, float value)
- {
- this.id = id;
- SetValue(value);
- }
- public void SetValue(float value)
- {
- if(GetValue() < value)
- {
- this.value = value;
- time = GameTime.time;
- }
- }
- public float GetValue()
- {
- float deltaTime = GameTime.time - time;
- if(deltaTime > 3f)
- {
- deltaTime = deltaTime - 3f;
- float modifyValue = value * (1f - deltaTime / 5f);
- return Mathf.Max(modifyValue, 0);
- }
- return value;
- }
-
- }
|