Пример #1
0
    private Dictionary <GameObject, ulong> ObjectContainer = new Dictionary <GameObject, ulong>(); //玩家物体——玩家编号

    void OnEnable()
    {
        LocalMessage.SetHandler(MessageHandler);
        InputField[] tempIF = { PlayerGoldInputField, TowerAttackInputField, TowerSpeedInputField, TowerBuildCostInputField, MonsterDefenseInputField, MonsterHipPointInputField, MonsterSpeedInputField };
        Dropdown[]   tempD  = { PlayerGoldDropdown, TowerAttackDropdown, TowerSpeedDropdown, TowerBuildCostDropdown, MonsterDefenseDropdown, MonsterHipPointDropdown, MonsterSpeedDropdown, Difficult, CheckPoint };
        if (LocalMessage.LocalIdentity != 0)
        {
            foreach (InputField field in tempIF)
            {
                field.enabled = false;
            }
            foreach (Dropdown d in tempD)
            {
                d.enabled = false;
            }
        }
        else
        {
            foreach (InputField field in tempIF)
            {
                field.enabled = true;
            }
            foreach (Dropdown d in tempD)
            {
                d.enabled = true;
            }
        }
        byte[] msg = new byte[8];
        SmallTools.CopyArray(msg, SmallTools.ToByteArray(LocalMessage.LocalPlayerNumber));
        LocalMessage.scom.SendMessage(MsgType.PlayerMsgInRoom, msg);
    }
Пример #2
0
    //获取地图某一项加成信息
    //return:返回4个字节
    private byte[] GetOptionByte(Text displayText)
    {
        byte[] result        = new byte[4];
        int    displayNumber = int.Parse(displayText.text);

        SmallTools.CopyArray(result, SmallTools.ToByteArray(displayNumber));
        return(result);
    }
Пример #3
0
 //创建房间事件
 private void CreateRoomListener()
 {
     byte[] msg = new byte[26];
     SmallTools.CopyArray(msg, SmallTools.ToByteArray(LocalMessage.LocalPlayerNumber));
     byte[] name = Encoding.ASCII.GetBytes(MyName.text);
     SmallTools.CopyArray(msg, name, 8);
     LocalMessage.scom.SendMessage(MsgType.MyRoomNumber, msg);
 }
Пример #4
0
 //点击加入房间
 private void RoomClick(ushort roomNumber)
 {
     byte[] msg = new byte[28];
     SmallTools.CopyArray(msg, SmallTools.ToByteArray(roomNumber));
     SmallTools.CopyArray(msg, SmallTools.ToByteArray(LocalMessage.LocalPlayerNumber), 2);
     byte[] name = Encoding.ASCII.GetBytes(MyName.text);
     SmallTools.CopyArray(msg, name, 10);
     LocalMessage.scom.SendMessage(MsgType.EnterRoom, msg);
 }
Пример #5
0
 //房主踢人
 private void KickPlayer(GameObject go, string text)
 {
     if (text.Equals("打开"))
     {
         byte[] message = new byte[10];
         SmallTools.CopyArray(message, SmallTools.ToByteArray(ObjectContainer[go]));
         SmallTools.CopyArray(message, SmallTools.ToByteArray(LocalMessage.LocalRoomNumber), 8);
         //向被踢玩家发送离开房间的消息
         LocalMessage.scom.SendMessage(MsgType.ExitRoom, message);
     }
 }