Exemplo n.º 1
0
    public void Send()
    {
        string    byt  = System.Text.Encoding.UTF8.GetString(Decode.DecodFirstContendBtye(MyIncode()));
        LoginInfo info = DataDo.Json2Object <LoginInfo>(Decode.DecodFirstContendBtye(MyIncode()));

        NetStart.SendContend(MyIncode());
    }
Exemplo n.º 2
0
    void Start()
    {
        guess_TBtns = transform.Find("66").gameObject;
        Debug.Log("+++++++++++++++++++" + guess_TBtns.transform.Find("1").GetSiblingIndex());

        Image cardSelected = GetComponent <Image>();

        seletedCard = cardSelected;
        //cardSelected.color = new Color(0.5f, 0.5f, 0.5f, 1);
        Debug.Log(transform.childCount);
        //transform.GetChild(0).GetChild(0).gameObject.SetActive(true);
        Debug.Log(transform.GetChild(0).GetChild(0).name);
        transform.Find("66/1").GetComponent <Image>().enabled = true;

        MyClass myClass = new MyClass {
            ID   = 1,
            Name = "沙克",
        };

        MyClass myClass1 = DataDo.Json2Object <MyClass>(DataDo.Object2Json(myClass));

        Debug.Log(myClass1.ID + myClass1.Name + myClass.Card);

        Test();
        Toggletest();
    }
Exemplo n.º 3
0
 public override void DoCommand()
 {
     friendListInfo = DataDo.Json2Object <List <PersonalInfo> >(Decode.DecodFirstContendBtye(bytes));
     //Debug.Log("查找到好友人数:" + friendListInfo.Count);
     if (MMunePanel.Get())
     {
         MMunePanel.Get().UpdateFriendList(friendListInfo);
     }
 }
Exemplo n.º 4
0
 public override void DoCommand()//登陆成功验证
 {
     NetStart.myInfo = DataDo.Json2Object <PersonalInfo>(Decode.DecodFirstContendBtye(bytes));
     if (NetStart.myInfo.status == (int)PersonStatus.OnLine)//登录成功--进行主界面数据的获取--跳转界面
     {
         NetStart.isLogin = true;
         LoadMMenuScene();
     }
 }
Exemplo n.º 5
0
 public override void DoCommand()//接收排行榜
 {
     //Rank.loadRank = true;
     //服务器是封装的是什么类型,客户端解析的时候就用什么类型去解
     rankList = DataDo.Json2Object <List <PersonalInfo> >(Decode.DecodFirstContendBtye(bytes));
     if (MMunePanel.Get())
     {
         MMunePanel.Get().UpdateRankList(rankList);
     }
 }
Exemplo n.º 6
0
    /// <summary>
    /// 初始化
    /// </summary>
    void Initialize()
    {
        Dictionary <string, int> timeList = DataDo.Json2Object <Dictionary <string, int> >(Decode.DecodSecondContendBtye(bytes));

        timeList.TryGetValue("_1stDrawTime", out _1stDrawTime);
        timeList.TryGetValue("_SingleDrawTime", out _SingleDrawTime);
        timeList.TryGetValue("_DiceTime", out _DiceTime);
        timeList.TryGetValue("_SelectMyselfCardTime", out _SelectMyselfCardTime);
        timeList.TryGetValue("_ExtraTime", out _ExtraTime);
        timeList.TryGetValue("_ClickThinkingTime", out _ClickThinkingTime);
        timeList.TryGetValue("_MoveCardTime", out _MoveCardTime);
    }
Exemplo n.º 7
0
 public override void DoCommand()
 {
     NetStart.myInfo = DataDo.Json2Object <PersonalInfo>(Decode.DecodFirstContendBtye(bytes));
     //if (NetStart.myInfo.status == 1)//登录成功--进行主界面数据的获取--跳转界面
     {
         NetStart.isLogin = true;//登录标志(在线)
         SceneManager.LoadScene("Scenes/MainScence");
         UnityAction <Scene, LoadSceneMode> onLoaded = null;
         onLoaded = (Scene scene, LoadSceneMode mode) =>
         {
             MMunePanel.Open();
             WelcomePanel.Open();
             SceneManager.sceneLoaded -= onLoaded;
         };
         SceneManager.sceneLoaded += onLoaded;
     }
 }
