tenho alguns erros nos scripts do mfps mas nao consigo resolver....
2 participantes
Página 1 de 1
tenho alguns erros nos scripts do mfps mas nao consigo resolver....
1º
Assets/MFPS/Scripts/Network/bl_FootSteps.cs(173,80): error CS1750: Optional parameter expression of type `null' cannot be converted to parameter type `PhotonMessageInfo'
script:using UnityEngine;
using System.Collections;
public class bl_FootSteps : bl_PhotonHelper
{
[HideInInspector]
public bool CanUpdate = true;
public bool CanSyncSteps = true;
[Header("Sounds Lists")]
public AudioClip[] m_dirtSounds;
public AudioClip[] m_concreteSounds;
public AudioClip[] m_WoodSounds;
public AudioClip[] m_WaterSounds;
[Header("Settings")]
public float m_minSpeed = 2f;
public float m_maxSpeed = 8f;
public float audioStepLengthCrouch = 0.65f;
public float audioStepLengthWalk = 0.45f;
public float audioStepLengthRun = 0.25f;
public float audioVolumeCrouch = 0.3f;
public float audioVolumeWalk = 0.4f;
public float audioVolumeRun = 1.0f;
[Space(5)]
public AudioSource InstanceReference;
public PhotonView m_view;
//private
private bool isStep = true;
private string m_MaterialHit;
private Vector3 LastPost = Vector3.zero;
/// <summary>
///
/// </summary>
void Update()
{
if (!CanUpdate)//if remote is not updated, only receives the RPC call (optimization helps)
return;
if (InstanceReference == null)
return;
if (!isStep)
return;
RaycastHit hit;
if (Physics.Raycast(transform.position, -Vector3.up, out hit, 10))
{
m_MaterialHit = hit.collider.transform.tag;
}
float m_magnitude = m_charactercontroller.velocity.magnitude;
if (m_charactercontroller.isGrounded && isStep)
{
if (m_magnitude < m_minSpeed && m_magnitude > 0.75f)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Crouch", m_MaterialHit);
}
SyncSteps("Crouch", m_MaterialHit);
}
else if (m_magnitude > m_minSpeed && m_magnitude < m_maxSpeed)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Walk", m_MaterialHit);
}
SyncSteps("Walk", m_MaterialHit);
}
else if (m_magnitude > m_maxSpeed)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Run", m_MaterialHit);
}
SyncSteps("Run", m_MaterialHit);
}
}
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Crouch(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthCrouch);
isStep = true;
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Walk(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthWalk);
isStep = true;
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Run(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthRun);
isStep = true;
}
[PunRPC]
void SyncSteps(string t_corrutine,string m_material,PhotonMessageInfo m_info =null )
{
if (m_info != null)
{
if (m_info.sender.name == gameObject.name)
{
GameObject player = FindPlayerRoot(m_info.photonView.viewID);
LastPost = player.transform.position;
StartCoroutine(t_corrutine, m_material);
}
}
else
{
LastPost = this.InstanceReference.transform.position;
StartCoroutine(t_corrutine, m_material);
}
}
public void OffUpdate()
{
CanUpdate = false;
}
public CharacterController m_charactercontroller
{
get
{
return this.transform.root.GetComponent<CharacterController>();
}
}
}
2º
Assets/MFPS/Scripts/Network/bl_ChatRoom.cs(48,73): error CS0103: The name `PeerState' does not exist in the current context
script:using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class bl_ChatRoom : bl_PhotonHelper {
public GUISkin m_Skin;
[Space(5)]
public Text ChatText;
public bool IsVisible = true;
public bool WithSound = true;
public int MaxMsn = 7;
private List<string> messages = new List<string>();
private string inputLine = "";
[Space(5)]
public AudioClip MsnSound;
public static readonly string ChatRPC = "Chat";
private float m_alpha = 2f;
private bool isChat = false;
void Start()
{
Refresh();
}
public void OnGUI()
{
if (ChatText == null)
return;
if (m_alpha > 0.0f && !isChat)
{
m_alpha -= Time.deltaTime / 2;
}
else if (isChat)
{
m_alpha = 10;
}
Color t_color = ChatText.color;
t_color.a = m_alpha;
ChatText.color = t_color;
GUI.skin = m_Skin;
GUI.color = new Color(1, 1, 1, m_alpha);
if (!this.IsVisible || PhotonNetwork.connectionStateDetailed != PeerState.Joined)
{
return;
}
if (Event.current.type == EventType.KeyDown &&(Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
{
if (!string.IsNullOrEmpty(this.inputLine) && isChat && bl_UtilityHelper.GetCursorState)
{
this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
this.inputLine = "";
GUI.FocusControl("");
isChat = false;
return; // printing the now modified list would result in an error. to avoid this, we just skip this single frame
}
else if (!isChat && bl_UtilityHelper.GetCursorState)
{
GUI.FocusControl("MyChatInput");
isChat = true;
}
else
{
if (isChat)
{
Closet();
}
}
}
if (Event.current.type == EventType.keyDown && (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t'))
{
Event.current.Use();
}
GUI.SetNextControlName("");
GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height - 35, 300, 50));
GUILayout.BeginHorizontal();
GUI.SetNextControlName("MyChatInput");
inputLine = GUILayout.TextField(inputLine);
GUI.SetNextControlName("None");
if (GUILayout.Button("Send", "box", GUILayout.ExpandWidth(false)))
{
this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
this.inputLine = "";
GUI.FocusControl("");
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void Closet()
{
isChat = false;
GUI.FocusControl("");
}
/// <summary>
/// Sync Method
/// </summary>
/// <param name="newLine"></param>
/// <param name="mi"></param>
[PunRPC]
public void Chat(string newLine, PhotonMessageInfo mi)
{
m_alpha = 7;
string senderName = "anonymous";
if (mi != null && mi.sender != null)
{
if (!string.IsNullOrEmpty(mi.sender.name))
{
senderName = mi.sender.name;
}
else
{
senderName = "Player " + mi.sender.ID;
}
}
this.messages.Add("[" + senderName + "]: " + newLine);
if (MsnSound != null && WithSound)
{
GetComponent<AudioSource>().PlayOneShot(MsnSound);
}
if (messages.Count > MaxMsn)
{
messages.RemoveAt(0);
}
ChatText.text = "";
foreach (string m in messages)
ChatText.text += m + "\n";
}
/// <summary>
/// Local Method
/// </summary>
/// <param name="newLine"></param>
public void AddLine(string newLine)
{
m_alpha = 7;
this.messages.Add(newLine);
if (messages.Count > MaxMsn)
{
messages.RemoveAt(0);
}
}
public void Refresh()
{
ChatText.text = "";
foreach (string m in messages)
ChatText.text += m + "\n";
}
}
3º
Assets/MFPS/Scripts/Network/bl_ChatRoom.cs(116,13): error CS0019: Operator `!=' cannot be applied to operands of type `PhotonMessageInfo' and `null'
script:= o segundo
4º
Assets/MFPS/Scripts/Network/bl_FootSteps.cs(175,13): error CS0019: Operator `!=' cannot be applied to operands of type `PhotonMessageInfo' and `null'
script: = o primeiro
5º
Assets/MFPS/Scripts/Network/bl_PhotonConnection.cs(152,82): error CS0103: The name `PeerState' does not exist in the current context
script:using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using Random = UnityEngine.Random;
public class bl_PhotonConnection : Photon.MonoBehaviour {
private LobbyState m_state = LobbyState.PlayerName;
public LobbyType m_LobbyType = LobbyType.OnGUI;
private string playerName;
private string hostName; //Name of room
[Header("Photon")]
public string AppVersion = "1.0";
public int Port = 5055;
public float UpdateServerListEach = 2;
[Header("OnGUI")]
public GUISkin Skin;
private float alpha = 2.0f;
[Header("UGUI")]
public GameObject RoomInfoPrefab;
public Transform RoomListPanel;
public List<GameObject> MenusUI = new List<GameObject>();
public CanvasGroup CanvasGroupRoot = null;
public Text PhotonStatusText = null;
public Text PlayerNameText = null;
public Text MaxPlayerText = null;
public Text RoundTimeText = null;
public Text GameModeText = null;
public Text MapNameText = null;
public Text AntiStrpicText = null;
public Text QualityText = null;
public Text VolumenText = null;
public Text SensitivityText = null;
public Image MapPreviewImage = null;
public InputField PlayerNameField = null;
public InputField RoomNameField = null;
//OPTIONS
private int m_currentQuality = 3;
private float m_volume = 1.0f;
private float m_sensitive = 15;
private string[] m_stropicOptions = new string[] { "Disable", "Enable", "Force Enable" };
private int m_stropic = 0;
private bool GamePerRounds = false;
private bool AutoTeamSelection = false;
[Space(7)]
public bool ShowPhotonStatus = false;
public bool ShowPhotonStatics = true;
[HideInInspector]
public bool loading = false;
[Space(5)]
public string[] GameModes;
private int CurrentGameMode = 0;
//Max players in game
public int[] maxPlayers;
private int players;
//Room Time in seconds
public int[] RoomTime;
private int r_Time;
//SERVERLIST
private RoomInfo[] roomList;
private bool listRefreshed = false;
private Vector2 scroll;
private bool FirstConnect = false;
[Space(5)]
[Header("Effects")]
public AudioClip a_Click;
public AudioClip backSound;
[System.Serializable]
public class AllScenes
{
public string m_name;
public string m_SceneName;
public Sprite m_Preview;
}
public List<AllScenes> m_scenes = new List<AllScenes>();
private List<GameObject> CacheRoomList = new List<GameObject>();
private int CurrentScene = 0;
/// <summary>
///
/// </summary>
void Awake()
{
// this makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.autoJoinLobby = true;
hostName = "LovattoRoom" + Random.Range(10, 999);
if (m_LobbyType == LobbyType.UGUI && RoomNameField != null)
{
RoomNameField.text = hostName;
}
if (string.IsNullOrEmpty(PhotonNetwork.playerName))
{
// generate a name for this player, if none is assigned yet
if (String.IsNullOrEmpty(playerName))
{
playerName = "Guest" + Random.Range(1, 9999);
if (m_LobbyType == LobbyType.UGUI && PlayerNameField != null) { PlayerNameField.text = playerName; }
}
ChangeWindow(0);
}
else
{
StartCoroutine(Fade(LobbyState.MainMenu,1.2f));
StartCoroutine(RefresListIE());
if (!PhotonNetwork.connected)
{
ConnectPhoton();
}
ChangeWindow(2,1);
}
if (m_LobbyType == LobbyType.UGUI)
{
SetUpOptionsHost();
InvokeRepeating("UpdateServerList", 1, UpdateServerListEach);
}
GetPrefabs();
}
/// <summary>
///
/// </summary>
/// <param name="t_state"></param>
/// <returns></returns>
IEnumerator Fade(LobbyState t_state, float t = 2.0f)
{
alpha = 0.0f;
m_state = t_state;
loading = true;
while (alpha < t)
{
alpha += Time.deltaTime;
if (m_LobbyType == LobbyType.UGUI) { CanvasGroupRoot.alpha = alpha; }
yield return null;
}
loading = false;
}
/// <summary>
///
/// </summary>
void ConnectPhoton()
{
// the following line checks if this client was just created (and not yet online). if so, we connect
if (!PhotonNetwork.connected || PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
{
PhotonNetwork.AuthValues = null;
PhotonNetwork.ConnectUsingSettings(AppVersion);
if (m_LobbyType == LobbyType.UGUI) { ChangeWindow(3); }
}
}
/// <summary>
///
/// </summary>
void UpdateServerList()
{
ServerList();
}
/// <summary>
///
/// </summary>
void FixedUpdate()
{
if (m_LobbyType == LobbyType.UGUI)
{
if (PhotonNetwork.connected)
{
if (ShowPhotonStatus)
{
PhotonStatusText.text = "<b><color=orange>STATUS:</color> " + PhotonNetwork.connectionStateDetailed.ToString().ToUpper() + "</b>";
PlayerNameText.text = "<b><color=orange>PLAYER:</color> " + PhotonNetwork.player.name + "</b>";
}
}
}
}
/// <summary>
/// Menu For Enter Name for UI 4.6 WIP
/// </summary>
public void EnterName (InputField field = null){
if (m_LobbyType == LobbyType.OnGUI)
{
playerName = playerName.Replace("\n", "");
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 57, 375, 135), "<color=black>Player Name</color>", "window");
GUILayout.Space(10);
GUILayout.BeginHorizontal("box");
GUILayout.Label("Player Name : ");
GUILayout.Space(5);
GUI.SetNextControlName("user");
playerName = playerName.Replace("\n", "");
playerName = GUILayout.TextField(playerName, 20, GUILayout.Width(223), GUILayout.Height(33));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(10);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Quit", GUILayout.Width(100), GUILayout.Height(33)))
{
PlayAudioClip(backSound, transform.position, 1.0f);
m_state = LobbyState.Quit;
}
GUILayout.Space(100);
if (GUILayout.Button("Continue", GUILayout.Width(150), GUILayout.Height(33)))
{
if (playerName != string.Empty && playerName.Length > 3)
{
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
StartCoroutine(RefresListIE());
PhotonNetwork.playerName = playerName;
ConnectPhoton();
}
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
else
{
if (field == null || string.IsNullOrEmpty(field.text))
return;
playerName = field.text;
playerName = playerName.Replace("\n", "");
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
StartCoroutine(RefresListIE());
PhotonNetwork.playerName = playerName;
ConnectPhoton();
}
}
#region UGUI
/// <summary>
/// For button can call this
/// </summary>
/// <param name="id"></param>
public void ChangeWindow(int id)
{
ChangeWindow(id, -1);
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
public void ChangeWindow(int id, int id2)
{
StartCoroutine(Fade(LobbyState.MainMenu,3f));
for (int i = 0; i < MenusUI.Count; i++)
{
if (i == id || i == id2)
{
MenusUI[i].SetActive(true);
}
else
{
if (i != 1)//1 = mainmenu buttons
{
MenusUI[i].SetActive(false);
}
if (id == 6 || id ==
{
MenusUI[1].SetActive(false);
}
}
}
if (a_Click != null)
{
AudioSource.PlayClipAtPoint(a_Click, this.transform.position, 1.0f);
}
}
public void Disconect()
{
if (PhotonNetwork.connected)
{ PhotonNetwork.Disconnect(); }
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
public void ChangeServerCloud(int id)
{
if (PhotonNetwork.connected)
{
PhotonNetwork.Disconnect();
Debug.LogWarning("Try again, because still not disconect");
return;
}
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
switch (id)
{
case 0:
PhotonNetwork.ConnectToRegion(CloudRegionCode.us, AppVersion);
break;
case 1:
PhotonNetwork.ConnectToRegion(CloudRegionCode.asia, AppVersion);
break;
case 2:
PhotonNetwork.ConnectToRegion(CloudRegionCode.au, AppVersion);
break;
case 3:
PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, AppVersion);
break;
case 4:
PhotonNetwork.ConnectToRegion(CloudRegionCode.jp, AppVersion);
break;
}
PlayAudioClip(a_Click, transform.position, 1.0f);
}
else
{
Debug.LogWarning("Need your AppId for changer server, please add it in inspector");
}
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeMaxPlayer(bool plus)
{
if (plus)
{
if (players < maxPlayers.Length)
{
players++;
if (players > (maxPlayers.Length - 1)) players = 0;
}
}
else
{
if (players < maxPlayers.Length)
{
players--;
if (players < 0) players = maxPlayers.Length - 1;
}
}
MaxPlayerText.text = maxPlayers[players] + " Players";
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeRoundTime(bool plus)
{
if (!plus)
{
if (r_Time < RoomTime.Length)
{
r_Time--;
if (r_Time < 0)
{
r_Time = RoomTime.Length - 1;
}
}
}
else
{
if (r_Time < RoomTime.Length)
{
r_Time++;
if (r_Time > (RoomTime.Length - 1))
{
r_Time = 0;
}
}
}
RoundTimeText.text = (RoomTime[r_Time] / 60) + " Minutes";
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeGameMode(bool plus)
{
if (plus)
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode++;
if (CurrentGameMode > (GameModes.Length - 1))
{
CurrentGameMode = 0;
}
}
}
else
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode--;
if (CurrentGameMode < 0)
{
CurrentGameMode = GameModes.Length - 1;
}
}
}
GameModeText.text = GameModes[CurrentGameMode];
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeMap(bool plus)
{
if (!plus)
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene--;
if (CurrentScene < 0)
{
CurrentScene = m_scenes.Count - 1;
}
}
}
else
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene++;
if (CurrentScene > (m_scenes.Count - 1))
{
CurrentScene = 0;
}
}
}
MapNameText.text = m_scenes[CurrentScene].m_name;
MapPreviewImage.sprite = m_scenes[CurrentScene].m_Preview;
}
public void ChangeAntiStropic(bool plus)
{
if (!plus)
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic--;
if (m_stropic < 0)
{
m_stropic = m_stropicOptions.Length - 1;
}
}
}
else
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic++;
if (m_stropic > (m_stropicOptions.Length - 1))
{
m_stropic = 0;
}
}
}
AntiStrpicText.text = m_stropicOptions[m_stropic];
}
public void ChangeQuality(bool plus)
{
if (!plus)
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality--;
if (m_currentQuality < 0)
{
m_currentQuality = QualitySettings.names.Length - 1;
}
}
}
else
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality++;
if (m_currentQuality > (QualitySettings.names.Length - 1))
{
m_currentQuality = 0;
}
}
}
QualityText.text = QualitySettings.names[m_currentQuality];
}
/// <summary>
///
/// </summary>
/// <param name="b"></param>
public void QuitGame(bool b)
{
if (b)
{
Application.Quit();
Debug.Log("Game Exit, this only work in standalone version");
}
else
{
StartCoroutine(Fade(LobbyState.MainMenu, 3.2f));
ChangeWindow(2, 1);
}
}
public void ChangeAutoTeamSelection(bool b) { AutoTeamSelection = b; }
public void ChangeGamePerRound(bool b) { GamePerRounds = b; }
public void ChangeRoomName(string t) { hostName = t; }
public void ChangeVolume(float v) { m_volume = v; VolumenText.text = (m_volume * 100).ToString("00") +"%"; }
public void ChangeSensitivity(float s) { m_sensitive = s; SensitivityText.text = m_sensitive.ToString("00") + "%"; }
/// <summary>
///
/// </summary>
void SetUpOptionsHost()
{
MaxPlayerText.text = maxPlayers[players] + " Players";
RoundTimeText.text = (RoomTime[r_Time] / 60) + " Minutes";
GameModeText.text = GameModes[CurrentGameMode];
MapNameText.text = m_scenes[CurrentScene].m_name;
MapPreviewImage.sprite = m_scenes[CurrentScene].m_Preview;
AntiStrpicText.text = m_stropicOptions[m_stropic];
SensitivityText.text = m_sensitive.ToString("00") + "%";
VolumenText.text = (m_volume * 100).ToString("00") + "%";
QualityText.text = QualitySettings.names[m_currentQuality];
}
public void Save()
{
PlayerPrefs.SetFloat("volumen", m_volume);
PlayerPrefs.SetFloat("sensitive", m_sensitive);
PlayerPrefs.SetInt("quality", m_currentQuality);
PlayerPrefs.SetInt("anisotropic", m_stropic);
Debug.Log("Save Done!");
}
#endregion
#region OnGUI
/// <summary>
///
/// </summary>
void OnGUI()
{
if (m_LobbyType != LobbyType.OnGUI)
return;
GUI.skin = Skin;
if (m_state == LobbyState.ChangeServer)
{
SelectServer();
}
if (m_state == LobbyState.PlayerName)
{
EnterName();
}
if (PhotonNetwork.connected && !PhotonNetwork.connecting)
{
FirstConnect = true;
if (m_state == LobbyState.PlayerName)
{
GUI.Label(new Rect(Screen.width - 150, 20, 150, 30), "<b><size=14> Version 1.0f </size></b>");
}
if (ShowPhotonStatus)
{
GUI.Label(new Rect(0, 55, 500, 20), " <b><color=orange> Status:</color> " + PhotonNetwork.connectionStateDetailed.ToString() + "</b>");
GUI.Label(new Rect(0, 80, 500, 20), " <b><color=orange> Player:</color> " + PhotonNetwork.player.name + "</b>");
}
if (ShowPhotonStatics)
{
ShowStaticSever();
}
if (loading && m_state != LobbyState.PlayerName)
{
GUI.enabled = false;
}
else
{
GUI.enabled = true;
}
//Everything after this line will be affected when we will change "alpha"
GUI.color = new Color(1.0f, 1.0f, 1.0f, alpha);
if (m_state != LobbyState.PlayerName)
{
MainMenu();
}
if (m_state == LobbyState.PlayerName)
{
EnterName();
}
else if (m_state == LobbyState.Join)
{
ServerList();
}
else if (m_state == LobbyState.MainMenu)
{
ServerList();
}
else if (m_state == LobbyState.Host)
{
CreateServer();
}
else if (m_state == LobbyState.Settings)
{
Settings();
}
else if (m_state == LobbyState.Quit)
{
QuitGame();
}
if (m_state != LobbyState.PlayerName && m_state != LobbyState.MainMenu)
{
ButtonBack();
}
}
else if (!FirstConnect)
{
if (PhotonNetwork.connecting)
{
GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 60), "Connecting...", "window");
}
else
{
GUILayout.Label("Not connected. Check console output. (" + PhotonNetwork.connectionState + ")");
}
}
}
/// <summary>
///
/// </summary>
/// <param name="field"></param>
public void CancelEnterName(InputField field)
{
field.text = "Player (" + Random.Range(0, 9999) + ")";
}
/// <summary>
/// Menu GUI for select a server to connect
/// </summary>
void SelectServer()
{
if (PhotonNetwork.connected)
{
PhotonNetwork.Disconnect();
}
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 150, 350, 300), "", "window");
GUILayout.Space(10);
GUILayout.Label("Available Regions");
GUILayout.Space(10);
if (GUILayout.Button("US (East Coast)",GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-us.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("EU (Amsterdam)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-eu.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Asia (Singapore)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-asia.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Japan (Tokyo)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-jp.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Australia (Melbourne) ", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-au.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
GUILayout.EndArea();
GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 165, 400, 100), "Choose the server nearest your location\n since this depends on the <color=orange>Ping.</color>");
}
/// <summary>
///
/// </summary>
void MainMenu (){
GUILayout.BeginArea(new Rect(0,0,Screen.width,60));
GUILayout.BeginHorizontal();
if (GUILayout.Button("Search Room", GUILayout.Height(GetButtonSize(LobbyState.Join))))
{
m_state = LobbyState.Join;
StartCoroutine(RefresListIE());
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Host Room", GUILayout.Height(GetButtonSize(LobbyState.Host))))
{
m_state = LobbyState.Host;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Setting", GUILayout.Height(GetButtonSize(LobbyState.Settings))))
{
m_state = LobbyState.Settings;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Change Server", GUILayout.Height(GetButtonSize(LobbyState.ChangeServer))))
{
m_state = LobbyState.ChangeServer;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Quit", GUILayout.Height(GetButtonSize(LobbyState.Quit))))
{
m_state = LobbyState.Quit;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void CreateServer()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 225, Screen.height / 2 - 165, 450, 400), "", "window");
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Space(15);
GUI.Box(new Rect(30, 35, 150, 30), "Host Name: ");
hostName = hostName.Replace("\n", "");
hostName = GUI.TextField(new Rect(200, 35, 220, 30), hostName, 20);
//Max Player Select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 70, 150, 30), "Max Players: ");
if (GUI.Button(new Rect(200, 70, 40, 30), "<<", "Box"))
{
if (players < maxPlayers.Length)
{
players--;
if (players < 0) players = maxPlayers.Length - 1;
}
}
GUI.Box(new Rect(260, 70, 100, 30), maxPlayers[players].ToString());
if (GUI.Button(new Rect(380, 70, 40, 30), ">>", "Box"))
{
if (players < maxPlayers.Length)
{
players++;
if (players > (maxPlayers.Length - 1)) players = 0;
}
}
GUILayout.EndHorizontal();
//Room Time select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 110, 150, 30), "Max Time: ");
if (GUI.Button(new Rect(200, 110, 40, 30), "<<", "Box"))
{
if (r_Time < RoomTime.Length)
{
r_Time--;
if (r_Time < 0)
{
r_Time = RoomTime.Length - 1;
}
}
}
GUI.Box(new Rect(260, 110, 100, 30), (RoomTime[r_Time] / 60) + " <size=12>Min</size>");
if (GUI.Button(new Rect(380, 110, 40, 30), ">>", "Box"))
{
if (r_Time < RoomTime.Length)
{
r_Time++;
if (r_Time > (RoomTime.Length - 1))
{
r_Time = 0;
}
}
}
GUILayout.EndHorizontal();
//GameMode Select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 150, 150, 30), "Game Mode: ");
if (GUI.Button(new Rect(200, 150, 40, 30), "<<", "Box"))
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode--;
if (CurrentGameMode < 0)
{
CurrentGameMode = GameModes.Length - 1;
}
}
}
GUI.Box(new Rect(260, 150, 100, 30), GameModes[CurrentGameMode]);
if (GUI.Button(new Rect(380, 150, 40, 30), ">>", "Box"))
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode++;
if (CurrentGameMode > (GameModes.Length - 1))
{
CurrentGameMode = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUI.Button(new Rect(25, 190, 75, 30), "<<", "Box"))
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene--;
if (CurrentScene < 0)
{
CurrentScene = m_scenes.Count - 1;
}
}
}
GUI.DrawTexture(new Rect(100, 190, 250, 100), m_scenes[CurrentScene].m_Preview.texture);
GUI.Box(new Rect(100, 265, 250, 25), m_scenes[CurrentScene].m_name);
if (GUI.Button(new Rect(350, 190, 75, 30), ">>", "Box"))
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene++;
if (CurrentScene > (m_scenes.Count - 1))
{
CurrentScene = 0;
}
}
}
GUILayout.EndHorizontal();
GamePerRounds = GUI.Toggle(new Rect(265, 300, 200, 30), GamePerRounds, "Game Per Rounds");
AutoTeamSelection = GUI.Toggle(new Rect(30, 300, 200, 30), AutoTeamSelection, "Auto Team Selection");
GUILayout.BeginHorizontal();
//Create a new Room with Photon
if (GUI.Button(new Rect(150, 330, 175, 50), "Create Room"))
{
CreateRoom();
}
GUILayout.Space(20);
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void ServerList()
{
if (m_LobbyType == LobbyType.OnGUI)
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 180, 800, 400), Skin.customStyles[3]);
GUI.Box(new Rect(25, 10, 150, 35), "Host Name");
GUI.Box(new Rect(180, 10, 140, 35), "Map Name");
GUI.Box(new Rect(325, 10, 130, 35), "Game Mode");
GUI.Box(new Rect(460, 10, 80, 35), "Players");
GUI.Box(new Rect(545, 10, 60, 35), "Ping");
//Refresh ServerList
if (GUI.Button(new Rect(610, 10, 130, 35), "Refresh"))
{
StartCoroutine(RefresListIE());
}
scroll = GUI.BeginScrollView(new Rect(10, 67, 770, 315), scroll, new Rect(0, 0, 220, 1000), false, true);
if (listRefreshed && !loading)
{
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
GUILayout.BeginHorizontal("Label");
GUILayout.Box(room.name, GUILayout.Width(150), GUILayout.Height(30));
GUILayout.Box((string)room.customProperties[PropiertiesKeys.SceneNameKey], GUILayout.Width(140), GUILayout.Height(30));
GUILayout.Box((string)room.customProperties[PropiertiesKeys.GameModeKey], GUILayout.Width(130), GUILayout.Height(30));
GUILayout.Box(room.playerCount + "/" + room.maxPlayers, GUILayout.Width(80), GUILayout.Height(30));
GUILayout.Box(PhotonNetwork.GetPing().ToString(), GUILayout.Width(60), GUILayout.Height(30));
if (GUILayout.Button("Join Game", GUILayout.Width(120), GUILayout.Height(30)))
{
if (room.playerCount < room.maxPlayers)
{
PhotonNetwork.JoinRoom(room.name);
PhotonNetwork.playerName = playerName;
}
}
GUILayout.EndHorizontal();
}
if (roomList.Length == 0 && !loading) GUI.Label(new Rect(320, 150, 200, 30), "No room created ... create one.");
}
GUI.EndScrollView();
GUILayout.EndArea();
}
else
{
//Removed old list
if (CacheRoomList.Count > 0)
{
foreach (GameObject g in CacheRoomList)
{
Destroy(g);
}
CacheRoomList.Clear();
}
//Update List
RoomInfo[] ri = PhotonNetwork.GetRoomList();
if (ri.Length > 0)
{
http://RoomListText.text = string.Empty;
for (int i = 0; i < ri.Length; i++)
{
GameObject r = Instantiate(RoomInfoPrefab) as GameObject;
CacheRoomList.Add(r);
r.GetComponent<bl_RoomInfo>().GetInfo(ri[i]);
r.transform.SetParent(RoomListPanel, false);
}
}
else
{
// RoomListText.text = "There is no room created yet, create your one.";
}
}
}
/// <summary>
/// Menu GUI for settings
/// </summary>
void Settings()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 170, 500, 350), "", "window");
GUILayout.Space(10);
GUILayout.Box("Setting");
GUILayout.Label("Quality Level");
GUILayout.BeginHorizontal();
if (GUILayout.Button("<<"))
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality--;
if (m_currentQuality < 0)
{
m_currentQuality = QualitySettings.names.Length - 1;
}
}
}
GUILayout.Box(QualitySettings.names[m_currentQuality]);
if (GUILayout.Button(">>"))
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality++;
if (m_currentQuality > (QualitySettings.names.Length - 1))
{
m_currentQuality = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.Label("Anisotropic Filtering");
GUILayout.BeginHorizontal();
if (GUILayout.Button("<<"))
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic--;
if (m_stropic < 0)
{
m_stropic = m_stropicOptions.Length - 1;
}
}
}
GUILayout.Box(m_stropicOptions[m_stropic]);
if (GUILayout.Button(">>"))
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic++;
if (m_stropic > (m_stropicOptions.Length - 1))
{
m_stropic = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.Label("Sound Volume");
GUILayout.BeginHorizontal();
m_volume = GUILayout.HorizontalSlider(m_volume, 0.0f, 1.0f);
GUILayout.Label((m_volume * 100).ToString("000"), GUILayout.Width(30));
GUILayout.EndHorizontal();
GUILayout.Label("Sensitivity");
GUILayout.BeginHorizontal();
m_sensitive = GUILayout.HorizontalSlider(m_sensitive, 0.0f, 100.0f);
GUILayout.Label(m_sensitive.ToString("000"), GUILayout.Width(30));
GUILayout.EndHorizontal();
if (GUILayout.Button("Save"))
{
Save();
}
GUILayout.EndArea();
}
/// <summary>
/// a simple window for quit of game (only work in Window o Mac Build)
/// if you use Web Player, not need this
/// </summary>
void QuitGame()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 100, 300, 150), "Quit", "window");
GUILayout.Space(35);
GUILayout.Label("Are you sure you want to exit game?");
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Space(35);
if (GUILayout.Button("Cancel", GUILayout.Width(100), GUILayout.Height(35)))
{
StartCoroutine(Fade(LobbyState.MainMenu));
}
GUILayout.Space(15);
if (GUILayout.Button("Ok", GUILayout.Width(100), GUILayout.Height(35)))
{
Application.Quit();
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
void ButtonBack()
{
GUILayout.BeginArea(new Rect(10, (Screen.height - 35), 200, 100));
if (GUILayout.Button("Back", GUILayout.Height(35)))
{
PlayAudioClip(backSound, transform.position, 1.0f);
listRefreshed = false;
StartCoroutine(Fade(LobbyState.MainMenu));
}
GUILayout.EndArea();
}
void ShowStaticSever()
{
GUILayout.BeginArea(new Rect(225, Screen.height - 35, Screen.width - 225, 50));
GUILayout.BeginHorizontal();
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayersInRooms + "</color> Players in Rooms");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayersOnMaster + "</color> Players in Lobby");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayers + "</color> Players in Server");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfRooms + "</color> Room are Create");
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
#endregion
/// <summary>
///
/// </summary>
public void CreateRoom()
{
PhotonNetwork.player.name = playerName;
//Save Room properties for load in room
ExitGames.Client.Photon.Hashtable roomOption = new ExitGames.Client.Photon.Hashtable();
roomOption[PropiertiesKeys.TimeRoomKey] = RoomTime[r_Time];
roomOption[PropiertiesKeys.GameModeKey] = GameModes[CurrentGameMode];
roomOption[PropiertiesKeys.SceneNameKey] = m_scenes[CurrentScene].m_SceneName;
roomOption[PropiertiesKeys.RoomRoundKey] = GamePerRounds ? "1" : "0";
roomOption[PropiertiesKeys.TeamSelectionKey] = AutoTeamSelection ? "1" : "0";
string[] properties = new string[5];
properties[0] = PropiertiesKeys.TimeRoomKey;
properties[1] = PropiertiesKeys.GameModeKey;
properties[2] = PropiertiesKeys.SceneNameKey;
properties[3] = PropiertiesKeys.RoomRoundKey;
properties[4] = PropiertiesKeys.TeamSelectionKey;
PhotonNetwork.CreateRoom(hostName, new RoomOptions()
{
maxPlayers = (byte)maxPlayers[players],
isVisible = true,
isOpen = true,
customRoomProperties = roomOption,
cleanupCacheOnLeave = true,
customRoomPropertiesForLobby = properties
}, null);
}
/// <summary>
/// get the list of rooms available to join
/// </summary>
/// <returns></returns>
IEnumerator RefresListIE (){
loading = true;
yield return new WaitForSeconds( 1.0f);
roomList = PhotonNetwork.GetRoomList();
loading = false;
listRefreshed = true;
}
/// <summary>
///
/// </summary>
/// <param name="clip"></param>
/// <param name="position"></param>
/// <param name="volume"></param>
/// <returns></returns>
AudioSource PlayAudioClip ( AudioClip clip , Vector3 position , float volume ){
GameObject go= new GameObject ("One shot audio");
go.transform.position = position;
AudioSource source = go.AddComponent<AudioSource>();
source.clip = clip;
source.volume = volume;
source.Play ();
Destroy (go, clip.length);
return source;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
private IEnumerator MoveToGameScene()
{
//Wait for check
while (PhotonNetwork.room == null)
{
yield return 0;
}
PhotonNetwork.isMessageQueueRunning = false;
Application.LoadLevel((string)PhotonNetwork.room.customProperties[PropiertiesKeys.SceneNameKey]);
}
// LOBBY EVENTS
void OnJoinedLobby()
{
Debug.Log("We joined the lobby.");
if (m_LobbyType == LobbyType.UGUI)
{
StartCoroutine(Fade(LobbyState.MainMenu));
ChangeWindow(2,1);
}
}
void OnLeftLobby()
{
Debug.Log("We left the lobby.");
}
// ROOMLIST
void OnReceivedRoomList()
{
Debug.Log("We received a new room list, total rooms: " + PhotonNetwork.GetRoomList().Length);
}
void OnReceivedRoomListUpdate()
{
Debug.Log("We received a room list update, total rooms now: " + PhotonNetwork.GetRoomList().Length);
}
void OnJoinedRoom (){
Debug.Log("We have joined a room.");
StartCoroutine(MoveToGameScene());
}
void OnFailedToConnectToPhoton ( DisconnectCause cause ){
Debug.LogWarning("OnFailedToConnectToPhoton: " + cause);
loading = false;
}
void OnConnectionFail(DisconnectCause cause)
{
Debug.LogWarning("OnConnectionFail: " + cause);
}
void GetPrefabs()
{
if (PlayerPrefs.HasKey("volumen"))
{
m_volume = PlayerPrefs.GetFloat("volumen");
AudioListener.volume = m_volume;
}
if (PlayerPrefs.HasKey("sensitive"))
{
m_sensitive = PlayerPrefs.GetFloat("sensitive");
}
if (PlayerPrefs.HasKey("quality"))
{
m_currentQuality = PlayerPrefs.GetInt("quality");
}
if (PlayerPrefs.HasKey("anisotropic"))
{
m_stropic = PlayerPrefs.GetInt("anisotropic");
}
}
private int GetButtonSize(LobbyState t_state)
{
if (m_state == t_state)
{
return 55;
}
else
{
return 40;
}
}
[System.Serializable]
public enum LobbyType
{
UGUI,
OnGUI,
}
}
Assets/MFPS/Scripts/Network/bl_FootSteps.cs(173,80): error CS1750: Optional parameter expression of type `null' cannot be converted to parameter type `PhotonMessageInfo'
script:using UnityEngine;
using System.Collections;
public class bl_FootSteps : bl_PhotonHelper
{
[HideInInspector]
public bool CanUpdate = true;
public bool CanSyncSteps = true;
[Header("Sounds Lists")]
public AudioClip[] m_dirtSounds;
public AudioClip[] m_concreteSounds;
public AudioClip[] m_WoodSounds;
public AudioClip[] m_WaterSounds;
[Header("Settings")]
public float m_minSpeed = 2f;
public float m_maxSpeed = 8f;
public float audioStepLengthCrouch = 0.65f;
public float audioStepLengthWalk = 0.45f;
public float audioStepLengthRun = 0.25f;
public float audioVolumeCrouch = 0.3f;
public float audioVolumeWalk = 0.4f;
public float audioVolumeRun = 1.0f;
[Space(5)]
public AudioSource InstanceReference;
public PhotonView m_view;
//private
private bool isStep = true;
private string m_MaterialHit;
private Vector3 LastPost = Vector3.zero;
/// <summary>
///
/// </summary>
void Update()
{
if (!CanUpdate)//if remote is not updated, only receives the RPC call (optimization helps)
return;
if (InstanceReference == null)
return;
if (!isStep)
return;
RaycastHit hit;
if (Physics.Raycast(transform.position, -Vector3.up, out hit, 10))
{
m_MaterialHit = hit.collider.transform.tag;
}
float m_magnitude = m_charactercontroller.velocity.magnitude;
if (m_charactercontroller.isGrounded && isStep)
{
if (m_magnitude < m_minSpeed && m_magnitude > 0.75f)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Crouch", m_MaterialHit);
}
SyncSteps("Crouch", m_MaterialHit);
}
else if (m_magnitude > m_minSpeed && m_magnitude < m_maxSpeed)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Walk", m_MaterialHit);
}
SyncSteps("Walk", m_MaterialHit);
}
else if (m_magnitude > m_maxSpeed)
{
if (CanSyncSteps && !PhotonNetwork.offlineMode)
{
m_view.RPC("SyncSteps", PhotonTargets.Others, "Run", m_MaterialHit);
}
SyncSteps("Run", m_MaterialHit);
}
}
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Crouch(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeCrouch, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthCrouch);
isStep = true;
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Walk(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeWalk, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthWalk);
isStep = true;
}
/// <summary>
///
/// </summary>
/// <param name="m_material"></param>
/// <returns></returns>
IEnumerator Run(string m_material)
{
if (InstanceReference.GetComponent<AudioSource>() == null)
yield return null;
isStep = false;
switch (m_material)
{
case "Dirt":
bl_UtilityHelper.PlayClipAtPoint(m_dirtSounds[Random.Range(0, m_dirtSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Concrete":
bl_UtilityHelper.PlayClipAtPoint(m_concreteSounds[Random.Range(0, m_concreteSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Wood":
bl_UtilityHelper.PlayClipAtPoint(m_WoodSounds[Random.Range(0, m_WoodSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
case "Water":
bl_UtilityHelper.PlayClipAtPoint(m_WaterSounds[Random.Range(0, m_WaterSounds.Length)], LastPost, audioVolumeRun, InstanceReference);
break;
}
yield return new WaitForSeconds(audioStepLengthRun);
isStep = true;
}
[PunRPC]
void SyncSteps(string t_corrutine,string m_material,PhotonMessageInfo m_info =null )
{
if (m_info != null)
{
if (m_info.sender.name == gameObject.name)
{
GameObject player = FindPlayerRoot(m_info.photonView.viewID);
LastPost = player.transform.position;
StartCoroutine(t_corrutine, m_material);
}
}
else
{
LastPost = this.InstanceReference.transform.position;
StartCoroutine(t_corrutine, m_material);
}
}
public void OffUpdate()
{
CanUpdate = false;
}
public CharacterController m_charactercontroller
{
get
{
return this.transform.root.GetComponent<CharacterController>();
}
}
}
2º
Assets/MFPS/Scripts/Network/bl_ChatRoom.cs(48,73): error CS0103: The name `PeerState' does not exist in the current context
script:using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public class bl_ChatRoom : bl_PhotonHelper {
public GUISkin m_Skin;
[Space(5)]
public Text ChatText;
public bool IsVisible = true;
public bool WithSound = true;
public int MaxMsn = 7;
private List<string> messages = new List<string>();
private string inputLine = "";
[Space(5)]
public AudioClip MsnSound;
public static readonly string ChatRPC = "Chat";
private float m_alpha = 2f;
private bool isChat = false;
void Start()
{
Refresh();
}
public void OnGUI()
{
if (ChatText == null)
return;
if (m_alpha > 0.0f && !isChat)
{
m_alpha -= Time.deltaTime / 2;
}
else if (isChat)
{
m_alpha = 10;
}
Color t_color = ChatText.color;
t_color.a = m_alpha;
ChatText.color = t_color;
GUI.skin = m_Skin;
GUI.color = new Color(1, 1, 1, m_alpha);
if (!this.IsVisible || PhotonNetwork.connectionStateDetailed != PeerState.Joined)
{
return;
}
if (Event.current.type == EventType.KeyDown &&(Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
{
if (!string.IsNullOrEmpty(this.inputLine) && isChat && bl_UtilityHelper.GetCursorState)
{
this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
this.inputLine = "";
GUI.FocusControl("");
isChat = false;
return; // printing the now modified list would result in an error. to avoid this, we just skip this single frame
}
else if (!isChat && bl_UtilityHelper.GetCursorState)
{
GUI.FocusControl("MyChatInput");
isChat = true;
}
else
{
if (isChat)
{
Closet();
}
}
}
if (Event.current.type == EventType.keyDown && (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t'))
{
Event.current.Use();
}
GUI.SetNextControlName("");
GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height - 35, 300, 50));
GUILayout.BeginHorizontal();
GUI.SetNextControlName("MyChatInput");
inputLine = GUILayout.TextField(inputLine);
GUI.SetNextControlName("None");
if (GUILayout.Button("Send", "box", GUILayout.ExpandWidth(false)))
{
this.photonView.RPC("Chat", PhotonTargets.All, this.inputLine);
this.inputLine = "";
GUI.FocusControl("");
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void Closet()
{
isChat = false;
GUI.FocusControl("");
}
/// <summary>
/// Sync Method
/// </summary>
/// <param name="newLine"></param>
/// <param name="mi"></param>
[PunRPC]
public void Chat(string newLine, PhotonMessageInfo mi)
{
m_alpha = 7;
string senderName = "anonymous";
if (mi != null && mi.sender != null)
{
if (!string.IsNullOrEmpty(mi.sender.name))
{
senderName = mi.sender.name;
}
else
{
senderName = "Player " + mi.sender.ID;
}
}
this.messages.Add("[" + senderName + "]: " + newLine);
if (MsnSound != null && WithSound)
{
GetComponent<AudioSource>().PlayOneShot(MsnSound);
}
if (messages.Count > MaxMsn)
{
messages.RemoveAt(0);
}
ChatText.text = "";
foreach (string m in messages)
ChatText.text += m + "\n";
}
/// <summary>
/// Local Method
/// </summary>
/// <param name="newLine"></param>
public void AddLine(string newLine)
{
m_alpha = 7;
this.messages.Add(newLine);
if (messages.Count > MaxMsn)
{
messages.RemoveAt(0);
}
}
public void Refresh()
{
ChatText.text = "";
foreach (string m in messages)
ChatText.text += m + "\n";
}
}
3º
Assets/MFPS/Scripts/Network/bl_ChatRoom.cs(116,13): error CS0019: Operator `!=' cannot be applied to operands of type `PhotonMessageInfo' and `null'
script:= o segundo
4º
Assets/MFPS/Scripts/Network/bl_FootSteps.cs(175,13): error CS0019: Operator `!=' cannot be applied to operands of type `PhotonMessageInfo' and `null'
script: = o primeiro
5º
Assets/MFPS/Scripts/Network/bl_PhotonConnection.cs(152,82): error CS0103: The name `PeerState' does not exist in the current context
script:using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using Random = UnityEngine.Random;
public class bl_PhotonConnection : Photon.MonoBehaviour {
private LobbyState m_state = LobbyState.PlayerName;
public LobbyType m_LobbyType = LobbyType.OnGUI;
private string playerName;
private string hostName; //Name of room
[Header("Photon")]
public string AppVersion = "1.0";
public int Port = 5055;
public float UpdateServerListEach = 2;
[Header("OnGUI")]
public GUISkin Skin;
private float alpha = 2.0f;
[Header("UGUI")]
public GameObject RoomInfoPrefab;
public Transform RoomListPanel;
public List<GameObject> MenusUI = new List<GameObject>();
public CanvasGroup CanvasGroupRoot = null;
public Text PhotonStatusText = null;
public Text PlayerNameText = null;
public Text MaxPlayerText = null;
public Text RoundTimeText = null;
public Text GameModeText = null;
public Text MapNameText = null;
public Text AntiStrpicText = null;
public Text QualityText = null;
public Text VolumenText = null;
public Text SensitivityText = null;
public Image MapPreviewImage = null;
public InputField PlayerNameField = null;
public InputField RoomNameField = null;
//OPTIONS
private int m_currentQuality = 3;
private float m_volume = 1.0f;
private float m_sensitive = 15;
private string[] m_stropicOptions = new string[] { "Disable", "Enable", "Force Enable" };
private int m_stropic = 0;
private bool GamePerRounds = false;
private bool AutoTeamSelection = false;
[Space(7)]
public bool ShowPhotonStatus = false;
public bool ShowPhotonStatics = true;
[HideInInspector]
public bool loading = false;
[Space(5)]
public string[] GameModes;
private int CurrentGameMode = 0;
//Max players in game
public int[] maxPlayers;
private int players;
//Room Time in seconds
public int[] RoomTime;
private int r_Time;
//SERVERLIST
private RoomInfo[] roomList;
private bool listRefreshed = false;
private Vector2 scroll;
private bool FirstConnect = false;
[Space(5)]
[Header("Effects")]
public AudioClip a_Click;
public AudioClip backSound;
[System.Serializable]
public class AllScenes
{
public string m_name;
public string m_SceneName;
public Sprite m_Preview;
}
public List<AllScenes> m_scenes = new List<AllScenes>();
private List<GameObject> CacheRoomList = new List<GameObject>();
private int CurrentScene = 0;
/// <summary>
///
/// </summary>
void Awake()
{
// this makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.autoJoinLobby = true;
hostName = "LovattoRoom" + Random.Range(10, 999);
if (m_LobbyType == LobbyType.UGUI && RoomNameField != null)
{
RoomNameField.text = hostName;
}
if (string.IsNullOrEmpty(PhotonNetwork.playerName))
{
// generate a name for this player, if none is assigned yet
if (String.IsNullOrEmpty(playerName))
{
playerName = "Guest" + Random.Range(1, 9999);
if (m_LobbyType == LobbyType.UGUI && PlayerNameField != null) { PlayerNameField.text = playerName; }
}
ChangeWindow(0);
}
else
{
StartCoroutine(Fade(LobbyState.MainMenu,1.2f));
StartCoroutine(RefresListIE());
if (!PhotonNetwork.connected)
{
ConnectPhoton();
}
ChangeWindow(2,1);
}
if (m_LobbyType == LobbyType.UGUI)
{
SetUpOptionsHost();
InvokeRepeating("UpdateServerList", 1, UpdateServerListEach);
}
GetPrefabs();
}
/// <summary>
///
/// </summary>
/// <param name="t_state"></param>
/// <returns></returns>
IEnumerator Fade(LobbyState t_state, float t = 2.0f)
{
alpha = 0.0f;
m_state = t_state;
loading = true;
while (alpha < t)
{
alpha += Time.deltaTime;
if (m_LobbyType == LobbyType.UGUI) { CanvasGroupRoot.alpha = alpha; }
yield return null;
}
loading = false;
}
/// <summary>
///
/// </summary>
void ConnectPhoton()
{
// the following line checks if this client was just created (and not yet online). if so, we connect
if (!PhotonNetwork.connected || PhotonNetwork.connectionStateDetailed == PeerState.PeerCreated)
{
PhotonNetwork.AuthValues = null;
PhotonNetwork.ConnectUsingSettings(AppVersion);
if (m_LobbyType == LobbyType.UGUI) { ChangeWindow(3); }
}
}
/// <summary>
///
/// </summary>
void UpdateServerList()
{
ServerList();
}
/// <summary>
///
/// </summary>
void FixedUpdate()
{
if (m_LobbyType == LobbyType.UGUI)
{
if (PhotonNetwork.connected)
{
if (ShowPhotonStatus)
{
PhotonStatusText.text = "<b><color=orange>STATUS:</color> " + PhotonNetwork.connectionStateDetailed.ToString().ToUpper() + "</b>";
PlayerNameText.text = "<b><color=orange>PLAYER:</color> " + PhotonNetwork.player.name + "</b>";
}
}
}
}
/// <summary>
/// Menu For Enter Name for UI 4.6 WIP
/// </summary>
public void EnterName (InputField field = null){
if (m_LobbyType == LobbyType.OnGUI)
{
playerName = playerName.Replace("\n", "");
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 57, 375, 135), "<color=black>Player Name</color>", "window");
GUILayout.Space(10);
GUILayout.BeginHorizontal("box");
GUILayout.Label("Player Name : ");
GUILayout.Space(5);
GUI.SetNextControlName("user");
playerName = playerName.Replace("\n", "");
playerName = GUILayout.TextField(playerName, 20, GUILayout.Width(223), GUILayout.Height(33));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(10);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Quit", GUILayout.Width(100), GUILayout.Height(33)))
{
PlayAudioClip(backSound, transform.position, 1.0f);
m_state = LobbyState.Quit;
}
GUILayout.Space(100);
if (GUILayout.Button("Continue", GUILayout.Width(150), GUILayout.Height(33)))
{
if (playerName != string.Empty && playerName.Length > 3)
{
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
StartCoroutine(RefresListIE());
PhotonNetwork.playerName = playerName;
ConnectPhoton();
}
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
else
{
if (field == null || string.IsNullOrEmpty(field.text))
return;
playerName = field.text;
playerName = playerName.Replace("\n", "");
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
StartCoroutine(RefresListIE());
PhotonNetwork.playerName = playerName;
ConnectPhoton();
}
}
#region UGUI
/// <summary>
/// For button can call this
/// </summary>
/// <param name="id"></param>
public void ChangeWindow(int id)
{
ChangeWindow(id, -1);
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
public void ChangeWindow(int id, int id2)
{
StartCoroutine(Fade(LobbyState.MainMenu,3f));
for (int i = 0; i < MenusUI.Count; i++)
{
if (i == id || i == id2)
{
MenusUI[i].SetActive(true);
}
else
{
if (i != 1)//1 = mainmenu buttons
{
MenusUI[i].SetActive(false);
}
if (id == 6 || id ==
{
MenusUI[1].SetActive(false);
}
}
}
if (a_Click != null)
{
AudioSource.PlayClipAtPoint(a_Click, this.transform.position, 1.0f);
}
}
public void Disconect()
{
if (PhotonNetwork.connected)
{ PhotonNetwork.Disconnect(); }
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
public void ChangeServerCloud(int id)
{
if (PhotonNetwork.connected)
{
PhotonNetwork.Disconnect();
Debug.LogWarning("Try again, because still not disconect");
return;
}
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
switch (id)
{
case 0:
PhotonNetwork.ConnectToRegion(CloudRegionCode.us, AppVersion);
break;
case 1:
PhotonNetwork.ConnectToRegion(CloudRegionCode.asia, AppVersion);
break;
case 2:
PhotonNetwork.ConnectToRegion(CloudRegionCode.au, AppVersion);
break;
case 3:
PhotonNetwork.ConnectToRegion(CloudRegionCode.eu, AppVersion);
break;
case 4:
PhotonNetwork.ConnectToRegion(CloudRegionCode.jp, AppVersion);
break;
}
PlayAudioClip(a_Click, transform.position, 1.0f);
}
else
{
Debug.LogWarning("Need your AppId for changer server, please add it in inspector");
}
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeMaxPlayer(bool plus)
{
if (plus)
{
if (players < maxPlayers.Length)
{
players++;
if (players > (maxPlayers.Length - 1)) players = 0;
}
}
else
{
if (players < maxPlayers.Length)
{
players--;
if (players < 0) players = maxPlayers.Length - 1;
}
}
MaxPlayerText.text = maxPlayers[players] + " Players";
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeRoundTime(bool plus)
{
if (!plus)
{
if (r_Time < RoomTime.Length)
{
r_Time--;
if (r_Time < 0)
{
r_Time = RoomTime.Length - 1;
}
}
}
else
{
if (r_Time < RoomTime.Length)
{
r_Time++;
if (r_Time > (RoomTime.Length - 1))
{
r_Time = 0;
}
}
}
RoundTimeText.text = (RoomTime[r_Time] / 60) + " Minutes";
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeGameMode(bool plus)
{
if (plus)
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode++;
if (CurrentGameMode > (GameModes.Length - 1))
{
CurrentGameMode = 0;
}
}
}
else
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode--;
if (CurrentGameMode < 0)
{
CurrentGameMode = GameModes.Length - 1;
}
}
}
GameModeText.text = GameModes[CurrentGameMode];
}
/// <summary>
///
/// </summary>
/// <param name="plus"></param>
public void ChangeMap(bool plus)
{
if (!plus)
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene--;
if (CurrentScene < 0)
{
CurrentScene = m_scenes.Count - 1;
}
}
}
else
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene++;
if (CurrentScene > (m_scenes.Count - 1))
{
CurrentScene = 0;
}
}
}
MapNameText.text = m_scenes[CurrentScene].m_name;
MapPreviewImage.sprite = m_scenes[CurrentScene].m_Preview;
}
public void ChangeAntiStropic(bool plus)
{
if (!plus)
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic--;
if (m_stropic < 0)
{
m_stropic = m_stropicOptions.Length - 1;
}
}
}
else
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic++;
if (m_stropic > (m_stropicOptions.Length - 1))
{
m_stropic = 0;
}
}
}
AntiStrpicText.text = m_stropicOptions[m_stropic];
}
public void ChangeQuality(bool plus)
{
if (!plus)
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality--;
if (m_currentQuality < 0)
{
m_currentQuality = QualitySettings.names.Length - 1;
}
}
}
else
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality++;
if (m_currentQuality > (QualitySettings.names.Length - 1))
{
m_currentQuality = 0;
}
}
}
QualityText.text = QualitySettings.names[m_currentQuality];
}
/// <summary>
///
/// </summary>
/// <param name="b"></param>
public void QuitGame(bool b)
{
if (b)
{
Application.Quit();
Debug.Log("Game Exit, this only work in standalone version");
}
else
{
StartCoroutine(Fade(LobbyState.MainMenu, 3.2f));
ChangeWindow(2, 1);
}
}
public void ChangeAutoTeamSelection(bool b) { AutoTeamSelection = b; }
public void ChangeGamePerRound(bool b) { GamePerRounds = b; }
public void ChangeRoomName(string t) { hostName = t; }
public void ChangeVolume(float v) { m_volume = v; VolumenText.text = (m_volume * 100).ToString("00") +"%"; }
public void ChangeSensitivity(float s) { m_sensitive = s; SensitivityText.text = m_sensitive.ToString("00") + "%"; }
/// <summary>
///
/// </summary>
void SetUpOptionsHost()
{
MaxPlayerText.text = maxPlayers[players] + " Players";
RoundTimeText.text = (RoomTime[r_Time] / 60) + " Minutes";
GameModeText.text = GameModes[CurrentGameMode];
MapNameText.text = m_scenes[CurrentScene].m_name;
MapPreviewImage.sprite = m_scenes[CurrentScene].m_Preview;
AntiStrpicText.text = m_stropicOptions[m_stropic];
SensitivityText.text = m_sensitive.ToString("00") + "%";
VolumenText.text = (m_volume * 100).ToString("00") + "%";
QualityText.text = QualitySettings.names[m_currentQuality];
}
public void Save()
{
PlayerPrefs.SetFloat("volumen", m_volume);
PlayerPrefs.SetFloat("sensitive", m_sensitive);
PlayerPrefs.SetInt("quality", m_currentQuality);
PlayerPrefs.SetInt("anisotropic", m_stropic);
Debug.Log("Save Done!");
}
#endregion
#region OnGUI
/// <summary>
///
/// </summary>
void OnGUI()
{
if (m_LobbyType != LobbyType.OnGUI)
return;
GUI.skin = Skin;
if (m_state == LobbyState.ChangeServer)
{
SelectServer();
}
if (m_state == LobbyState.PlayerName)
{
EnterName();
}
if (PhotonNetwork.connected && !PhotonNetwork.connecting)
{
FirstConnect = true;
if (m_state == LobbyState.PlayerName)
{
GUI.Label(new Rect(Screen.width - 150, 20, 150, 30), "<b><size=14> Version 1.0f </size></b>");
}
if (ShowPhotonStatus)
{
GUI.Label(new Rect(0, 55, 500, 20), " <b><color=orange> Status:</color> " + PhotonNetwork.connectionStateDetailed.ToString() + "</b>");
GUI.Label(new Rect(0, 80, 500, 20), " <b><color=orange> Player:</color> " + PhotonNetwork.player.name + "</b>");
}
if (ShowPhotonStatics)
{
ShowStaticSever();
}
if (loading && m_state != LobbyState.PlayerName)
{
GUI.enabled = false;
}
else
{
GUI.enabled = true;
}
//Everything after this line will be affected when we will change "alpha"
GUI.color = new Color(1.0f, 1.0f, 1.0f, alpha);
if (m_state != LobbyState.PlayerName)
{
MainMenu();
}
if (m_state == LobbyState.PlayerName)
{
EnterName();
}
else if (m_state == LobbyState.Join)
{
ServerList();
}
else if (m_state == LobbyState.MainMenu)
{
ServerList();
}
else if (m_state == LobbyState.Host)
{
CreateServer();
}
else if (m_state == LobbyState.Settings)
{
Settings();
}
else if (m_state == LobbyState.Quit)
{
QuitGame();
}
if (m_state != LobbyState.PlayerName && m_state != LobbyState.MainMenu)
{
ButtonBack();
}
}
else if (!FirstConnect)
{
if (PhotonNetwork.connecting)
{
GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2, 200, 60), "Connecting...", "window");
}
else
{
GUILayout.Label("Not connected. Check console output. (" + PhotonNetwork.connectionState + ")");
}
}
}
/// <summary>
///
/// </summary>
/// <param name="field"></param>
public void CancelEnterName(InputField field)
{
field.text = "Player (" + Random.Range(0, 9999) + ")";
}
/// <summary>
/// Menu GUI for select a server to connect
/// </summary>
void SelectServer()
{
if (PhotonNetwork.connected)
{
PhotonNetwork.Disconnect();
}
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 150, 350, 300), "", "window");
GUILayout.Space(10);
GUILayout.Label("Available Regions");
GUILayout.Space(10);
if (GUILayout.Button("US (East Coast)",GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-us.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("EU (Amsterdam)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-eu.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Asia (Singapore)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-asia.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Japan (Tokyo)", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-jp.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
if (GUILayout.Button("Australia (Melbourne) ", GUILayout.Height(35)))
{
if (PhotonNetwork.PhotonServerSettings.AppID != string.Empty)
{
PhotonNetwork.ConnectToMaster("app-au.exitgamescloud.com", Port, PhotonNetwork.PhotonServerSettings.AppID, AppVersion);
PlayAudioClip(a_Click, transform.position, 1.0f);
StartCoroutine(Fade(LobbyState.MainMenu));
}
}
GUILayout.EndArea();
GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 + 165, 400, 100), "Choose the server nearest your location\n since this depends on the <color=orange>Ping.</color>");
}
/// <summary>
///
/// </summary>
void MainMenu (){
GUILayout.BeginArea(new Rect(0,0,Screen.width,60));
GUILayout.BeginHorizontal();
if (GUILayout.Button("Search Room", GUILayout.Height(GetButtonSize(LobbyState.Join))))
{
m_state = LobbyState.Join;
StartCoroutine(RefresListIE());
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Host Room", GUILayout.Height(GetButtonSize(LobbyState.Host))))
{
m_state = LobbyState.Host;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Setting", GUILayout.Height(GetButtonSize(LobbyState.Settings))))
{
m_state = LobbyState.Settings;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Change Server", GUILayout.Height(GetButtonSize(LobbyState.ChangeServer))))
{
m_state = LobbyState.ChangeServer;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
if (GUILayout.Button("Quit", GUILayout.Height(GetButtonSize(LobbyState.Quit))))
{
m_state = LobbyState.Quit;
PlayAudioClip(a_Click, transform.position, 1.0f);
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void CreateServer()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 225, Screen.height / 2 - 165, 450, 400), "", "window");
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Space(15);
GUI.Box(new Rect(30, 35, 150, 30), "Host Name: ");
hostName = hostName.Replace("\n", "");
hostName = GUI.TextField(new Rect(200, 35, 220, 30), hostName, 20);
//Max Player Select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 70, 150, 30), "Max Players: ");
if (GUI.Button(new Rect(200, 70, 40, 30), "<<", "Box"))
{
if (players < maxPlayers.Length)
{
players--;
if (players < 0) players = maxPlayers.Length - 1;
}
}
GUI.Box(new Rect(260, 70, 100, 30), maxPlayers[players].ToString());
if (GUI.Button(new Rect(380, 70, 40, 30), ">>", "Box"))
{
if (players < maxPlayers.Length)
{
players++;
if (players > (maxPlayers.Length - 1)) players = 0;
}
}
GUILayout.EndHorizontal();
//Room Time select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 110, 150, 30), "Max Time: ");
if (GUI.Button(new Rect(200, 110, 40, 30), "<<", "Box"))
{
if (r_Time < RoomTime.Length)
{
r_Time--;
if (r_Time < 0)
{
r_Time = RoomTime.Length - 1;
}
}
}
GUI.Box(new Rect(260, 110, 100, 30), (RoomTime[r_Time] / 60) + " <size=12>Min</size>");
if (GUI.Button(new Rect(380, 110, 40, 30), ">>", "Box"))
{
if (r_Time < RoomTime.Length)
{
r_Time++;
if (r_Time > (RoomTime.Length - 1))
{
r_Time = 0;
}
}
}
GUILayout.EndHorizontal();
//GameMode Select
GUILayout.BeginHorizontal();
GUI.Box(new Rect(30, 150, 150, 30), "Game Mode: ");
if (GUI.Button(new Rect(200, 150, 40, 30), "<<", "Box"))
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode--;
if (CurrentGameMode < 0)
{
CurrentGameMode = GameModes.Length - 1;
}
}
}
GUI.Box(new Rect(260, 150, 100, 30), GameModes[CurrentGameMode]);
if (GUI.Button(new Rect(380, 150, 40, 30), ">>", "Box"))
{
if (CurrentGameMode < GameModes.Length)
{
CurrentGameMode++;
if (CurrentGameMode > (GameModes.Length - 1))
{
CurrentGameMode = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUI.Button(new Rect(25, 190, 75, 30), "<<", "Box"))
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene--;
if (CurrentScene < 0)
{
CurrentScene = m_scenes.Count - 1;
}
}
}
GUI.DrawTexture(new Rect(100, 190, 250, 100), m_scenes[CurrentScene].m_Preview.texture);
GUI.Box(new Rect(100, 265, 250, 25), m_scenes[CurrentScene].m_name);
if (GUI.Button(new Rect(350, 190, 75, 30), ">>", "Box"))
{
if (CurrentScene < m_scenes.Count)
{
CurrentScene++;
if (CurrentScene > (m_scenes.Count - 1))
{
CurrentScene = 0;
}
}
}
GUILayout.EndHorizontal();
GamePerRounds = GUI.Toggle(new Rect(265, 300, 200, 30), GamePerRounds, "Game Per Rounds");
AutoTeamSelection = GUI.Toggle(new Rect(30, 300, 200, 30), AutoTeamSelection, "Auto Team Selection");
GUILayout.BeginHorizontal();
//Create a new Room with Photon
if (GUI.Button(new Rect(150, 330, 175, 50), "Create Room"))
{
CreateRoom();
}
GUILayout.Space(20);
GUILayout.EndHorizontal();
GUILayout.EndVertical();
GUILayout.EndArea();
}
/// <summary>
///
/// </summary>
void ServerList()
{
if (m_LobbyType == LobbyType.OnGUI)
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 400, Screen.height / 2 - 180, 800, 400), Skin.customStyles[3]);
GUI.Box(new Rect(25, 10, 150, 35), "Host Name");
GUI.Box(new Rect(180, 10, 140, 35), "Map Name");
GUI.Box(new Rect(325, 10, 130, 35), "Game Mode");
GUI.Box(new Rect(460, 10, 80, 35), "Players");
GUI.Box(new Rect(545, 10, 60, 35), "Ping");
//Refresh ServerList
if (GUI.Button(new Rect(610, 10, 130, 35), "Refresh"))
{
StartCoroutine(RefresListIE());
}
scroll = GUI.BeginScrollView(new Rect(10, 67, 770, 315), scroll, new Rect(0, 0, 220, 1000), false, true);
if (listRefreshed && !loading)
{
foreach (RoomInfo room in PhotonNetwork.GetRoomList())
{
GUILayout.BeginHorizontal("Label");
GUILayout.Box(room.name, GUILayout.Width(150), GUILayout.Height(30));
GUILayout.Box((string)room.customProperties[PropiertiesKeys.SceneNameKey], GUILayout.Width(140), GUILayout.Height(30));
GUILayout.Box((string)room.customProperties[PropiertiesKeys.GameModeKey], GUILayout.Width(130), GUILayout.Height(30));
GUILayout.Box(room.playerCount + "/" + room.maxPlayers, GUILayout.Width(80), GUILayout.Height(30));
GUILayout.Box(PhotonNetwork.GetPing().ToString(), GUILayout.Width(60), GUILayout.Height(30));
if (GUILayout.Button("Join Game", GUILayout.Width(120), GUILayout.Height(30)))
{
if (room.playerCount < room.maxPlayers)
{
PhotonNetwork.JoinRoom(room.name);
PhotonNetwork.playerName = playerName;
}
}
GUILayout.EndHorizontal();
}
if (roomList.Length == 0 && !loading) GUI.Label(new Rect(320, 150, 200, 30), "No room created ... create one.");
}
GUI.EndScrollView();
GUILayout.EndArea();
}
else
{
//Removed old list
if (CacheRoomList.Count > 0)
{
foreach (GameObject g in CacheRoomList)
{
Destroy(g);
}
CacheRoomList.Clear();
}
//Update List
RoomInfo[] ri = PhotonNetwork.GetRoomList();
if (ri.Length > 0)
{
http://RoomListText.text = string.Empty;
for (int i = 0; i < ri.Length; i++)
{
GameObject r = Instantiate(RoomInfoPrefab) as GameObject;
CacheRoomList.Add(r);
r.GetComponent<bl_RoomInfo>().GetInfo(ri[i]);
r.transform.SetParent(RoomListPanel, false);
}
}
else
{
// RoomListText.text = "There is no room created yet, create your one.";
}
}
}
/// <summary>
/// Menu GUI for settings
/// </summary>
void Settings()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 170, 500, 350), "", "window");
GUILayout.Space(10);
GUILayout.Box("Setting");
GUILayout.Label("Quality Level");
GUILayout.BeginHorizontal();
if (GUILayout.Button("<<"))
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality--;
if (m_currentQuality < 0)
{
m_currentQuality = QualitySettings.names.Length - 1;
}
}
}
GUILayout.Box(QualitySettings.names[m_currentQuality]);
if (GUILayout.Button(">>"))
{
if (m_currentQuality < QualitySettings.names.Length)
{
m_currentQuality++;
if (m_currentQuality > (QualitySettings.names.Length - 1))
{
m_currentQuality = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.Label("Anisotropic Filtering");
GUILayout.BeginHorizontal();
if (GUILayout.Button("<<"))
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic--;
if (m_stropic < 0)
{
m_stropic = m_stropicOptions.Length - 1;
}
}
}
GUILayout.Box(m_stropicOptions[m_stropic]);
if (GUILayout.Button(">>"))
{
if (m_stropic < m_stropicOptions.Length)
{
m_stropic++;
if (m_stropic > (m_stropicOptions.Length - 1))
{
m_stropic = 0;
}
}
}
GUILayout.EndHorizontal();
GUILayout.Label("Sound Volume");
GUILayout.BeginHorizontal();
m_volume = GUILayout.HorizontalSlider(m_volume, 0.0f, 1.0f);
GUILayout.Label((m_volume * 100).ToString("000"), GUILayout.Width(30));
GUILayout.EndHorizontal();
GUILayout.Label("Sensitivity");
GUILayout.BeginHorizontal();
m_sensitive = GUILayout.HorizontalSlider(m_sensitive, 0.0f, 100.0f);
GUILayout.Label(m_sensitive.ToString("000"), GUILayout.Width(30));
GUILayout.EndHorizontal();
if (GUILayout.Button("Save"))
{
Save();
}
GUILayout.EndArea();
}
/// <summary>
/// a simple window for quit of game (only work in Window o Mac Build)
/// if you use Web Player, not need this
/// </summary>
void QuitGame()
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 100, 300, 150), "Quit", "window");
GUILayout.Space(35);
GUILayout.Label("Are you sure you want to exit game?");
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Space(35);
if (GUILayout.Button("Cancel", GUILayout.Width(100), GUILayout.Height(35)))
{
StartCoroutine(Fade(LobbyState.MainMenu));
}
GUILayout.Space(15);
if (GUILayout.Button("Ok", GUILayout.Width(100), GUILayout.Height(35)))
{
Application.Quit();
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
void ButtonBack()
{
GUILayout.BeginArea(new Rect(10, (Screen.height - 35), 200, 100));
if (GUILayout.Button("Back", GUILayout.Height(35)))
{
PlayAudioClip(backSound, transform.position, 1.0f);
listRefreshed = false;
StartCoroutine(Fade(LobbyState.MainMenu));
}
GUILayout.EndArea();
}
void ShowStaticSever()
{
GUILayout.BeginArea(new Rect(225, Screen.height - 35, Screen.width - 225, 50));
GUILayout.BeginHorizontal();
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayersInRooms + "</color> Players in Rooms");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayersOnMaster + "</color> Players in Lobby");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfPlayers + "</color> Players in Server");
GUILayout.Label("<color=orange>" + PhotonNetwork.countOfRooms + "</color> Room are Create");
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
#endregion
/// <summary>
///
/// </summary>
public void CreateRoom()
{
PhotonNetwork.player.name = playerName;
//Save Room properties for load in room
ExitGames.Client.Photon.Hashtable roomOption = new ExitGames.Client.Photon.Hashtable();
roomOption[PropiertiesKeys.TimeRoomKey] = RoomTime[r_Time];
roomOption[PropiertiesKeys.GameModeKey] = GameModes[CurrentGameMode];
roomOption[PropiertiesKeys.SceneNameKey] = m_scenes[CurrentScene].m_SceneName;
roomOption[PropiertiesKeys.RoomRoundKey] = GamePerRounds ? "1" : "0";
roomOption[PropiertiesKeys.TeamSelectionKey] = AutoTeamSelection ? "1" : "0";
string[] properties = new string[5];
properties[0] = PropiertiesKeys.TimeRoomKey;
properties[1] = PropiertiesKeys.GameModeKey;
properties[2] = PropiertiesKeys.SceneNameKey;
properties[3] = PropiertiesKeys.RoomRoundKey;
properties[4] = PropiertiesKeys.TeamSelectionKey;
PhotonNetwork.CreateRoom(hostName, new RoomOptions()
{
maxPlayers = (byte)maxPlayers[players],
isVisible = true,
isOpen = true,
customRoomProperties = roomOption,
cleanupCacheOnLeave = true,
customRoomPropertiesForLobby = properties
}, null);
}
/// <summary>
/// get the list of rooms available to join
/// </summary>
/// <returns></returns>
IEnumerator RefresListIE (){
loading = true;
yield return new WaitForSeconds( 1.0f);
roomList = PhotonNetwork.GetRoomList();
loading = false;
listRefreshed = true;
}
/// <summary>
///
/// </summary>
/// <param name="clip"></param>
/// <param name="position"></param>
/// <param name="volume"></param>
/// <returns></returns>
AudioSource PlayAudioClip ( AudioClip clip , Vector3 position , float volume ){
GameObject go= new GameObject ("One shot audio");
go.transform.position = position;
AudioSource source = go.AddComponent<AudioSource>();
source.clip = clip;
source.volume = volume;
source.Play ();
Destroy (go, clip.length);
return source;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
private IEnumerator MoveToGameScene()
{
//Wait for check
while (PhotonNetwork.room == null)
{
yield return 0;
}
PhotonNetwork.isMessageQueueRunning = false;
Application.LoadLevel((string)PhotonNetwork.room.customProperties[PropiertiesKeys.SceneNameKey]);
}
// LOBBY EVENTS
void OnJoinedLobby()
{
Debug.Log("We joined the lobby.");
if (m_LobbyType == LobbyType.UGUI)
{
StartCoroutine(Fade(LobbyState.MainMenu));
ChangeWindow(2,1);
}
}
void OnLeftLobby()
{
Debug.Log("We left the lobby.");
}
// ROOMLIST
void OnReceivedRoomList()
{
Debug.Log("We received a new room list, total rooms: " + PhotonNetwork.GetRoomList().Length);
}
void OnReceivedRoomListUpdate()
{
Debug.Log("We received a room list update, total rooms now: " + PhotonNetwork.GetRoomList().Length);
}
void OnJoinedRoom (){
Debug.Log("We have joined a room.");
StartCoroutine(MoveToGameScene());
}
void OnFailedToConnectToPhoton ( DisconnectCause cause ){
Debug.LogWarning("OnFailedToConnectToPhoton: " + cause);
loading = false;
}
void OnConnectionFail(DisconnectCause cause)
{
Debug.LogWarning("OnConnectionFail: " + cause);
}
void GetPrefabs()
{
if (PlayerPrefs.HasKey("volumen"))
{
m_volume = PlayerPrefs.GetFloat("volumen");
AudioListener.volume = m_volume;
}
if (PlayerPrefs.HasKey("sensitive"))
{
m_sensitive = PlayerPrefs.GetFloat("sensitive");
}
if (PlayerPrefs.HasKey("quality"))
{
m_currentQuality = PlayerPrefs.GetInt("quality");
}
if (PlayerPrefs.HasKey("anisotropic"))
{
m_stropic = PlayerPrefs.GetInt("anisotropic");
}
}
private int GetButtonSize(LobbyState t_state)
{
if (m_state == t_state)
{
return 55;
}
else
{
return 40;
}
}
[System.Serializable]
public enum LobbyType
{
UGUI,
OnGUI,
}
}
Última edição por dstaroski em Dom Ago 19, 2018 8:36 am, editado 1 vez(es) (Motivo da edição : Título editado conforme padrões do fórum)
Re: tenho alguns erros nos scripts do mfps mas nao consigo resolver....
Boa noite! é de uma Asset certo? já tentou o suporte do Asset? eles com certeza poderão te dizer exatamente o problema, pelo que vi são vários scripts. Quando postar scripts use o botão "script" do editor e poste o código dentro da caixa cinza.
Abraço!
Abraço!
Re: tenho alguns erros nos scripts do mfps mas nao consigo resolver....
eu ja fiz isso mas parece que o suporte esta abandonado pois ninguem responde...sou novo na progrmação estou aprendendo com o tempo talvez eu seja melhor na programação daqui a algum tempo....vou aguardar mais respostas obrigado.dstaroski escreveu:Boa noite! é de uma Asset certo? já tentou o suporte do Asset? eles com certeza poderão te dizer exatamente o problema, pelo que vi são vários scripts. Quando postar scripts use o botão "script" do editor e poste o código dentro da caixa cinza.
Abraço!
eu ja removi o valor null mas acontece um erro de simbolo o que impede de remover o valor null(nulo)
obrigado pela atenção
Tópicos semelhantes
» Alguem pode resolver o erro desses scripts, resolver o erro deste pacote
» Alguém me ajuda a resolver esses 3 erros no meu script C# pf
» Realistic fps prefab tenho esses erros ao tentar colocar um script de entrar sair do carro
» Erro NullReferenceException Não consigo resolver
» Unity 3d (Não Consigo Resolver Isso)
» Alguém me ajuda a resolver esses 3 erros no meu script C# pf
» Realistic fps prefab tenho esses erros ao tentar colocar um script de entrar sair do carro
» Erro NullReferenceException Não consigo resolver
» Unity 3d (Não Consigo Resolver Isso)
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos