SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
Jogo multiplayer com steam
Collider (mesh?)
[TUTORIAL] Deformar mesh com batidas (para objetos, veículos, etc)
WW2 Low poly Pack (Free)
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
Mais Um jogo!
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Sombras estão quadradas na build
nao consigo fazer o player sentar no sofa alguem me ajuda
Unity - Ao mudar de scene, todas as Lights são deletadas
210 Linhas de código para inimigo é muito grande?
modelar avatar e skins para um jogo web
ShapeKeys do Blender para a Unity altera áreas próximas
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Problema com sombra
Mesh e Material do objeto trocando para uma instancia no inicio do jogo
[RESOLVIDO] Unity - RawImages_Layer_Camera
INVESTIMENTO EM JOGOS E BANCO DE TALENTO
Teaser do meu novo projeto pessoal, Dark Age
Preciso de ajuda com mudança para mobile androide.
[RESOLVIDO] Posição final do objeto em jogo 2D
Input.GetAxis() obedercer a orientação de um objeto.
Interação com elementos UI
Meu primeiro jogo na steam
Minimap/Radar/GPS Estilo GTA V
[RESOLVIDO] Erro no console depois que formatei o pc
PACK GRÁTIS de Músicas ELETRÔNICAS para ajudar vocês em seus Jogos Indies!
[TUTORIAL] Entenda como funciona: ENUM, SWITCH, BREAK, CASE no C#
O Labirinto II - Baixe o Jogo
Qual e o codigo de Botões na unity para saber seus estados?
Como carregar itens pequenos dentro do carro sem que atravesse os colliders
[Duvida] Script pegar itens
Travamento ao trocar de cena
Colisão zoada e movimentação
Salvar objetos que foram destruidos entre cenas na unity
Quero começa a desenvolver um jogo de luta porem eu queria aprender a faze
Pegar qual objeto colidiu com o Linecast.
movimentação e camera?
[RESOLVIDO] Unity - SceneManager.LoadScene abre scene com objeto "vazio"
[RESOLVIDO] ajuda sobre skybox
MEU SIMULADOR DE CARRO
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY
[RESOLVIDO] Ausencia da funçao NavMesh na Unity 2022.2.12
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY - 2
Roll Up Um jogo de aventura e desáfios
Terminologia da Unity em outras engines
Como criar a iluminação do Sol no Sistema Solar?
Sáb maio 11, 2024 8:58 am
Sáb maio 11, 2024 8:55 am
Qui maio 09, 2024 11:33 pm
Seg Abr 29, 2024 9:34 pm
Qui Abr 25, 2024 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
Sáb Abr 13, 2024 11:37 am
Qua Abr 10, 2024 1:33 am
Ter Abr 09, 2024 10:28 am
Seg Abr 08, 2024 9:27 pm
Seg Abr 08, 2024 8:01 am
Sáb Abr 06, 2024 8:05 pm
Qui Abr 04, 2024 11:34 pm
Qui Abr 04, 2024 11:13 pm
Sex Mar 22, 2024 2:41 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Ter Fev 20, 2024 9:28 am
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am
Seg Nov 27, 2023 1:35 am
Qua Nov 22, 2023 7:37 am
Qui Nov 09, 2023 1:22 pm
Seg Nov 06, 2023 11:59 am
Ter Out 31, 2023 9:53 am
Dom Out 29, 2023 8:05 pm
Dom Out 29, 2023 3:03 am
Sex Out 27, 2023 3:43 pm
Sex Out 27, 2023 3:28 pm
Qua Out 25, 2023 1:20 pm
Seg Out 23, 2023 10:34 am
Dom Out 22, 2023 6:55 pm
Qui Out 19, 2023 11:57 pm
Qui Out 19, 2023 6:39 pm
Ter Out 17, 2023 6:37 pm
Ter Out 17, 2023 6:18 pm
Seg Out 16, 2023 1:59 pm
Sáb Out 14, 2023 12:15 pm
Qua Out 11, 2023 6:07 pm
Seg Out 09, 2023 4:19 pm
Qua Out 04, 2023 12:12 pm
Qua Out 04, 2023 12:11 pm
Ter Out 03, 2023 9:18 pm
Ter Out 03, 2023 9:08 pm
Ter Out 03, 2023 6:05 pm
Ter Set 26, 2023 12:45 pm
Seg Set 25, 2023 9:02 pm
Seg Set 25, 2023 9:47 am
Sáb Set 23, 2023 2:10 pm
Sex Set 22, 2023 9:01 pm
Qui Set 21, 2023 11:04 am
Qua Set 20, 2023 4:40 pm
Qua Set 20, 2023 9:15 am



































































































tenho alguns erros nos scripts do mfps mas nao consigo resolver....

2 participantes

Ir para baixo

DÚVIDA tenho alguns erros nos scripts do mfps mas nao consigo resolver....

Mensagem por ProBrStalker Sáb Ago 18, 2018 6:19 pm


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>();
        }
    }
}






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";
    }
}


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

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

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 == Cool
                {
                    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)
ProBrStalker
ProBrStalker
Avançado
Avançado

Masculino PONTOS : 2693
REPUTAÇÃO : 14
Respeito as regras : tenho alguns erros nos scripts do mfps mas nao consigo resolver.... WvDYdlf

https://redskygamesstudios.000webhostapp.com/

Ir para o topo Ir para baixo

DÚVIDA Re: tenho alguns erros nos scripts do mfps mas nao consigo resolver....

Mensagem por dstaroski Sáb Ago 18, 2018 6:24 pm

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!
dstaroski
dstaroski
Instrutor

Masculino PONTOS : 6110
REPUTAÇÃO : 1123
Idade : 34
Áreas de atuação : Teologia, Unity 3D, C#, HTML, CSS, Dart, Flutter.

Respeito as regras : tenho alguns erros nos scripts do mfps mas nao consigo resolver.... Aad8pUi

http://diegodeoliveira.gamejolt.io/defeattheilluminatis

Ir para o topo Ir para baixo

DÚVIDA Re: tenho alguns erros nos scripts do mfps mas nao consigo resolver....

Mensagem por ProBrStalker Sáb Ago 18, 2018 6:43 pm

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 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.
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
ProBrStalker
ProBrStalker
Avançado
Avançado

Masculino PONTOS : 2693
REPUTAÇÃO : 14
Respeito as regras : tenho alguns erros nos scripts do mfps mas nao consigo resolver.... WvDYdlf

https://redskygamesstudios.000webhostapp.com/

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos