Пример #1
0
    private void OnConnectCallback(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;
        string        MethodName = p.GetString(startIndex, ref startIndex);
        int           returnCode = p.GetInt(startIndex, ref startIndex);

        if (returnCode == 0)
        {
            Debug.Log("连接成功");

            UIManager.Instance.ShowUI(UIid.MainUI);
            MessageCenter.Send(EMessageType.PlayerName, inputField.text);
            UIManager.Instance.HideTheUI(this.uiId, () => { });
        }
        else
        {
            Debug.Log("连接失败");
            UIManager.Instance.ShowUI(UIid.TipsUI);
            object[] param = new object[2];
            param[0] = "连接失败\n可能原因:昵称已被使用、服务器问题 或 网络故障";
            param[1] = "知道了";
            MessageCenter.Send_Multparam(EMessageType.TipsUI, param);
        }
    }
Пример #2
0
    /// <summary>
    /// 获取地图道具随机数种子
    /// </summary>
    private void OnGetMapItemDataBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        Seed = p.GetInt(startIndex, ref startIndex);

        object[] param = new object[2];
        param[0] = "正在接收道具数据...";
        param[1] = 0;
        MessageCenter.Send_Multparam(EMessageType.LoadingUI, param);

        if (Seed != 0)
        {
            //220个物品生成点的随机数
            RandomList = InitTotalProbabilityValue(ProbabilityValue);
            param[0]   = "道具数据接收完毕";
            param[1]   = 0;
            MessageCenter.Send_Multparam(EMessageType.LoadingUI, param);

            GenerateItem();
        }
        else
        {
            Debug.LogError("Seed异常 " + Seed.ToString() + " 无法加载");
        }
    }
Пример #3
0
    /// <summary>
    /// 获取玩家列表回调
    /// </summary>
    public void OnGetPlayersInfo(BaseProtocol baseProtocol)
    {
        BytesProtocol p          = baseProtocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int Playernum = p.GetInt(startIndex, ref startIndex);

        UnityEngine.Object playerprefab = Resources.Load("NetPlayerPrefab");
        GameObject         tmp_player   = null;

        for (int i = 0; i < Playernum; i++)
        {
            string playerName = p.GetString(startIndex, ref startIndex);
            //自己不需要更新
            if (playerName != NetworkManager.PlayerName)
            {
                tmp_player      = Instantiate(playerprefab) as GameObject;
                tmp_player.name = playerName;
                tmp_player.transform.SetParent(transform);

                NetworkPlayer nPlayer = tmp_player.GetComponent <NetworkPlayer>();
                nPlayer.SetPlayerName(playerName);
                ScenePlayers.Add(playerName, nPlayer);
                nPlayer.LastUpdateTime = NetworkManager.GetTimeStamp();
            }
        }
    }
Пример #4
0
    private void GetRoomList(BaseProtocol protocol)
    {
        for (int j = 0; j < RoomList.content.childCount; j++)
        {
            Destroy(RoomList.content.GetChild(j).gameObject);
        }

        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;
        string        MethodName = p.GetString(startIndex, ref startIndex);
        int           RoomCount  = p.GetInt(startIndex, ref startIndex);

        for (int i = 0; i < RoomCount; i++)

        {
            int playerNum  = p.GetInt(startIndex, ref startIndex);
            int RoomStatus = p.GetInt(startIndex, ref startIndex);
            AddRoomListItem(i, playerNum, RoomStatus);
        }
    }
Пример #5
0
    public void OnCirclefieldTimeBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int HoldTime = p.GetInt(startIndex, ref startIndex);

        //HUDUI倒计时显示
        countdownTime = HoldTime;
        Moving        = false;
    }
Пример #6
0
    private void OnLeaveRoomBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int returnCode = p.GetInt(startIndex, ref startIndex);

        if (returnCode == 0)
        {
            UIManager.Instance.ShowUI(UIid.MainUI);
        }
    }
Пример #7
0
    /// <summary>
    /// 游戏物品被拾取处理
    /// </summary>
    /// <param name="protocol"></param>
    public void OnPickItem(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int GroundItemID = p.GetInt(startIndex, ref startIndex);

        if (Items.ContainsKey(GroundItemID))
        {
            Items[GroundItemID].Hide();
        }
    }
Пример #8
0
    /// <summary>
    /// 开门
    /// </summary>
    /// <param name="protocol"></param>
    public void OnDoorOpen(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int DoorID = p.GetInt(startIndex, ref startIndex);

        if (itemSpawnPoint.DoorSpawnPoints[DoorID] != null)
        {
            Doors[DoorID].gameObject.GetComponent <DoorControl>().ControlDoor();
        }
    }
Пример #9
0
    /// <summary>
    /// 下降点回调
    /// </summary>
    public void OnDroppointBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int index = p.GetInt(startIndex, ref startIndex);

        if (DebugMode == false)
        {
            CameraBase.Instance.gameObject.transform.position = Droppoint[index].position;
            CameraBase.Instance.player.transform.position     = Droppoint[index].position;
        }
    }
