-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventManager.cs
58 lines (53 loc) · 1.58 KB
/
EventManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class EventManager : MonoBehaviour
{
MapMake mapMakeScript;
GameManager gameManager;
MonsterManager monsterManager;
public static EventManager Instance;
public UnityEvent OnPlayerMove;
public UnityEvent OnMapGenerate;
public UnityEvent OnPlayerBattle;
public UnityEvent OnLevelUp;
public UnityEvent OnMonsterDead;
public UnityEvent VisitedFloor;
private void Awake()
{
SetInstance();
}
private void Start()
{
mapMakeScript = this.gameObject.transform.GetComponent<MapMake>();
gameManager = GameManager.instance;
monsterManager = this.gameObject.transform.GetComponent<MonsterManager>();
gameManager.InstantiatePlayerObj();
AddMapGenerateFunction();
GameManager.instance.OnMapGenerate.Invoke();
TurnManager.instance.turn++;
}
void AddMapGenerateFunction()
{
if (GameManager.instance != null)
{
gameManager.OnMapGenerate.AddListener(mapMakeScript.MapGenerate);
gameManager.OnMapGenerate.AddListener(monsterManager.AddMonsterSpawnFunction);
gameManager.OnMapGenerate.AddListener(gameManager.SetPlayerNextFloor);
gameManager.OnMapGenerate.AddListener(gameManager.item.MakeItems);
}
else
{
Debug.Log("GameManager NullError");
}
}
void SetInstance()
{
if(Instance == null)
{
Instance = this;
}
}
}