void OnGUI() { if (!optionShown && !sonShown && !langueShown && !characterShown && !worldcreateShown && !ipserveurshown && !creditshown) { if (!this.manager.isNetworkActive) { // Verification of Sound when we come back to menu GameObject map = GameObject.Find("Map"); if (this.firstScene == null && map != null) { this.character = GameObject.Find("CharacterModel"); this.skinCharacter.ForceApply(this.character); this.firstScene = map.GetComponent<FirstScene>(); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } GUI.Box(new Rect(Screen.width / 4, Screen.height / 10, Screen.width / 2, Screen.width / 12.8f), "", this.skin.GetStyle("aegina")); if (GUI.Button(new Rect(this.posX, this.posY, this.width, this.height), TextDatabase.Play.GetText(), this.skin.GetStyle("button"))) { this.worldsShown = !this.worldsShown; worldsList = new List<string>(Directory.GetDirectories(Application.dataPath + "/Saves")); for (int i = 0; i < worldsList.Count; i++) worldsList[i] = worldsList[i].Remove(0, Application.dataPath.Length + 7); this.listServShown = false; this.firstScene.PlayButtonSound(); } if (GUI.Button(new Rect(this.posX, this.posY + (worldsShown ? Mathf.Min(4, worldsList.Count + 1) * this.spacing : 0) + this.spacing, this.width, this.height), TextDatabase.Join.GetText(), this.skin.GetStyle("button"))) { this.listServShown = !this.listServShown; this.worldsShown = false; this.firstScene.PlayButtonSound(); } if (GUI.Button(new Rect(this.posX, this.posY + (worldsShown ? Mathf.Min(4, worldsList.Count + 1) * this.spacing : listServShown ? Mathf.Min(4, ipList.Count + 1) * this.spacing : 0) + this.spacing * 2, this.width, this.height), TextDatabase.Settings.GetText(), skin.GetStyle("button"))) { this.optionShown = true; this.listServShown = false; this.worldsShown = false; this.firstScene.PlayButtonSound(); } if (GUI.Button(new Rect(this.posX, this.posY + (worldsShown ? Mathf.Min(4, worldsList.Count + 1) * this.spacing : listServShown ? Mathf.Min(4, ipList.Count + 1) * this.spacing : 0) + this.spacing * 3, this.width, this.height), TextDatabase.Quit.GetText(), skin.GetStyle("button"))) { this.firstScene.PlayButtonSound(); Application.Quit(); } if (this.worldsShown) this.DrawWorlds(); else if (this.listServShown) this.DrawIplist(); } else if (!this.manager.IsClientConnected()) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), this.loadingImage); GUI.Box(new Rect(Screen.width / 4, Screen.height / 10, Screen.width / 2, Screen.width / 12.8f), "", this.skin.GetStyle("aegina")); if (GUI.Button(new Rect(this.posX, Screen.height / 1.1f, this.width, this.height), TextDatabase.Cancel.GetText(), this.skin.GetStyle("button"))) { this.firstScene.PlayButtonSound(); this.Launch(TypeLaunch.Stop); this.manager.networkAddress = "localhost"; } } else if (!this.manager.clientLoadedScene || GameObject.Find("Player(Clone)") == null || GameObject.Find("Player(Clone)").GetComponent<Controller>().Loading) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), this.loadingImage); GUI.Box(new Rect(Screen.width / 4, Screen.height / 10, Screen.width / 2, Screen.width / 12.8f), "", this.skin.GetStyle("aegina")); } } else { GUI.Box(new Rect(Screen.width / 4, Screen.height / 10, Screen.width / 2, Screen.width / 12.8f), "", this.skin.GetStyle("aegina")); if (this.optionShown) this.DrawOption(); else if (this.langueShown) this.DrawLangue(); else if (this.sonShown) this.DrawSon(); else if (this.characterShown) this.DrawCharacter(); else if (this.worldcreateShown) this.DrawWorldCreate(); else if (this.ipserveurshown) this.DrawServeurCreate(); else if (this.creditshown) this.DrawCredit(); } }
// Use this for initialization new void Start() { firstScene = Director.Director.getInstance().currentSceneController as FirstScene; firstScene.actionMassager = this; // 初始化actionmassager }
void Awake() { this.character = GameObject.Find("CharacterModel"); this.loadingImage = Resources.Load<Texture>("Sprites/SplashImages/LoadingImage"); this.incr = Random.Range(-0.02f, 0.02f); this.incg = Random.Range(-0.02f, 0.02f); this.incb = Random.Range(-0.02f, 0.02f); this.manager = GetComponent<NetworkManager>(); this.skin = Resources.Load<GUISkin>("Sprites/GUIskin/skin"); this.skin.GetStyle("chat").fontSize = (int)(Screen.height * 0.025f); this.skin.GetStyle("chat").alignment = TextAnchor.MiddleCenter; this.skin.GetStyle("chat").fontStyle = FontStyle.Bold; this.skin.textField.fontSize = (int)(Screen.height * 0.025f); this.skin.textField.fontStyle = FontStyle.Bold; this.skin.GetStyle("button").fontSize = (int)(Screen.height * 0.025f); this.posX = (int)(Screen.width / 2.6f); this.posY = (int)(Screen.height / 2.5f); this.width = Screen.width / 4; this.height = Screen.height / 30; this.spacing = this.height * 2; this.playerName = PlayerPrefs.GetString("PlayerName", ""); SystemLanguage langue = PlayerPrefs.GetInt("langue", 1) == 1 ? SystemLanguage.English : SystemLanguage.French; this.categoryCloth = CategoryCloth.None; Text.SetLanguage(langue); this.firstScene = GameObject.Find("Map").GetComponent<FirstScene>(); if (!Directory.Exists(Application.dataPath + "/Saves")) Directory.CreateDirectory(Application.dataPath + "/Saves"); this.skin.GetStyle("loading").normal.textColor = Color.black; try { string skintStr = PlayerPrefs.GetString("Skin", ""); this.skinCharacter = Skin.Load(skintStr); this.skinCharacter.ForceApply(this.character); } catch { this.characterShown = true; this.skinCharacter = new Skin(Clothing.NormalBrownBeard, Clothing.NormalBrownHair, Clothing.NoneHat, Clothing.BasicBody, Clothing.NoneTshirt, Clothing.BrownOveralls, Clothing.BrownGloves, Clothing.BlackEye); this.skinCharacter.ForceApply(this.character); } }