2021-01-05 13:10:20 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Weapons.Scripts;
|
|
|
|
|
|
|
|
|
|
public class LoseLife : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private Renderer[] healthMarkers;
|
|
|
|
|
[SerializeField] private Renderer polygon;
|
|
|
|
|
|
|
|
|
|
private EntityHealth _health;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_health = GetComponent<EntityHealth>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LifeLost(int livesLeft)
|
|
|
|
|
{
|
2021-01-09 17:18:29 +01:00
|
|
|
|
healthMarkers[livesLeft].transform.DOScale(Vector3.zero, 1f).SetEase(Ease.InBack).SetUpdate(true);
|
2021-01-05 13:10:20 +01:00
|
|
|
|
_health.enabled = false;
|
|
|
|
|
var timeVal = Time.timeScale;
|
|
|
|
|
Time.timeScale = 0;
|
|
|
|
|
WaitUtils.Wait(0.1f, false, () => Time.timeScale = timeVal);
|
|
|
|
|
|
|
|
|
|
var sequence = DOTween.Sequence();
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
2021-01-09 17:18:29 +01:00
|
|
|
|
sequence.Append(polygon.material.DOFloat(1,"_FlashAmount", 0.2f).SetUpdate(true));
|
|
|
|
|
sequence.Append(polygon.material.DOFloat(0,"_FlashAmount", 0.2f).SetUpdate(true));
|
2021-01-05 13:10:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sequence.Play().OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
_health.enabled = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|