autobalance

This commit is contained in:
dart 2022-04-03 15:11:21 +03:00
parent b8e5cad380
commit 88063d164e
2 changed files with 33 additions and 9 deletions

View File

@ -22,12 +22,10 @@ public struct StatReturn
public float Damage;
public float MoveSpeed;
}
private void Start()
{
characterAnimator = characterSprite.GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
@ -58,14 +56,10 @@ void Update()
MoveCamera();
}
private void MoveCamera()
{
mainCamera.transform.position = new Vector3(transform.position.x, transform.position.y,-10);
}
public StatReturn GetStats()
{
var stats = new StatReturn
@ -76,14 +70,24 @@ public StatReturn GetStats()
};
return stats;
}
public void ApplyDamage(float damage)
{
health -= damage;
}
public float GetHealth()
{
return health;
}
public float GetDamage()
{
return damage;
}
public void SetHealth(float newHealth)
{
health = newHealth;
}
public void SetDamage(float newDamage)
{
damage = newDamage;
}
}

View File

@ -9,6 +9,9 @@ public class Gameplay : MonoBehaviour
[SerializeField] private GameObject overMind;
[SerializeField] private float timeOnStart;
[SerializeField] private GameObject DeathScreen;
[SerializeField] private float balanceScale;
private float _time;
private GameStates _curGameState;
public enum GameStates
@ -23,6 +26,23 @@ void Start()
_curGameState = GameStates.Game;
_time = timeOnStart;
_characterCharacterClass = character.GetComponent<Character>();
StartCoroutine(AutoBalance());
}
private IEnumerator AutoBalance()
{
while (true)
{
yield return new WaitForSeconds(30f);
print("autobalance");
if (balanceScale > 1.1f)
{
balanceScale -= 0.1f;
}
_characterCharacterClass.SetHealth(_characterCharacterClass.GetHealth() * balanceScale);
_characterCharacterClass.SetDamage(_characterCharacterClass.GetDamage() * balanceScale);
}
}
// Update is called once per frame