예제 #1
0
 private static void Send2AllPlayer(ShowInfoData data)
 {
     SimpleNetManager.Player[] players = SimpleNetManager.PlayerManager.GetAllPlayers();
     foreach (var p in players)
     {
         Send2Client(p, data);
     }
 }
예제 #2
0
        private static void Send2Client(SimpleNetManager.Player player, ShowInfoData data)
        {
            if (NetServer.NetManager != null)
            {
                AppInfoData2Client msg = new AppInfoData2Client();
                msg.data = data;

                NetServer.NetManager.Send(player.session, msg);
            }
        }
예제 #3
0
        private static void Send2Client(LiteNetLibManager.Player player, ShowInfoData data)
        {
            if (LitNetServer.NetManager != null)
            {
                AppInfoData2Client msg = new AppInfoData2Client();
                msg.data = data;

                LitNetServer.NetManager.Send(player, msg);
            }
        }
예제 #4
0
        public static void AddInfoValue(string typeName, string label, string key, object value, string description = null)
        {
            try
            {
                if (string.IsNullOrEmpty(typeName) ||
                    string.IsNullOrEmpty(label) ||
                    string.IsNullOrEmpty(key))
                {
                    Debug.LogError("typeName or label or key cant be null");
                    return;
                }
                if (value == null)
                {
                    Debug.LogError("value cant be null!" + " typeName:" + typeName + " label:" + label + " key:" + key);
                    return;
                }

                ShowInfoData data         = GetShowInfoData(typeName, label, key);
                string       valueStr     = SimpleJsonUtils.ToJson(value);
                string       valueTypeStr = value.GetType().FullName;

                bool isSend = false;
                if (data == null)
                {
                    data              = new ShowInfoData();
                    data.typeName     = typeName;
                    data.label        = label;
                    data.key          = key;
                    data.value        = valueStr;
                    data.valueTypeStr = valueTypeStr;
                    data.discription  = description;
                    infoDatas.Add(data);

                    isSend = true;
                }
                else
                {
                    if (data.valueTypeStr != valueTypeStr)
                    {
                        Debug.LogError(" Path:" + data.GetPath() + " already have value Type:" + data.valueTypeStr + " can not set Value Type:" + valueStr);
                        return;
                    }
                    else
                    {
                        if (data.value != valueStr)
                        {
                            data.value = valueStr;
                            isSend     = true;
                        }
                        if (!string.IsNullOrEmpty(description) && data.discription != description)
                        {
                            data.discription = description;
                            isSend           = true;
                        }
                    }
                }
                if (isSend)
                {
                    Send2AllPlayer(data);
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }
        }
 public void Deserialize(NetDataReader reader)
 {
     data = new ShowInfoData();
     data.Deserialize(reader);
 }