blob: 8e555d5f194c19707b921e708541cf4cd3d7862f (
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
|
using System;
using System.Collections;
using UnityEngine;
public class GameCrownHandler : MonoBehaviour
{
private float crownPos;
public AnimationCurve transitionCurve;
private GM_ArmsRace gm;
private int currentCrownHolder = -1;
private void Start()
{
gm = GetComponentInParent<GM_ArmsRace>();
GM_ArmsRace gM_ArmsRace = gm;
gM_ArmsRace.pointOverAction = (Action)Delegate.Combine(gM_ArmsRace.pointOverAction, new Action(PointOver));
}
public void PointOver()
{
int num = -1;
int num2 = -1;
if (gm.p1Rounds > gm.p2Rounds)
{
num2 = 0;
}
if (gm.p1Rounds < gm.p2Rounds)
{
num2 = 1;
}
if (num2 == -1)
{
int num3 = -1;
if (gm.p1Points > gm.p2Points)
{
num3 = 0;
}
if (gm.p1Points < gm.p2Points)
{
num3 = 1;
}
if (num3 != -1)
{
num = num3;
}
}
else
{
num = num2;
}
if (num != -1 && num != currentCrownHolder)
{
if (currentCrownHolder == -1)
{
currentCrownHolder = num;
crownPos = currentCrownHolder;
GetComponent<CurveAnimation>().PlayIn();
}
else
{
GiveCrownToPlayer(num);
}
}
}
private void LateUpdate()
{
if (currentCrownHolder == -1)
{
return;
}
if (PlayerManager.instance.players[currentCrownHolder].gameObject.activeInHierarchy)
{
if (!base.transform.GetChild(0).gameObject.activeSelf)
{
base.transform.GetChild(0).gameObject.SetActive(value: true);
}
}
else if (base.transform.GetChild(0).gameObject.activeSelf)
{
base.transform.GetChild(0).gameObject.SetActive(value: false);
}
Vector3 position = Vector3.LerpUnclamped(PlayerManager.instance.players[0].data.GetCrownPos(), PlayerManager.instance.players[1].data.GetCrownPos(), crownPos);
base.transform.position = position;
}
private void GiveCrownToPlayer(int playerID)
{
currentCrownHolder = playerID;
StartCoroutine(IGiveCrownToPlayer(playerID));
}
private IEnumerator IGiveCrownToPlayer(int playerID)
{
int fromInt;
int toInt;
if (playerID == 0)
{
fromInt = 1;
toInt = 0;
}
else
{
fromInt = 0;
toInt = 1;
}
for (float i = 0f; i < transitionCurve.keys[transitionCurve.keys.Length - 1].time; i += Time.unscaledDeltaTime)
{
crownPos = Mathf.LerpUnclamped(fromInt, toInt, transitionCurve.Evaluate(i));
yield return null;
}
}
}
|