Exemplo n.º 8
0
    public override void DoCommand()
    {
        Debug.Log("接收到消息");

        GameAudio.instance.PlayAudioSourceUI("receiveMsg");
        MessageInfo info = DataDo.Json2Object <MessageInfo>(Decode.DecodSecondContendBtye(bytes));

        List <MessageInfo> msgList;

        info.isReaded = false;
        if (MessageInfo.unReadMsg.TryGetValue(info.sendId, out msgList))
        {
            msgList.Add(info);
        }
        else
        {
            msgList = new List <MessageInfo>();
            msgList.Add(info);
            MessageInfo.unReadMsg.Add(info.sendId, msgList);
        }

        if (MessageInfo.massageAll.TryGetValue(info.sendId, out msgList))
        {
            msgList.Add(info);
        }
        else
        {
            msgList = new List <MessageInfo>();
            msgList.Add(info);
            MessageInfo.massageAll.Add(info.sendId, msgList);
        }

        //在接收消息的时候将发件人添加到联系人中区便于统一实例化
        if (!NetStart.chatmanlist.Contains(info.sendId))
        {
            NetStart.chatmanlist.Add(info.sendId);
        }

        ChatPanel chatPanel = ChatPanel.Get();

        if (chatPanel)
        {
            chatPanel.UpdateMsg();
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// 打开游戏场景
    /// </summary>
    void OpenGameScene()
    {
        RoomPanel.Close();
        GameAudio.instance.PlayAudioSourceBG("Guess");
        GameAudio.instance.PlayAudioSourceUI("start");

        //开始游戏就将房间信息保存,后面的命令(除玩家退出)基本就不会获取房间信息了
        currentRoom = DataDo.Json2Object <RoomInfo>(Decode.DecodSecondContendBtye(bytes));
        SceneManager.LoadScene("GameScene");
        UnityAction <Scene, LoadSceneMode> onLoaded = null;

        onLoaded = (Scene scene, LoadSceneMode mode) =>
        {
            GamePanel.Open().Init(currentRoom);
            SceneManager.sceneLoaded -= onLoaded;
        };
        SceneManager.sceneLoaded += onLoaded;
    }
Exemplo n.º 10
0
    //界面打开  初始化  建一副牌 发牌 掷骰子(选首玩家) 开始执行逻辑(摸排(放置一边)
    //猜牌(选牌,选指定值,判定) 摊牌(归位) 下一位) 没牌直接猜 没有未知手牌(pass) 结束回合(回到房间界面)
    public override void DoCommand()
    {
        int command = BitConverter.ToInt32(bytes, 8);

        switch (command)
        {
        case 0:
            Initialize();
            break;

        case 1:
            OpenGameScene();
            Debug.Log("开始游戏,跳转场景");
            break;

        case 2:
            byte[] sd = Decode.DecodSecondContendBtye(bytes);
            currentRoom = DataDo.Json2Object <RoomInfo>(sd);   //必须在此时获取一次,里面携带玩家手牌信息
            GamePanel.Get().DealWithCards(currentRoom);
            Debug.Log("显示手牌");
            break;

        case 3:
            int[] dice = new int[2];
            dice[0] = BitConverter.ToInt32(bytes, 12);
            dice[1] = BitConverter.ToInt32(bytes, 16);
            Debug.Log("dice[0] :" + dice[0] + "  dice[1] :" + dice[1]);
            GamePanel.Get().SetForthgoer(dice[0] + dice[1]);
            GamePanel.Get().CreatDice(dice);
            break;

        case 4:
            Next();    //房间独立线程发出的
            break;

        case 5:
            Debug.Log("接收到摸排结果");
            byte[] content = Decode.DecodSecondContendBtye(bytes);
            GamePanel.Get().DisplayDraw(BitConverter.ToInt32(content, 0), DataDo.Json2Object <BaseCard>(content.Skip(4).ToArray()));
            break;

        case 6:
            Debug.Log("猜对了  将该牌公布");
            GamePanel.Get().KitheCard_T(DataDo.Json2Object <GuessInfo>(Decode.DecodSecondContendBtye(bytes)));
            break;

        case 7:
            Debug.Log("猜错了  将该牌公布");
            GuessInfo guessInfo = DataDo.Json2Object <GuessInfo>(Decode.DecodSecondContendBtye(bytes));
            GamePanel.Get().KitheCard_F(guessInfo.whoIndex, guessInfo.delateIndex, guessInfo.lineCardSeatIndex);
            break;

        case 8:
            Debug.Log("-------------------公布玩家自选的手牌");
            GamePanel.Get().OpenSelfSelect(DataDo.Json2Object <SingleDraw>(Decode.DecodSecondContendBtye(bytes)));
            break;

        case 9:
            Debug.Log("公布牌");
            GamePanel.Get().OpenCards(BitConverter.ToInt32(bytes, 12));
            break;

        case 10:
            Debug.Log("-----------------执行出局命令");
            GamePanel.Get().DoOut(BitConverter.ToInt32(bytes, 12));
            break;

        case 11:
            Debug.Log("-------------------游戏结束");
            List <int> exitList = DataDo.Json2Object <List <int> >(Decode.DecodSecondContendBtye(bytes));
            GamePanel.Get().GameOver(exitList);
            break;

        case 12:
            Debug.Log("-------------------创建自选计时器");
            GamePanel.Get().CreatSelectSelfCardTimer();
            break;

        case 13:
            Debug.Log("-------------------继续猜牌");
            GamePanel.Get().DoContinue();
            break;

        case 14:

            break;

        case 15:
            Debug.Log("-------------------接收到移动万能牌的命令");
            Info info = DataDo.Json2Object <Info>(Decode.DecodSecondContendBtye(bytes));
            GamePanel.Get().DoMoveLineCard(info.myId, DataDo.Json2Object <List <LineCardMoveInfo> >(info.content));
            break;

        case 16:
            Debug.Log("-------------------玩家离线");
            GamePanel.Get().OffLine(BitConverter.ToInt32(bytes, 12));

            break;
        }
    }
Exemplo n.º 11
0
    public override void DoCommand()
    {
        int command = BitConverter.ToInt32(bytes, 8);

        switch (command)
        {
        case 1:                                                                                                //处理将闲置房间列发反馈给客户端
            rooms = DataDo.Json2Object <Dictionary <string, RoomInfo> >(Decode.DecodSecondContendBtye(bytes)); //查找数据报错,解析成对象时
            if (RoomsHallPanel.Get())
            {
                RoomsHallPanel.Get().OperateRoom();
            }
            Debug.Log("查找成功, 房间数:" + rooms.Count);
            break;

        case 2:
            Debug.Log("开房成功");

            break;

        case 3:
            //返回房间界面
            RoomInfo room = DataDo.Json2Object <RoomInfo>(Decode.DecodSecondContendBtye(bytes));
            RoomPanel.room = room;
            SceneManager.LoadScene("Scenes/MainScence");
            UnityAction <Scene, LoadSceneMode> onLoaded = null;
            onLoaded = (Scene scene, LoadSceneMode mode) =>
            {
                RoomPanel.Open().ForeachPlayerList(room);
                RoomPanel.Get().inPutField.text = room.roomName;
                SceneManager.sceneLoaded -= onLoaded;
            };
            SceneManager.sceneLoaded += onLoaded;


            break;

        case 4:
            Debug.Log("加入房间:");
            RoomsHallPanel.Close();
            RoomInfo roomInfos = DataDo.Json2Object <RoomInfo>(Decode.DecodSecondContendBtye(bytes));
            RoomPanel.room = roomInfos;

            //判断是否是在房间界面
            if (SceneManager.GetActiveScene().name == "MainScence")
            {
                RoomPanel.Open().ForeachPlayerList(roomInfos);
                RoomPanel.Get().inPutField.text = roomInfos.roomName;
                NetStart.myInfo.roomNum = roomInfos.roomID;
            }
            break;

        case 5:
            RoomInfo roomInfo5 = DataDo.Json2Object <RoomInfo>(Decode.DecodSecondContendBtye(bytes));
            RoomPanel.room = roomInfo5;
            RoomPanel roomPanel = RoomPanel.Get();
            if (roomPanel)
            {
                roomPanel.inPutField.text = roomInfo5.roomName;
                roomPanel.ForeachPlayerList(roomInfo5);
            }
            Debug.Log("已退出房间" + roomInfo5.member.Count);
            break;

        case 6:
            Debug.Log("房主转让");
            //被动接受
            break;

        case 8:
            Debug.Log("邀请加入");

            break;

        case 9:
            Debug.Log("踢出房间");

            break;

        case 10:
            Debug.Log("添加好友");

            break;

        case 11:
            Debug.Log("获取可以邀请好友列表");

            break;

        case 12:
            Debug.Log("修改房间名");

            break;
        }
    }