コード例 #1
0
    public void SocketTest()
    {
        MessageTest msg = new MessageTest();

        msg.ReqestContent = "Dmk";

        _netController.RegisterProtoHandler(ProtocolEnum.MessageTest,
                                            (message) => { Debug.Log("测试回调:" + ((MessageTest)message).ResponseContent); });

        _netController.SendMessage(msg);
    }
コード例 #2
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);
                }
            }
        }
    }
コード例 #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);
    }
コード例 #4
0
    IEnumerator GenerateBubblesForSingleGame()
    {
        if (_levelTimer == 0)
        {
            NextLevel();
            yield return(new WaitForSeconds(0.1f));

            StartCoroutine(GenerateBubblesForSingleGame());
        }
        else
        {
            BubbleController newBubble = bubblesGenerator.GenerateNewBubble(smallBubbleSpeed, bigBubbleSpeed);
            NetController.SendMessage(NetMessageCode.NewBubble, newBubble.GenerateNewBubbleProxy());
            bubblesDict.Add(newBubble.id, newBubble);
            float nextBubbleTimeDelay =
                UnityEngine.Random.Range(bubbleGenerationDelay - ConfigDictionary.Config.bubbleGenerationDelayRandom,
                                         bubbleGenerationDelay + ConfigDictionary.Config.bubbleGenerationDelayRandom);
            yield return(new WaitForSeconds(nextBubbleTimeDelay));

            StartCoroutine(GenerateBubblesForSingleGame());
        }
    }