-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCursorManager.cs
More file actions
115 lines (97 loc) · 3.58 KB
/
CursorManager.cs
File metadata and controls
115 lines (97 loc) · 3.58 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class CursorManager : MonoBehaviour
{
public static Texture2D NormalCursor;
private AssetStore _assetStore;
private NPCManager _npcManager;
private Radio _radio;
private bool _inCameraScene;
void Start()
{
_assetStore = GameObject.FindGameObjectWithTag("GameController").GetComponent<AssetStore>();
_inCameraScene = GameManager.CurrentScene.Equals(GameManager.Scene.Camera);
if (!_inCameraScene)
{
SetCursor(_assetStore.NormalCursor);
NormalCursor = _assetStore.NormalCursor;
}
else
{
if (HandManager.Currently.Equals(HandManager.state.HoldingRadio))
{
_radio = GameObject.FindGameObjectWithTag("RadioUI").GetComponent<Radio>();
_npcManager = GameObject.FindGameObjectWithTag("GameController").GetComponent<NPCManager>();
SetCursor(_assetStore.RadioCursor1);
NormalCursor = _assetStore.RadioCursor1;
}
else if (HandManager.Currently.Equals(HandManager.state.HoldingBBGun)){
SetCursor(_assetStore.BBGunCursor);
NormalCursor = _assetStore.BBGunCursor;
}
else
{
SetCursor(_assetStore.CameraCursor);
NormalCursor = _assetStore.CameraCursor;
}
}
}
private void Update()
{
if (_inCameraScene)
{
if (HandManager.Currently.Equals(HandManager.state.HoldingRadio))
{
ChangeRadioCursor();
}
else if (DialogueManager.InDialogue)
{
SetCursor(_assetStore.NormalCursor);
NormalCursor = _assetStore.NormalCursor;
}
}
if (CombineManager.InCombineMode)
{
SetCursor(_assetStore.CombineCursor);
}
}
public void ChangeRadioCursor()
{
if (_npcManager.ClosestNPC != null)
{
var npcFrequency = _npcManager.ClosestNPC.RadioFrequency;
var npcRadioTolerance = _npcManager.ClosestNPC.Tolerance;
if (_radio.Frequency < npcFrequency + npcRadioTolerance && _radio.Frequency > npcFrequency - npcRadioTolerance)
{
if (NormalCursor != _assetStore.RadioCursor3)
{
SetCursor(_assetStore.RadioCursor3);
NormalCursor = _assetStore.RadioCursor3;
}
}
else if (_radio.Frequency < npcFrequency + npcRadioTolerance * 5 && _radio.Frequency > npcFrequency - npcRadioTolerance * 5)
{
if (NormalCursor != _assetStore.RadioCursor2)
{
SetCursor(_assetStore.RadioCursor2);
NormalCursor = _assetStore.RadioCursor2;
}
}
else
{
if (NormalCursor != _assetStore.RadioCursor1)
{
SetCursor(_assetStore.RadioCursor1);
NormalCursor = _assetStore.RadioCursor1;
}
}
}
}
public static void SetCursor(Texture2D cursor)
{
Vector2 hotSpot = new Vector2(cursor.width / 2f, cursor.height / 2f);
Cursor.SetCursor(cursor, hotSpot, CursorMode.ForceSoftware);
}
}