Пример #10
0
    private void OnPlayerEquipWeapon(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        string Playername = p.GetString(startIndex, ref startIndex);
        int    ItemID     = p.GetInt(startIndex, ref startIndex);

        if (ScenePlayers.ContainsKey(Playername))
        {
            ScenePlayers[Playername].SetPlayerWeapon(ItemID);
        }
    }
Пример #11
0
    private void GetRoomInfo(BaseProtocol protocol)
    {
        for (int j = 0; j < 10; j++)
        {
            MemberListItems[j].SetActive(false);
        }
        MemberListItem memberListItem;
        BytesProtocol  p          = protocol as BytesProtocol;
        int            startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int PlayerNum = p.GetInt(startIndex, ref startIndex);

        for (int i = 0; i < PlayerNum; i++)
        {
            memberListItem = MemberListItems[i].GetComponent <MemberListItem>();
            string playerName = p.GetString(startIndex, ref startIndex);
            memberListItem.Text_PlayerName.text = playerName;

            int isMaster = p.GetInt(startIndex, ref startIndex);

            if (playerName == NetworkManager.PlayerName)
            {
                if (isMaster == 1)
                {
                    memberListItem.Text_Rank.text = "房主";
                    Btn_Start.gameObject.SetActive(true);
                }
                else
                {
                    Btn_Start.gameObject.SetActive(false);
                }
            }

            MemberListItems[i].SetActive(true);
        }
    }
Пример #12
0
    private void OnPlayerGetBuff(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        string playerName = p.GetString(startIndex, ref startIndex);
        int    bufftype   = p.GetInt(startIndex, ref startIndex);
        float  buffTime   = p.GetFloat(startIndex, ref startIndex);

        if (playerName == NetworkManager.PlayerName)
        {
            CameraBase.Instance.player.GetComponent <PlayerController>().GetDeBuffInTime((BuffType)bufftype, buffTime, BagManager.Instance.characterStatus);
        }
    }
Пример #13
0
    private void OnPlayerEquipHelmet(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        string Playername = p.GetString(startIndex, ref startIndex);
        int    ItemID     = p.GetInt(startIndex, ref startIndex);

        Debug.Log("网络玩家 " + Playername + "  又要威又要戴头盔");
        if (ScenePlayers.ContainsKey(Playername))
        {
            ScenePlayers[Playername].SetPlayerHelmet(ItemID);
        }
    }
Пример #14
0
    /// <summary>
    /// 接收到物品被扔消息
    /// </summary>
    public void OnDropItem(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int   GroundItemID = p.GetInt(startIndex, ref startIndex);
        float posX         = p.GetFloat(startIndex, ref startIndex);
        float posY         = p.GetFloat(startIndex, ref startIndex);
        float posZ         = p.GetFloat(startIndex, ref startIndex);

        if (Items.ContainsKey(GroundItemID))
        {
            Items[GroundItemID].Show();
            Items[GroundItemID].transform.position = new Vector3(posX, posY, posZ);
        }
    }
Пример #15
0
    private void OnRequestStartGameBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int returnCode = p.GetInt(startIndex, ref startIndex);

        Debug.Log("RequestStartGameBack Return code: " + returnCode.ToString());
        if (returnCode == -1)
        {
            UIManager.Instance.ShowUI(UIid.TipsUI);
            object[] param = new object[2];
            param[0] = "无法开始,人数不够";
            param[1] = "返回";
            MessageCenter.Send_Multparam(EMessageType.TipsUI, param);
        }
    }
Пример #16
0
    /// <summary>
    /// 毒圈回调
    /// </summary>
    /// <param name="protocol"></param>
    public void OnCirclefieldBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        float X             = p.GetFloat(startIndex, ref startIndex);
        float Y             = p.GetFloat(startIndex, ref startIndex);
        float shrinkPercent = p.GetFloat(startIndex, ref startIndex);
        int   Movetime      = p.GetInt(startIndex, ref startIndex);

        //HUDUI倒计时显示
        countdownTime = Movetime;
        Moving        = true;
        CircleCenter  = new Vector3(X, 0, Y);

        isBegin = true;
        iTween.ScaleTo(Circlefield, iTween.Hash("x", Circlefield.transform.localScale.x * shrinkPercent, "y", Circlefield.transform.localScale.y * shrinkPercent, "time", Movetime, "easeType", iTween.EaseType.linear));
        iTween.MoveTo(Circlefield, iTween.Hash("position", new Vector3(X, 0, Y), "time", Movetime, "easeType", iTween.EaseType.linear));
    }
Пример #17
0
    private void OnJoinRoomBack(BaseProtocol protocol)
    {
        BytesProtocol p          = protocol as BytesProtocol;
        int           startIndex = 0;

        p.GetString(startIndex, ref startIndex);
        int returnCode = p.GetInt(startIndex, ref startIndex);

        if (returnCode == 0)
        {
            UIManager.Instance.ShowUI(UIid.RoomUI);
        }
        else
        {
            UIManager.Instance.ShowUI(UIid.TipsUI);
            object[] param = new object[2];
            param[0] = "加入房间失败";
            param[1] = "返回";
            MessageCenter.Send_Multparam(EMessageType.TipsUI, param);
        }
    }