blob: 5650ffd1464ff7f3cb9a10a76b5daa55618ce408 (
plain)
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
|
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class LevelSelectManager : MonoBehaviour
{
public static LevelSelectManager instance;
private LevelInteractor[] levelInteractors;
public Vector3 spawnOnLevelOffsetPositon;
public PlayerMovement playerMovement;
public TMP_Text levelTitle;
public TMP_Text levelHighscore;
public TMP_Text beatenState;
public string notBeatenYet = "Not beaten yet.";
public string successfullyBeaten = "Successfully beaten.";
public string scorePrefix = "Your Best: ";
public GameObject tooltipObject;
public Image tooltipImage;
public TMP_Text tooltipTitle;
public TMP_Text tooltipDescription;
private Equippable showingTooltipFor;
public Canvas levelSelectedCanvas;
public Camera camMain;
private LevelInteractor openedLevel;
private int iFrames;
private bool fixedLoadout;
public Equippable ShowingTooltipFor => showingTooltipFor;
public bool PreLevelMenuIsOpen => openedLevel != null;
public void ShowTooltip(Equippable _eq)
{
showingTooltipFor = _eq;
tooltipObject.SetActive(_eq != null);
if (!(_eq == null))
{
tooltipImage.sprite = _eq.icon;
tooltipTitle.text = _eq.displayName;
tooltipDescription.text = _eq.description;
float num = camMain.pixelRect.height / levelSelectedCanvas.pixelRect.height;
tooltipObject.transform.position = Input.mousePosition * num;
}
}
private void Awake()
{
instance = this;
}
private void Start()
{
levelInteractors = GetComponentsInChildren<LevelInteractor>();
ShowTooltip(null);
}
private void MovePlayerToTheLevelYouCameFrom()
{
SceneTransitionManager sceneTransitionManager = SceneTransitionManager.instance;
if (!sceneTransitionManager || sceneTransitionManager.ComingFromGameplayScene == "")
{
return;
}
for (int i = 0; i < levelInteractors.Length; i++)
{
if (levelInteractors[i].sceneName == sceneTransitionManager.ComingFromGameplayScene)
{
playerMovement.TeleportTo(levelInteractors[i].transform.position + spawnOnLevelOffsetPositon);
break;
}
}
}
private void Update()
{
if (iFrames <= 1)
{
MovePlayerToTheLevelYouCameFrom();
}
iFrames++;
}
public void PlayButtonPressed()
{
if (PreLevelMenuIsOpen)
{
if (openedLevel.fixedLoadout.Count > 0)
{
PerkManager.instance.CurrentlyEquipped.Clear();
PerkManager.instance.CurrentlyEquipped.AddRange(openedLevel.fixedLoadout);
}
SceneTransitionManager.instance.TransitionFromLevelSelectToLevel(openedLevel.sceneName);
}
}
}
|