-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameManager.cs
46 lines (35 loc) · 1.3 KB
/
GameManager.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using System;
using System.Linq;
using UnityEngine.SceneManagement;
public class GameManager : NetworkBehaviour
{
//--------------------------------------------------------METHODS-----------------------------------------------
[Server]
public override void OnStartServer()
{
NetworkManagerLobby networkManagerObject = NetworkManager.singleton.GetComponent<NetworkManagerLobby>();
for (int i = 0; i < networkManagerObject.GamePlayers.Count; i++)
{
networkManagerObject.GamePlayers[i].localPlayerID = i;
}
System.Random random = new System.Random();
int turnID = random.Next(0, networkManagerObject.GamePlayers.Count);
for (int i = 0; i < networkManagerObject.GamePlayers.Count; i++)
{
networkManagerObject.GamePlayers[i].WhichTurn = turnID;
}
}
[Server]
public void ChangeWhoGivesAssociation(int WhichTurn)
{
NetworkManagerLobby networkManagerObject = NetworkManager.singleton.GetComponent<NetworkManagerLobby>();
for (int i = 0; i < networkManagerObject.GamePlayers.Count; i++)
{
networkManagerObject.GamePlayers[i].WhichTurn = WhichTurn;
}
}
}