private void ProcessRecieveMessages(BaseClientServer clientServer) { for (int i = 0; i < clientServer.CountRecievedData(); i++) { curMessage = clientServer.GetRecievedData(); if (curMessage == string.Empty) { continue; } NetMessage netMessage = JsonReader.Deserialize <NetMessage>(curMessage); if (netMessage != null) { switch ((NetMessageCode)netMessage.messType) { case NetMessageCode.RequestGameState: { SendMessage(NetMessageCode.GetGameState, null); break; } case NetMessageCode.GetGameState: { GameStateProxy proxy = JsonReader.Deserialize <GameStateProxy>(netMessage.message); GameController.StartNetWatchGame(proxy); break; } case NetMessageCode.NewBubble: { if (GameController.curGameMode == GameMode.netView) { NewBubbleProxy proxy = JsonReader.Deserialize <NewBubbleProxy>(netMessage.message); GameController.CreateNetWatchBubble(proxy); } break; } case NetMessageCode.UserDestroyBubble: { if (GameController.curGameMode == GameMode.netView) { UserDestroyBubbleProxy proxy = JsonReader.Deserialize <UserDestroyBubbleProxy>(netMessage.message); GameController.DestroyNetWatchBuble(proxy); } break; } case NetMessageCode.NewLevel: { if (GameController.curGameMode == GameMode.netView) { NewLevelProxy proxy = JsonReader.Deserialize <NewLevelProxy>(netMessage.message); GameController.NewNetWatchLevel(proxy); } break; } } } } }
public static void CreateNetWatchBubble(NewBubbleProxy proxy) { if (singleton._curGameMode == GameMode.netView) { BubbleController newBubble = singleton.bubblesGenerator.GenerateNewNetWatchBubble(proxy, singleton.smallBubbleSpeed, singleton.bigBubbleSpeed); singleton.bubblesDict.Add(newBubble.id, newBubble); } }
public NewBubbleProxy GenerateNewBubbleProxy() { NewBubbleProxy proxy = new NewBubbleProxy(); proxy.id = id; proxy.posX = bubbleTransform.position.x; proxy.posY = bubbleTransform.position.y; proxy.size = bubbleTransform.localScale.x; return(proxy); }
public BubbleController GenerateNewNetWatchBubble(NewBubbleProxy proxy, float _smallBubbleSpeed, float _bigBubbleSpeed) { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad); go.name = proxy.id.ToString(); go.layer = 8; go.transform.parent = bublesRoot.transform; GameObject.Destroy(go.GetComponent <MeshCollider>()); go.AddComponent <SphereCollider>(); Material newBubbleMat = new Material(baseMaterial); go.renderer.material = newBubbleMat; BubbleController controller = go.AddComponent <BubbleController>(); float newBubbleSize = proxy.size; float newBubbleSpeed = GenerateSpeed(newBubbleSize, _smallBubbleSpeed, _bigBubbleSpeed); go.transform.position = GenerateInitPosition(proxy.posX, proxy.posY); controller.Setup(proxy.id, newBubbleSize, newBubbleSpeed, ResourceManager.GetRandomTextureFromSet()); return(controller); }