98 lines
2.3 KiB
C#
98 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
public Action OnPlayerDied;
|
|
|
|
private string penisSuriveTime = "";
|
|
|
|
public int Revives { get; private set; }
|
|
|
|
public GameObject ReviveParticleSystem;
|
|
|
|
public TMPro.TextMeshProUGUI ReviveText;
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance != null)
|
|
{
|
|
Destroy(Instance);
|
|
}
|
|
|
|
Instance = this;
|
|
Revives = 1;
|
|
ReviveText.text = Revives + "x";
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
}
|
|
|
|
public void playerDied(GameObject who)
|
|
{
|
|
Debug.Log($"{who.name} died");
|
|
if (Revives == 0)
|
|
{
|
|
AudioManager.Instance.StopAllAudio();
|
|
AudioManager.PlaySound("Game_Over_Jingle", Vector3.zero);
|
|
SceneManager.LoadScene(3);
|
|
}
|
|
else
|
|
{
|
|
Revives--;
|
|
ReviveText.text = Revives + "x";
|
|
Collider2D[] d = Physics2D.OverlapCircleAll(who.transform.position, 3f);
|
|
|
|
Debug.Log(d);
|
|
|
|
foreach (Collider2D c in d)
|
|
{
|
|
if (c.gameObject.CompareTag("Enemy"))
|
|
{
|
|
c.gameObject.GetComponent<HealthComponent>().TakeDamage(69420);
|
|
}
|
|
}
|
|
|
|
var g = who.GetComponent<HealthComponent>();
|
|
// heal
|
|
g.setMaxHealth(g.getMaxHealth(), true);
|
|
g.resetKillFlag();
|
|
|
|
// REVIVE SOUND HERE
|
|
AudioManager.PlaySound("Revive_SFX", who.transform.position);
|
|
RumbleManager.StartRumble(0, 0.3f, 0.1f, 3f);
|
|
RumbleManager.StartRumble(1, 0.3f, 0.1f, 3f);
|
|
|
|
GameObject go = Instantiate(ReviveParticleSystem, who.transform.position, Quaternion.identity);
|
|
ParticleSystem ps = go.GetComponent<ParticleSystem>();
|
|
ps.Play();
|
|
|
|
go.AddComponent<DestroyAfter>().Init(5f);
|
|
}
|
|
}
|
|
|
|
public void AddRevive()
|
|
{
|
|
Revives++;
|
|
ReviveText.text = Revives + "x";
|
|
}
|
|
|
|
public void setTime(string t)
|
|
{
|
|
penisSuriveTime = t;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|