blob: e972cba9e9652d597f0e2c12aef290732d930d51 (
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
|
using Photon.Pun;
using TMPro;
using UnityEngine;
public class DevConsole : MonoBehaviour
{
public TMP_InputField inputField;
public static bool isTyping;
private void Start()
{
isTyping = false;
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Return))
{
inputField.gameObject.SetActive(!inputField.gameObject.activeSelf);
isTyping = inputField.gameObject.activeSelf;
GameManager.lockInput = isTyping;
if (inputField.gameObject.activeSelf)
{
inputField.ActivateInputField();
}
else
{
Send(inputField.text);
}
}
}
private void Send(string message)
{
if (Application.isEditor || ((bool)GM_Test.instance && GM_Test.instance.gameObject.activeSelf))
{
SpawnCard(message);
}
if (Application.isEditor)
{
SpawnMap(message);
}
int viewID = PlayerManager.instance.GetPlayerWithActorID(PhotonNetwork.LocalPlayer.ActorNumber).data.view.ViewID;
GetComponent<PhotonView>().RPC("RPCA_SendChat", RpcTarget.All, message, viewID);
}
private void SpawnMap(string message)
{
try
{
int iD = int.Parse(message);
MapManager.instance.LoadLevelFromID(iD, onlyMaster: false, callInImidetly: true);
}
catch
{
}
}
[PunRPC]
private void RPCA_SendChat(string message, int playerViewID)
{
PhotonNetwork.GetPhotonView(playerViewID).GetComponentInChildren<PlayerChat>().Send(message);
}
private void SpawnCard(string message)
{
CardInfo[] cards = CardChoice.instance.cards;
int num = -1;
float num2 = 0f;
for (int i = 0; i < cards.Length; i++)
{
string text = cards[i].GetComponent<CardInfo>().cardName.ToUpper();
text = text.Replace(" ", "");
string text2 = message.ToUpper();
text2 = text2.Replace(" ", "");
float num3 = 0f;
for (int j = 0; j < text2.Length; j++)
{
if (text.Length > j && text2[j] == text[j])
{
num3 += 1f / (float)text2.Length;
}
}
num3 -= (float)Mathf.Abs(text2.Length - text.Length) * 0.001f;
if (num3 > 0.1f && num3 > num2)
{
num2 = num3;
num = i;
}
}
if (num != -1)
{
GameObject obj = CardChoice.instance.AddCard(cards[num]);
obj.GetComponentInChildren<CardVisuals>().firstValueToSet = true;
obj.transform.root.GetComponentInChildren<ApplyCardStats>().shootToPick = true;
}
}
public static int GetClosestString(string inputText, string[] compareTo)
{
CardInfo[] cards = CardChoice.instance.cards;
int result = -1;
float num = 0f;
for (int i = 0; i < cards.Length; i++)
{
string text = compareTo[i];
text = text.Replace(" ", "");
string text2 = inputText.ToUpper();
text2 = text2.Replace(" ", "");
float num2 = 0f;
for (int j = 0; j < text2.Length; j++)
{
if (text.Length > j && text2[j] == text[j])
{
num2 += 1f / (float)text2.Length;
}
}
num2 -= (float)Mathf.Abs(text2.Length - text.Length) * 0.001f;
if (num2 > 0.1f && num2 > num)
{
num = num2;
result = i;
}
}
return result;
}
}
|