| using System.Collections; |
| using System.Collections.Generic; |
| using UnityEngine; |
| |
| public class GameManager : Photon.MonoBehaviour { |
| |
| public GameObject[] spawnSpots; |
| |
| public int state = 0; |
| |
| void Connect() |
| { |
| PhotonNetwork.ConnectUsingSettings("V1.0"); |
| } |
| |
| void OnJoinedLobby() |
| { |
| state = 1; |
| } |
| |
| void OnPhotonRandomJoinFailed() |
| { |
| PhotonNetwork.CreateRoom(null); |
| } |
| |
| void OnJoinedRoom() |
| { |
| state = 2; |
| } |
| |
| |
| void Start () { |
| |
| } |
| |
| |
| void Update () { |
| |
| } |
| |
| void OnGUI() |
| { |
| switch (state) |
| { |
| case 0: |
| if (GUI.Button(new Rect(10,10,100,30), "Connect")) |
| { |
| Connect(); |
| } |
| break; |
| case 1: |
| GUI.Label(new Rect(10, 10, 100, 30), "Connected"); |
| if (GUI.Button(new Rect(10, 10, 100, 30), "Search")) |
| { |
| PhotonNetwork.JoinRandomRoom(); |
| } |
| break; |
| case 2: |
| GUI.Label(new Rect(10, 10, 100, 30), "Select Your Champion"); |
| if (GUI.Button(new Rect(10, 10, 100, 30), "Barbarian Mage")) |
| { |
| spawnCharacter(0, "Barbarian Mage"); |
| } |
| break; |
| case 3: |
| |
| break; |
| } |
| } |
| |
| void spawnCharacter(int team, string character) |
| { |
| state = 3; |
| Debug.Log("You are on team.... " + team + ". And are playing as " + character); |
| |
| GameObject mySpawn = spawnSpots[Random.Range(0, spawnSpots.Length)]; |
| GameObject myPlayer = PhotonNetwork.Instantiate(character, mySpawn.transform.position, mySpawn.transform.rotation, 0); |
| } |
| } |