Erro em script (photon)
Página 1 de 1
Erro em script (photon)
ola estou com 7 erros no script abaixo:
Erro 2: Assets/LobbyController.cs(118,45): error CS0841: A local variable `playerHash' cannot be used before it is declared
Erro 3: Assets/LobbyController.cs(127,5): error CS0246: The type or namespace name `Exit' could not be found. Are you missing an assembly reference?
Erro 4: Assets/LobbyController.cs(130,55): error CS0841: A local variable `mapHash' cannot be used before it is declared
Erro 5: Assets/LobbyController.cs(130,19): error CS1501: No overload for method `CreateRoom' takes `6' arguments
Erro 6:Assets/LobbyController.cs(173,6): error CS0246: The type or namespace name `Exit' could not be found. Are you missing an assembly reference?
Erro 7:Assets/LobbyController.cs(174,46): error CS0841: A local variable `playerHash' cannot be used before it is declared
- Código:
using System;
using UnityEngine;
using System.Collections;
public enum LobbyState
{
ConnectingLobby = 0,
LobbyConnected
}
public class LobbyController : Photon.MonoBehaviour
{
private LobbyState state = LobbyState.ConnectingLobby;
private string gameName = "Game Name";
private string mapName = "Map Name";
private string gameType = "FFA";
private string fragLimit = "10";
private string playerNick = "Unnamed player";
private bool offlineMode;
public string LevelName;
//Singleton Pattern
private static LobbyController instance = null;
public static LobbyController Instance
{
get
{
if (instance == null)
{
instance = (LobbyController)GameObject.FindGameObjectWithTag("Lobby").GetComponent<LobbyController>();
if (instance == null)
{
return null;
}
}
return instance;
}
}
void Start()
{
try
{
PhotonNetwork.offlineMode = true;
PhotonNetwork.ConnectUsingSettings("0.1");
playerNick = PlayerPrefs.GetString("playerNick", "Unnamedplayer");
gameType = PlayerPrefs.GetString("gameType", "FFA");
mapName = PlayerPrefs.GetString("mapName", "Map");
}
catch (Exception)
{
PhotonNetwork.offlineMode = true;
PhotonNetwork.ConnectUsingSettings("0.1");
playerNick = PlayerPrefs.GetString("playerNick", "Unnamedplayer");
gameType = PlayerPrefs.GetString("gameType", "FFA");
mapName = PlayerPrefs.GetString("mapName", "Map");
}
}
void OnGUI()
{
switch (state)
{
case LobbyState.ConnectingLobby:
{
GUI.Label(new Rect(5, 5, 200, 200), "Connecting Lobby....");
}
break;
case LobbyState.LobbyConnected:
{
GUICreateRoom();
GUIShowRooms();
}
break;
default:
break;
}
}
private void GUICreateRoom()
{
GUILayout.BeginHorizontal();
GUILayout.Label("Player name:");
playerNick = GUILayout.TextField(playerNick, 20);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Game name:");
gameName = GUILayout.TextField(gameName, 12);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Map name:");
mapName = GUILayout.TextField(mapName, 12);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Game type:");
gameType = GUILayout.TextField(gameType, 12);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Fraglimit:");
fragLimit = GUILayout.TextField(fragLimit, 5);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("offline mode:");
offlineMode = GUILayout.Toggle(offlineMode, "");
GUILayout.EndHorizontal();
if (GUILayout.Button("CREATE"))
{
bool nameFree = true;
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
if (room.name == gameName)
nameFree = false;
}
if (gameName != "" && nameFree)
{
Exit.Games.Client.Photon.Hashtable playerHash = new Exit.Games.Client.Photon.Hashtable { { "PlayerNick", playerNick } };
PhotonNetwork.SetPlayerCustomProperties(playerHash);
string[] defs = new string[3];
defs[0] = "mapName";
defs[1] = "gameType";
defs[2] = "fragLimit";
PlayerPrefs.SetString("playerNick", playerNick);
PlayerPrefs.SetString("mapName", mapName);
PlayerPrefs.SetString("gameType", gameType);
Exit.Games.Client.Photon.Hashtable mapHash = new Exit.Games.Client.Photon.Hashtable { { "mapName", mapName }, { "gameType", gameType }, { "fragLimit", fragLimit } };
PhotonNetwork.isMessageQueueRunning = false;
PhotonNetwork.offlineMode = offlineMode;
PhotonNetwork.CreateRoom(gameName, true, true, 4, mapHash, defs);
Application.LoadLevel(mapName);
}
}
}
private void GUIShowRooms()
{
if (PhotonNetwork.GetRoomList().Length == 0)
return;
GUILayout.BeginHorizontal("Box");
GUILayout.BeginVertical(GUILayout.Width(150));
GUILayout.Label("Game name", GUILayout.Width(150));
GUILayout.EndVertical();
GUILayout.BeginVertical(GUILayout.Width(75));
GUILayout.Label("Players", GUILayout.Width(75));
GUILayout.EndVertical();
GUILayout.BeginVertical(GUILayout.Width(75));
GUILayout.Label("Map", GUILayout.Width(75));
GUILayout.EndVertical();
GUILayout.EndHorizontal();
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
GUILayout.BeginHorizontal("Box");
GUILayout.BeginVertical(GUILayout.Width(150));
GUILayout.Label(room.name, GUILayout.Width(150));
GUILayout.EndVertical();
GUILayout.BeginVertical(GUILayout.Width(75));
GUILayout.Label(room.playerCount + "/" + room.maxPlayers, GUILayout.Width(75));
GUILayout.EndVertical();
GUILayout.BeginVertical(GUILayout.Width(75));
GUILayout.Label(room.customProperties["mapName"].ToString(), GUILayout.Width(75));
GUILayout.EndVertical();
if (room.playerCount < room.maxPlayers)
{
if (GUILayout.Button("JOIN"))
{
PlayerPrefs.SetString("playerNick", playerNick);
Exit.Games.Client.Photon.Hashtable playerHash = new Exit.Games.Client.Photon.Hashtable { { "PlayerNick", playerNick } };
PhotonNetwork.SetPlayerCustomProperties(playerHash);
PhotonNetwork.JoinRoom(room.name);
Application.LoadLevel(room.customProperties["mapName"].ToString());
}
}
else
{
if (GUILayout.Button("FULL"))
{
Debug.Log("Room is filled up");
}
}
GUILayout.EndHorizontal();
}
}
#region PhotonMethods
void OnJoinedLobby()
{
state = LobbyState.LobbyConnected;
Debug.Log("You joined the lobby");
}
#endregion
}
Erro 2: Assets/LobbyController.cs(118,45): error CS0841: A local variable `playerHash' cannot be used before it is declared
Erro 3: Assets/LobbyController.cs(127,5): error CS0246: The type or namespace name `Exit' could not be found. Are you missing an assembly reference?
Erro 4: Assets/LobbyController.cs(130,55): error CS0841: A local variable `mapHash' cannot be used before it is declared
Erro 5: Assets/LobbyController.cs(130,19): error CS1501: No overload for method `CreateRoom' takes `6' arguments
Erro 6:Assets/LobbyController.cs(173,6): error CS0246: The type or namespace name `Exit' could not be found. Are you missing an assembly reference?
Erro 7:Assets/LobbyController.cs(174,46): error CS0841: A local variable `playerHash' cannot be used before it is declared
PatifeCraft- Avançado
- PONTOS : 2871
REPUTAÇÃO : 6
Respeito as regras :
Tópicos semelhantes
» [ERRO DO PHOTON] Script do Photon com a unity
» Erro Script Photon
» Erro Script Photon
» Erro em script para photon
» Erro em script do Photon Voice
» Erro Script Photon
» Erro Script Photon
» Erro em script para photon
» Erro em script do Photon Voice
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos