Esempio n. 1
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;
                }
                }
            }
        }
    }
Esempio n. 2
0
 public static void NewNetWatchLevel(NewLevelProxy proxy)
 {
     singleton._curLevel++;
     ResourceManager.GenerateNewTexturesSet();
     singleton.smallBubbleSpeed      += ConfigDictionary.Config.nextLevelIncreaseBubbleSpeed;
     singleton.bigBubbleSpeed        += ConfigDictionary.Config.nextLevelIncreaseBubbleSpeed;
     singleton._levelTimer            = ConfigDictionary.Config.levelTime;
     singleton.bubbleGenerationDelay -= ConfigDictionary.Config.nextLevelIncreaseBubbleGenerationDelay;
     singleton.bubbleGenerationDelay  = Mathf.Clamp(singleton.bubbleGenerationDelay, 0.5f, 1000);
     singleton.DestroyAllBubblesInDict();
     for (int i = 0; i < proxy.bubbles.Length; i++)
     {
         BubbleController newBubble = singleton.bubblesGenerator.GenerateNewNetWatchBubble(proxy.bubbles[i], singleton.smallBubbleSpeed, singleton.bigBubbleSpeed);
         singleton.bubblesDict.Add(newBubble.id, newBubble);
     }
 }
Esempio n. 3
0
    private void NextLevel()
    {
        _curLevel++;
        ResourceManager.GenerateNewTexturesSet();
        smallBubbleSpeed      += ConfigDictionary.Config.nextLevelIncreaseBubbleSpeed;
        bigBubbleSpeed        += ConfigDictionary.Config.nextLevelIncreaseBubbleSpeed;
        _levelTimer            = ConfigDictionary.Config.levelTime;
        bubbleGenerationDelay -= ConfigDictionary.Config.nextLevelIncreaseBubbleGenerationDelay;
        bubbleGenerationDelay  = Mathf.Clamp(bubbleGenerationDelay, 0.5f, 1000);
        NewLevelProxy proxy = new NewLevelProxy();

        proxy.score = score;
        List <NewBubbleProxy> bubbles = new List <NewBubbleProxy>();

        foreach (KeyValuePair <int, BubbleController> bubble in singleton.bubblesDict)
        {
            bubbles.Add(bubble.Value.GenerateNewBubbleProxy());
        }
        proxy.bubbles = bubbles.ToArray <NewBubbleProxy>();
        NetController.SendMessage(NetMessageCode.NewLevel, proxy);
    }