blob: c5a6c945f9b9c4c9e0ae313e07fbd489341df627 (
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
using System;
using System.Collections;
using Photon.Pun;
using UnityEngine;
public class Map : MonoBehaviour
{
public bool wasSpawned;
public float size = 15f;
public bool hasEntered;
internal int levelID;
internal int missingObjects;
private float counter;
private int readyForFrames;
private bool hasCalledReady;
public Rigidbody2D[] allRigs;
private SpawnPoint[] spawnPoints;
public Action mapIsReadyAction;
public Action mapIsReadyEarlyAction;
public Action mapMovingOutAction;
internal bool hasRope;
internal bool LoadedForAll()
{
return MapManager.instance.otherPlayersMostRecentlyLoadedLevel == levelID;
}
private void Awake()
{
if (!GameManager.instance || !GameManager.instance.isPlaying)
{
GM_Test componentInChildren = GameManager.instance.transform.root.GetComponentInChildren<GM_Test>(includeInactive: true);
componentInChildren.gameObject.SetActive(value: true);
componentInChildren.testMap = true;
MapManager.instance.isTestingMap = true;
componentInChildren.transform.root.Find("UI/UI_MainMenu").gameObject.SetActive(value: false);
hasEntered = true;
}
}
private void Update()
{
counter += Time.deltaTime;
if (!hasCalledReady && ((PhotonNetwork.OfflineMode && counter > 1f && hasEntered) || (hasEntered && LoadedForAll())))
{
if (missingObjects <= 0)
{
readyForFrames++;
}
if (readyForFrames > 2)
{
StartCoroutine(StartMatch());
}
}
}
public void MapMoveOut()
{
mapMovingOutAction?.Invoke();
}
internal Vector3 GetRandomSpawnPos()
{
if (spawnPoints == null)
{
spawnPoints = GetComponentsInChildren<SpawnPoint>();
}
return spawnPoints[UnityEngine.Random.Range(0, spawnPoints.Length)].transform.position;
}
private IEnumerator StartMatch()
{
hasCalledReady = true;
mapIsReadyEarlyAction?.Invoke();
yield return new WaitForSecondsRealtime(0f);
allRigs = GetComponentsInChildren<Rigidbody2D>();
mapIsReadyAction?.Invoke();
}
private void Start()
{
if (!PhotonNetwork.OfflineMode)
{
MapManager.instance.ReportMapLoaded(levelID);
}
if (MapManager.instance.isTestingMap)
{
wasSpawned = true;
}
if (!wasSpawned)
{
MapManager.instance.UnloadScene(base.gameObject.scene);
}
SpriteRenderer[] componentsInChildren = GetComponentsInChildren<SpriteRenderer>(includeInactive: true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if ((double)componentsInChildren[i].color.a < 0.5)
{
continue;
}
componentsInChildren[i].transform.position = new Vector3(componentsInChildren[i].transform.position.x, componentsInChildren[i].transform.position.y, -3f);
if (!(componentsInChildren[i].gameObject.tag == "NoMask"))
{
componentsInChildren[i].color = new Color(11f / 51f, 11f / 51f, 11f / 51f);
if (!componentsInChildren[i].GetComponent<SpriteMask>())
{
componentsInChildren[i].gameObject.AddComponent<SpriteMask>().sprite = componentsInChildren[i].sprite;
}
}
}
SpriteMask[] componentsInChildren2 = GetComponentsInChildren<SpriteMask>();
for (int j = 0; j < componentsInChildren2.Length; j++)
{
if (!(componentsInChildren2[j].gameObject.tag == "NoMask"))
{
componentsInChildren2[j].isCustomRangeActive = true;
componentsInChildren2[j].frontSortingLayerID = SortingLayer.NameToID("MapParticle");
componentsInChildren2[j].frontSortingOrder = 1;
componentsInChildren2[j].backSortingLayerID = SortingLayer.NameToID("MapParticle");
componentsInChildren2[j].backSortingOrder = 0;
}
}
}
}
|