protected override void DidActivate(bool firstActivation, ActivationType activationType) { base.DidActivate(firstActivation, activationType); if (activationType == ActivationType.AddedToHierarchy) { //Set up UI title = "Room Selection Screen"; showBackButton = true; _roomSelection = BeatSaberUI.CreateViewController <RoomSelection>(); _roomSelection.MatchSelected += roomSelection_MatchSelected; _roomSelection.CreateMatchPressed += roomSelection_MatchCreated; _splashScreen = BeatSaberUI.CreateViewController <SplashScreen>(); _splashScreen.StatusText = $"Connecting to \"{Host.Name}\"..."; ProvideInitialViewControllers(_splashScreen); } }
protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { if (addedToHierarchy) { //Set up UI SetTitle("Room Selection", ViewController.AnimationType.None); showBackButton = true; _roomSelection = BeatSaberUI.CreateViewController<RoomSelection>(); _roomSelection.MatchSelected += RoomSelection_MatchSelected; _roomSelection.CreateMatchPressed += RoomSelection_MatchCreated; _splashScreen = BeatSaberUI.CreateViewController<SplashScreen>(); _splashScreen.StatusText = $"Connecting to \"{Host.Name}\"..."; ProvideInitialViewControllers(_splashScreen); } base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling); }
// handle data in DataReaded void handle() { if (!guard) { guard = true; while (DataReaded.Count > 0) { string[] data = DataReaded.Dequeue().Split('|'); switch (data[0]) { case "SHOT": GameObject playerShot = GameObject.Find(data[1]); GunController gun = playerShot.GetComponent <GunController>(); gun.FireBullets(); break; case "ITEM": switch (data[1]) { case "SHIELD": GameObject playerShield = GameObject.Find(data[3]); if (playerShield != null) { PlayerController playerscript = playerShield.GetComponent <PlayerController>(); playerscript.CancelInvoke("SwithOffShield"); playerscript.Invoke("SwithOffShield", 5); playerscript.shiledRenderObject.SetActive(true); playerscript.isShieldOn = true; } GameObject Shielditem = GameObject.Find("ShiledPickup" + "|" + data[2]); if (Shielditem != null) { Destroy(Shielditem); } break; case "HEALTH": GameObject Healthitem = GameObject.Find("HealthPickup" + "|" + data[2]); if (Healthitem != null) { Destroy(Healthitem); } break; case "GUN": GameObject player = GameObject.Find(data[3]); GameObject item = GameObject.Find("GunPickup" + "|" + data[2]); Debug.Log(player.name + " increagun"); if (player != null) { PlayerController playerscript = player.GetComponent <PlayerController>(); playerscript.IncreaseGun(); } if (item != null) { Destroy(item); } break; } break; case "SHOTED": HealthController enemyHealth = GameObject.Find(data[1]).GetComponent <HealthController>(); //Debug.Log("decre health " + data[1] + " " + Mathf.Max(0, enemyHealth.HealthCount - 20)); if (enemyHealth != null) { enemyHealth.HealthCount = Mathf.Max(0, enemyHealth.HealthCount - 20); enemyHealth.CheckDeadOrAlive(); } break; case "DESTROY": HealthController enemyDestroy = GameObject.Find(data[1]).GetComponent <HealthController>(); if (enemyDestroy != null) { enemyDestroy.HealthCount = 0; enemyDestroy.CheckDeadOrAlive(); } break; case "JOIN_ROOM": //Debug.Log(data[1]); if (int.Parse(data[1]) == 1) { //Debug.Log("joinroom"); Loading = GameObject.Find("MainMenu_UI").transform.Find("Loading").gameObject; RoomSelection = GameObject.Find("MainMenu_UI").transform.Find("RoomSelection").gameObject; Loading.SetActive(true); RoomSelection.SetActive(false); } else { Notification = GameObject.Find("MainMenu_UI").transform.Find("Notification").gameObject; Text text = Notification.GetComponentInChildren <Text>(); text.text = "Room full, try another"; Notification.SetActive(true); } break; case "LOGIN": //Debug.Log(data[1]); if (int.Parse(data[1]) == 1) { setString("PlayerName", clientName); setRoomAndLevel(data); } else { Notification = GameObject.Find("MainMenu_UI").transform.Find("Notification").gameObject; Text text = Notification.GetComponentInChildren <Text>(); text.text = "Login fail, try another name"; Notification.SetActive(true); } break; } } guard = false; } }