예제 #1
0
    public static void GamerHitScreen(Vector3 position)
    {
        if (singleton == null)
        {
            Debug.LogError("Singleton = null");
            return;
        }
        if (singleton._curGameMode == GameMode.netView)
        {
            return;
        }

        if (Physics.Raycast(Camera.main.ScreenPointToRay(position), out singleton.hit, 100f))
        {
            if (singleton.hit.collider.gameObject.layer == 8)
            {
                int hittedBubbleId = int.Parse(singleton.hit.collider.gameObject.name);
                if (singleton.bubblesDict.ContainsKey(hittedBubbleId))
                {
                    singleton.AddScore(singleton.bubblesDict[hittedBubbleId].GetBubbleSize());
                    singleton.bubblesDict[hittedBubbleId].GamerHitBubble();
                    UserDestroyBubbleProxy proxy = new UserDestroyBubbleProxy(hittedBubbleId, score);
                    NetController.SendMessage(NetMessageCode.UserDestroyBubble, proxy);
                }
            }
        }
    }
예제 #2
0
    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;
                }
                }
            }
        }
    }
예제 #3
0
 public static void DestroyNetWatchBuble(UserDestroyBubbleProxy proxy)
 {
     if (singleton.bubblesDict.ContainsKey(proxy.id))
     {
         singleton.AddScore(singleton.bubblesDict[proxy.id].GetBubbleSize());
         singleton.bubblesDict[proxy.id].GamerHitBubble();
     }
     else
     {
         Debug.LogError("Dictionary not contains bubble id=" + proxy.id);
     }
     singleton._score = proxy.resScore;
 }