Inheritance: MonoBehaviour
 public void Awake()
 {
     if( !playing )
     {
         playing = true;
         GetComponent<AudioSource>().Play();
     }
     else Destroy( this );
     Instance = this;
 }
Exemplo n.º 2
0
    public static bool Button(string text, GUIStyle style, params GUILayoutOption[] options)
    {
        bool pressed = GUILayout.Button(text, style, options);

        if (pressed)
        {
            GlobalSoundsScript.PlayButtonPress();
        }
        return(pressed);
    }
Exemplo n.º 3
0
 public void Awake()
 {
     if (!playing)
     {
         playing = true;
         GetComponent <AudioSource>().Play();
     }
     else
     {
         Destroy(this);
     }
     Instance = this;
 }
Exemplo n.º 4
0
    private void DrawLoginWindow(int id)
    {
        GUILayout.BeginHorizontal();
        {
            string currentUserName     = PlayerPrefs.GetString("username", "Anonymous");
            string newStartingUserName = RemoveSpecialCharacters(GUILayout.TextField(currentUserName));
            if (newStartingUserName != currentUserName)
            {
                PlayerPrefs.SetString("username", newStartingUserName);
                PlayerPrefs.Save();
            }
            GUI.enabled = !TryingToConnect;
            // TODO shouldn't be allocating here, that's dumb, store it
            GUILayout.Box("", BoxSpacer);
            if (GUILayout.Button("HOST"))
            {
                GlobalSoundsScript.PlayButtonPress();
                Connect(RunMode.Server);
            }
            GUILayout.Box("", BoxSpacer);
            if (DevelopmentMode)
            {
                if (GUILayout.Button("LOCAL"))
                {
                    GlobalSoundsScript.PlayButtonPress();
                    Connect(RunMode.Client);
                }
            }
            else
            {
                if (GUILayout.Button("RANDOM"))
                {
                    GlobalSoundsScript.PlayButtonPress();
                    ConnectToRandomServer();
                }
            }

            GUILayout.Box("", BoxSpacer);
            if (GUILayout.Button("REFRESH"))
            {
                GlobalSoundsScript.PlayButtonPress();
                ExternalServerList.Refresh();
            }

            GUI.enabled = true;
        }
        GUILayout.EndHorizontal();
    }
Exemplo n.º 5
0
 private void HandleMessage(string text, int messageType)
 {
     if (messageType == ChatMessageType)
     {
         GlobalSoundsScript.PlayChatMessageSound();
     }
     else if (messageType == BannerMessageType)
     {
         BannerMessages.Add(new BannerMessage(text.ToUpper(), BannerStyle));
     }
     else if (messageType == BannerMessageWithSoundType)
     {
         GlobalSoundsScript.PlayServerMessageSound();
         BannerMessages.Add(new BannerMessage(text.ToUpper(), BannerStyle));
     }
 }
Exemplo n.º 6
0
    private void DrawServerList(int id)
    {
        // TODO this should be in a scrollable view, because it will obviously run offscreen if there are too many
        if (DoAnyServersExist)
        {
            GUIStyle rowStyle = new GUIStyle(BaseSkin.box)
            {
                fixedWidth = 312 - 65
            };
            StringBuilder sb = new StringBuilder();
            foreach (var serverInfo in ExternalServerList.MasterListRaw.active_servers)
            {
                sb.Append(serverInfo.name);
                if (serverInfo.VersionMismatch)
                {
                    sb.Append(" |Incompatible Version|");
                }
                else
                {
                    sb.Append(", ");
                    //sb.Append(serverInfo.);
                    sb.Append(" players on ");
                    sb.Append(serverInfo.map);
                }


                GUILayout.BeginHorizontal();
                //rowStyle.normal.textColor = PlayerRegistry.For(log.Player).Color;
                GUILayout.Box(sb.ToString(), rowStyle);
                GUILayout.Box("", new GUIStyle(BaseSkin.box)
                {
                    fixedWidth = 1
                });
                GUI.enabled = !TryingToConnect && !serverInfo.VersionMismatch;

                if (GUILayout.Button("JOIN"))
                {
                    GlobalSoundsScript.PlayButtonPress();
                    ConnectToExternalListedServer(serverInfo);
                }
                GUILayout.EndHorizontal();

                // clear
                sb.Length = 0;
            }
        }
        else
        {
            GUIStyle rowStyle = new GUIStyle(BaseSkin.box)
            {
                fixedWidth = 312
            };
            GUILayout.BeginHorizontal();
            //rowStyle.normal.textColor = PlayerRegistry.For(log.Player).Color;
            string message;
            if (ExternalServerListAvailable)
            {
                message = "No servers";
            }
            else
            {
                message = "Getting server list...";
            }
            GUILayout.Box(message, rowStyle);
            GUILayout.EndHorizontal();
        }
    }