2024-02-04 03:25:06 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2024-02-04 09:52:47 +01:00
|
|
|
using System;
|
2024-02-04 03:25:06 +01:00
|
|
|
using UnityEngine;
|
2024-02-04 09:52:47 +01:00
|
|
|
using UnityEngine.Events;
|
2024-02-04 10:31:50 +01:00
|
|
|
using UnityEngine.SceneManagement;
|
2024-02-04 03:25:06 +01:00
|
|
|
|
|
|
|
public class GameManager : MonoBehaviour
|
|
|
|
{
|
2024-02-04 09:52:47 +01:00
|
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
|
|
|
|
public Action OnPlayerDied;
|
|
|
|
|
2024-02-04 10:04:07 +01:00
|
|
|
private string penisSuriveTime = "";
|
|
|
|
|
2024-02-04 10:31:50 +01:00
|
|
|
public int Revives { get; private set; }
|
|
|
|
|
2024-02-04 11:13:51 +01:00
|
|
|
public GameObject ReviveParticleSystem;
|
|
|
|
|
2024-02-04 09:52:47 +01:00
|
|
|
void Awake()
|
|
|
|
{
|
2024-02-04 10:04:07 +01:00
|
|
|
if (Instance == null)
|
2024-02-04 09:52:47 +01:00
|
|
|
{
|
|
|
|
Instance = this;
|
|
|
|
DontDestroyOnLoad(gameObject);
|
2024-02-04 11:13:51 +01:00
|
|
|
Revives = 1;
|
2024-02-04 09:52:47 +01:00
|
|
|
}
|
2024-02-04 10:04:07 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
2024-02-04 09:52:47 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 03:25:06 +01:00
|
|
|
void Start()
|
|
|
|
{
|
2024-02-04 09:52:47 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 10:31:50 +01:00
|
|
|
public void playerDied(GameObject who)
|
2024-02-04 09:52:47 +01:00
|
|
|
{
|
2024-02-04 10:31:50 +01:00
|
|
|
if (Revives == 0)
|
2024-02-04 11:13:51 +01:00
|
|
|
{
|
|
|
|
AudioManager.StopAllAudio();
|
|
|
|
AudioManager.PlaySound("Game_Over_Jingle", Vector3.zero);
|
2024-02-04 10:31:50 +01:00
|
|
|
SceneManager.LoadScene(3);
|
2024-02-04 11:13:51 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-02-04 10:31:50 +01:00
|
|
|
Revives--;
|
2024-02-04 11:13:51 +01:00
|
|
|
Collider2D[] d = Physics2D.OverlapCircleAll(who.transform.position, 3f);
|
|
|
|
|
|
|
|
Debug.Log(d);
|
2024-02-04 10:31:50 +01:00
|
|
|
|
2024-02-04 11:13:51 +01:00
|
|
|
foreach (Collider2D c in d)
|
|
|
|
{
|
|
|
|
if (c.gameObject.CompareTag("Enemy"))
|
|
|
|
{
|
|
|
|
c.gameObject.GetComponent<HealthComponent>().TakeDamage(69420);
|
|
|
|
}
|
2024-02-04 10:31:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var g = who.GetComponent<HealthComponent>();
|
|
|
|
// heal
|
|
|
|
g.setMaxHealth(g.getMaxHealth(), true);
|
|
|
|
|
|
|
|
// REVIVE SOUND HERE
|
2024-02-04 11:13:51 +01:00
|
|
|
AudioManager.PlaySound("Revive_SFX", who.transform.position);
|
|
|
|
RumbleManager.StartRumble(0, 0.3f, 0.1f, 3f);
|
|
|
|
RumbleManager.StartRumble(1, 0.3f, 0.1f, 3f);
|
|
|
|
|
|
|
|
ReviveParticleSystem.transform.position = who.transform.position;
|
|
|
|
ReviveParticleSystem.GetComponent<ParticleSystem>().Play();
|
2024-02-04 10:31:50 +01:00
|
|
|
}
|
2024-02-04 03:25:06 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 11:32:07 +01:00
|
|
|
public void AddRevive() {
|
|
|
|
Revives++;
|
|
|
|
}
|
|
|
|
|
2024-02-04 10:31:50 +01:00
|
|
|
public void setTime(string t)
|
|
|
|
{
|
2024-02-04 10:04:07 +01:00
|
|
|
penisSuriveTime = t;
|
|
|
|
}
|
|
|
|
|
2024-02-04 03:25:06 +01:00
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
2024-02-04 09:52:47 +01:00
|
|
|
|
2024-02-04 03:25:06 +01:00
|
|
|
}
|
|
|
|
}
|