private void Load(Dsl.DslFile dataFile)
        {
            lock (m_Lock) {
                for (int i = 0; i < dataFile.DslInfos.Count; i++)
                {
                    if (dataFile.DslInfos[i].GetId() == "skill")
                    {
                        Dsl.FunctionData funcData = dataFile.DslInfos[i].First;
                        if (null != funcData)
                        {
                            Dsl.CallData callData = funcData.Call;
                            if (null != callData && callData.HaveParam())
                            {
                                int id = int.Parse(callData.GetParamId(0));
                                if (!m_SkillInstances.ContainsKey(id))
                                {
                                    SkillInstance instance = new SkillInstance();
                                    instance.Init(dataFile.DslInfos[i]);
                                    m_SkillInstances.Add(id, instance);

                                    LogSystem.Debug("ParseSkill {0}", id);
                                }
                                //else
                                //{
                                //repeated skill config.
                                //}
                            }
                        }
                    }
                }
            }
        }
        public static object Decode(byte[] msgbuf)
        {
            int id = (int)(((int)msgbuf[0] << 8) | ((int)msgbuf[1]));

            if (id < 0)
            {
                LogSystem.Debug("decode error:message id({0}) error !!!", id);
                return(null);
            }

            if (m_DicIDMsg.ContainsKey(id))
            {
                Type t = m_DicIDMsg[id];
                m_Stream.SetLength(0);
                m_Stream.Write(msgbuf, 2, msgbuf.Length - 2);
                m_Stream.Position = 0;
                object msg = m_Serializer.Deserialize(m_Stream, null, t);
                if (msg == null)
                {
                    LogSystem.Debug("decode error:can't find id {0}  !!!", id);
                    return(null);
                }
                return(msg);
            }
            return(null);
        }
Exemple #3
0
        internal void SendMessage(object msg)
        {
            if (!m_IsConnected)
            {
                return;
            }
            NetOutgoingMessage om = m_NetClient.CreateMessage();

            byte[] bt = Serialize.Encode(msg);
            om.Write(bt);
            NetSendResult result = m_NetClient.SendMessage(om, NetDeliveryMethod.ReliableOrdered);

            if (result == NetSendResult.FailedNotConnected)
            {
                m_IsConnected    = false;
                m_WaitDisconnect = false;
                m_CanSendMessage = false;
                LogSystem.Debug("{0} SendMessage FailedNotConnected {1}", Robot.LobbyNetworkSystem.User, LobbyRobot.Robot.GetDateTime());
            }
            else if (result == NetSendResult.Dropped)
            {
                LogSystem.Error("{0} SendMessage {1} Dropped {2}", Robot.LobbyNetworkSystem.User, msg.ToString(), LobbyRobot.Robot.GetDateTime());
            }
            m_NetClient.FlushSendQueue();
        }
        private void Load(int id, Dsl.FunctionData funcData)
        {
            if (null != funcData)
            {
                string key = funcData.GetId();
                if (key == "skill" || key == "skilldsl")
                {
                    Dsl.CallData callData = funcData.Call;
                    if (null != callData)
                    {
                        int dslId = id;
                        if (callData.HaveParam())
                        {
                            dslId = int.Parse(callData.GetParamId(0));
                        }
                        SkillInstance instance = new SkillInstance();
                        instance.Init(funcData);
                        instance.OuterDslSkillId = dslId;
                        if (!m_SkillInstances.ContainsKey(dslId))
                        {
                            m_SkillInstances.Add(dslId, instance);
                        }
                        else
                        {
                            m_SkillInstances[dslId] = instance;
                        }

                        LogSystem.Debug("ParseSkill {0}", dslId);
                    }
                }
            }
        }
Exemple #5
0
        internal void Tick()
        {
            try
            {
                if (m_NetClient == null)
                {
                    return;
                }
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_IsConnected && m_CanSendMessage)
                {
                    if (curTime - m_LastPingTime >= m_PingInterval)
                    {
                        InternalPing();
                    }
                }
                ProcessMsg();

                if (m_WaitDisconnect && m_WaitDisconnectTime + 5000 < curTime)
                {
                    m_WaitDisconnect = false;

                    LogSystem.Debug("{0} auth failed, restart match !!! {1}", Robot.LobbyNetworkSystem.User, LobbyRobot.Robot.GetDateTime());

                    QuitBattle(true);
                    Robot.LobbyNetworkSystem.QuitRoom();

                    Robot.StorySystem.SendMessage("missionfailed");
                }
            }
            catch (Exception e)
            {
                LogSystem.Error("{0} Exception:{1}\n{2}", Robot.LobbyNetworkSystem.User, e.Message, e.StackTrace);
            }
        }
Exemple #6
0
        private List <T> ConvertNumericList <T>(string vec)
        {
            List <T> list   = new List <T>();
            string   strPos = vec;

            string[] resut = strPos.Split(new string[] { ",", " " }, StringSplitOptions.None);

            try
            {
                if (resut != null && resut.Length > 0 && resut[0] != "")
                {
                    for (int index = 0; index < resut.Length; index++)
                    {
                        list.Add((T)Convert.ChangeType(resut[index], typeof(T)));
                    }
                }
            }
            catch (System.Exception ex)
            {
                string info = string.Format("ExtractNumeric Error vec:{0} ex:{1} stacktrace:{2}", vec, ex.Message, ex.StackTrace);
                LogSystem.Debug(info);
                list.Clear();
            }
            return(list);
        }
Exemple #7
0
        public void OnPong(long time, long sendPingTime, long sendPongTime)
        {
            if (time < sendPingTime)
            {
                return;
            }
            ++m_PingPongNumber;

            long rtt = time - sendPingTime;

            if (TimeUtility.AverageRoundtripTime == 0)
            {
                TimeUtility.AverageRoundtripTime = rtt;
            }
            else
            {
                TimeUtility.AverageRoundtripTime = (long)(TimeUtility.AverageRoundtripTime * 0.7f + rtt * 0.3f);
            }

            LogSystem.Debug("RoundtripTime:{0} AverageRoundtripTime:{1}", rtt, TimeUtility.AverageRoundtripTime);

            long diff = sendPongTime + rtt / 2 - time;

            TimeUtility.RemoteTimeOffset = (TimeUtility.RemoteTimeOffset * (m_PingPongNumber - 1) + diff) / m_PingPongNumber;
        }
Exemple #8
0
        private void HandleGetOnlineTimeRewardResult(JsonMessage lobbyMsg)
        {
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_GetOnlineTimeRewardResult protoData = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_GetOnlineTimeRewardResult;
            RoleInfo role = LobbyClient.Instance.CurrentRole;

            if (null != protoData)
            {
                if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Succeed)
                {
                    // 成功
                    if (!role.OnLineDurationRewardedIndex.Contains(protoData.m_Index))
                    {
                        role.OnLineDurationRewardedIndex.Add(protoData.m_Index);
                        LogSystem.Debug("GetOnlineTimeRewardResult succed");
                    }
                }
                else if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Failure_Code_Used)
                {
                    LogSystem.Debug("GetOnlineTimeRewardResult alread get");
                    // 已经领取
                }
                else if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Failure_Time)
                {
                    LogSystem.Debug("GetOnlineTimeRewardResult time not OK");
                    // 时间不够
                }
                else
                {
                    // 未知错误
                }
            }
        }
        internal void ConnectIfNotOpen()
        {
            if (!IsConnected)
            {
                m_LastReceiveHeartbeatTime = 0;
                m_LastQueueingTime         = 0;
                m_LastShowQueueingNum      = 0;
                m_LastConnectTime          = TimeUtility.GetLocalMilliseconds();
                LogSystem.Debug("ConnectIfNotOpen at time:{0} ServerAddress:{1}", m_LastConnectTime, m_Url);

                WorldSystem.Instance.WaitMatchSceneId = -1;
                m_IsLogining = true;
                m_IsQueueing = false;
#if !PLATFORM_WEBGL
                m_WebSocket = new WebSocket4Net.WebSocket(m_Url);
#else
                m_WebSocket = WebSocketWrapper.Instance;
                m_WebSocket.SetUrl(m_Url);
#endif
                m_WebSocket.AllowUnstrustedCertificate = true;
                m_WebSocket.EnableAutoSendPing         = true;
                m_WebSocket.AutoSendPingInterval       = 10;
                m_WebSocket.Opened          += OnWsOpened;
                m_WebSocket.MessageReceived += OnWsMessageReceived;
                m_WebSocket.DataReceived    += OnWsDataReceived;
                m_WebSocket.Error           += OnWsError;
                m_WebSocket.Closed          += OnWsClosed;
                m_WebSocket.Open();
            }
        }
Exemple #10
0
        public bool CheckRoadBlock(Vector3 start, Vector3 end, Vector3[] polygon, out Vector3 roadBlock)
        {
            bool           ret      = false;
            List <CellPos> cells    = cell_manager_.GetCellsCrossByLine(start, end);
            Vector3        blockPos = new Vector3();

            VisitCellsCrossByLine(start, end, (int row, int col) => {
                byte status  = cell_manager_.cells_arr_[row, col];
                byte block   = BlockType.GetBlockType(status);
                byte subtype = BlockType.GetBlockSubType(status);
                if (BlockType.NOT_BLOCK != block && BlockType.SUBTYPE_ROADBLOCK == subtype)
                {
                    Vector3 pos = cell_manager_.GetCellCenter(row, col);
                    if (Geometry.PointInPolygon(pos, polygon, 0, polygon.Length) > 0)
                    {
                        blockPos = pos;
                        ret      = true;
                        LogSystem.Debug("CheckRoadBlock {0} -> {1} find roadblock {2}", start.ToString(), end.ToString(), pos.ToString());
                        return(false);
                    }
                }
                return(true);
            });
            roadBlock = blockPos;
            return(ret);
        }
Exemple #11
0
 private void NetworkThread()
 {
     while (!m_IsQuited)
     {
         if (m_IsWaitStart)
         {
             Thread.Sleep(1000);
         }
         else
         {
             while (!m_IsQuited && !m_IsConnected && !m_IsWaitStart)
             {
                 LogSystem.Debug("{0} Connect ip:{1} port:{2} key:{3} {4}\nNetPeer Statistic:{5}", Robot.LobbyNetworkSystem.User, m_Ip, m_Port, m_Key, LobbyRobot.Robot.GetDateTime(), m_NetClient.Statistics.ToString());
                 try
                 {
                     m_NetClient.Connect(m_Ip, m_Port);
                 }
                 catch
                 {
                 }
                 for (int ct = 0; ct < 10 && !m_IsConnected; ++ct)
                 {
                     OnRecvMessage();
                     LogSystem.Debug("{0} Wait NetConnectionStatus.Connected ... {1}", Robot.LobbyNetworkSystem.User, LobbyRobot.Robot.GetDateTime());
                     if (!m_IsConnected)
                     {
                         Thread.Sleep(1000);
                     }
                 }
             }
             OnRecvMessage();
         }
     }
 }
Exemple #12
0
 internal void SendMessage(object msg)
 {
     try
     {
         if (!m_IsConnected)
         {
             return;
         }
         NetOutgoingMessage om = m_NetClient.CreateMessage();
         byte[]             bt = Serialize.Encode(msg);
         om.Write(bt);
         NetSendResult result = m_NetClient.SendMessage(om, NetDeliveryMethod.ReliableOrdered);
         if (result == NetSendResult.FailedNotConnected)
         {
             m_IsConnected    = false;
             m_WaitDisconnect = false;
             m_CanSendMessage = false;
             LogSystem.Debug("SendMessage FailedNotConnected");
         }
         else if (result == NetSendResult.Dropped)
         {
             LogSystem.Error("SendMessage {0} Dropped", msg.ToString());
         }
         m_NetClient.FlushSendQueue();
     }
     catch (Exception ex)
     {
         LogSystem.Error("NetworkSystem.SendMessage throw Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
Exemple #13
0
        private void CustomNetWorkThread(int pharse)
        {
            if (m_IsWaitStart)
            {
                return;
            }

            if (pharse == 1)
            {
                if (!m_IsQuited && !m_IsConnected && !m_IsWaitStart)
                {
                    LogSystem.Debug("Connect ip:{0} port:{1} key:{2}\nNetPeer Statistic:{3}", m_Ip, m_Port, m_Key, m_NetClient.Statistics.ToString());
                    GameControler.NotifyRoomServerDisconnected();
                    try
                    {
                        m_NetClient.Connect(m_Ip, m_Port);
                    }
                    catch
                    {
                    }
                    for (int ct = 0; ct < 10 && !m_IsConnected; ++ct)
                    {
                        OnRecvMessage();
                        LogSystem.Debug("Wait NetConnectionStatus.Connected ...");
                        if (!m_IsConnected)
                        {
                            Thread.Sleep(1000);
                        }
                    }
                }
                OnRecvMessage();
            }
        }
        private void Load(int id, Dsl.DslFile dataFile)
        {
            lock (m_Lock) {
                for (int i = 0; i < dataFile.DslInfos.Count; i++)
                {
                    if (dataFile.DslInfos[i].GetId() == "skill")
                    {
                        Dsl.FunctionData funcData = dataFile.DslInfos[i].First;
                        if (null != funcData)
                        {
                            Dsl.CallData callData = funcData.Call;
                            if (null != callData)
                            {
                                int dslId = id;
                                if (callData.HaveParam())
                                {
                                    dslId = int.Parse(callData.GetParamId(0));
                                }
                                if (!m_SkillInstances.ContainsKey(dslId))
                                {
                                    SkillInstance instance = new SkillInstance();
                                    instance.Init(dataFile.DslInfos[i]);
                                    instance.OuterDslSkillId = dslId;
                                    m_SkillInstances.Add(dslId, instance);

                                    LogSystem.Debug("ParseSkill {0}", dslId);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #15
0
        private void OnRecvMessage()
        {
            m_NetClient.MessageReceivedEvent.WaitOne(1000);
            NetIncomingMessage im;

            while ((im = m_NetClient.ReadMessage()) != null)
            {
                switch (im.MessageType)
                {
                case NetIncomingMessageType.DebugMessage:
                case NetIncomingMessageType.VerboseDebugMessage:
                    LogSystem.Debug("Debug Message: {0}", im.ReadString());
                    break;

                case NetIncomingMessageType.ErrorMessage:
                    LogSystem.Debug("Error Message: {0}", im.ReadString());
                    break;

                case NetIncomingMessageType.WarningMessage:
                    LogSystem.Debug("Warning Message: {0}", im.ReadString());
                    break;

                case NetIncomingMessageType.StatusChanged:
                    NetConnectionStatus status = im.SenderConnection.Status;

                    string reason = im.ReadString();
                    LogSystem.Debug("Network Status Changed:{0} Reason:{1}\nStatistic:{2}", status.ToString(), reason, im.SenderConnection.Statistics.ToString());
                    if (NetConnectionStatus.Disconnected == status)
                    {
                        m_IsConnected = false;
                    }
                    else if (NetConnectionStatus.Connected == status)
                    {
                        OnConnected(im.SenderConnection);
                    }
                    break;

                case NetIncomingMessageType.Data:
                    if (m_IsConnected == false)
                    {
                        break;
                    }
                    try {
                        object msg = Serialize.Decode(im.ReadBytes(im.LengthBytes));
                        if (msg != null)
                        {
                            PushMsg(msg, im.SenderConnection);
                        }
                    } catch (Exception ex) {
                        GfxSystem.GfxLog("Decode Message exception:{0}\n{1}", ex.Message, ex.StackTrace);
                    }
                    break;

                default:
                    break;
                }
                m_NetClient.Recycle(im);
            }
        }
Exemple #16
0
        protected void Logging(string message, LogType en)
        {
            try
            {
                try
                {
                    if (String.IsNullOrEmpty(MethodName))
                    {
                        MethodName = string.Format("{0}", new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().Name);
                    }
                }
                catch (Exception ex)
                {
                    LogSystem.Error(ex);
                }
                string threadInfo = GetThreadId();
                message = new StringBuilder().Append("- ClassName: ").Append(ClassName)
                          .Append("\n- MethodName: ").Append(MethodName).
                          Append("\n- UserName: "******"\n- ThreadInfo: ").Append(threadInfo)
                          .Append(message).ToString();
                switch (en)
                {
                case LogType.Debug:
                    LogSystem.Debug(message);
                    break;

                case LogType.Info:
                    LogSystem.Info(message);
                    break;

                case LogType.Warn:
                    LogSystem.Warn(message);
                    break;

                case LogType.Error:
                    LogSystem.Error(message);
                    break;

                case LogType.Fatal:
                    LogSystem.Fatal(message);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    LogSystem.Error("EntityBase.Logging.Exception.", ex);
                }
                catch (Exception)
                {
                }
            }
        }
        bool GenerateMatrix()
        {
            Vector2 newSize = unclampedGridSize;

            newSize.x *= Mathf.Sign(newSize.x);
            newSize.y *= Mathf.Sign(newSize.y);

            if (nodeSize < newSize.x / (float)maxNodeNumInWidth || nodeSize < newSize.y / (float)maxNodeNumInDepth)
            {
                if (m_NodeSizeSelfAdaption)
                {
                    LogSystem.Debug("Gird width and depth are not able to over num " + maxNodeNumInWidth + " and " + maxNodeNumInDepth + ".\n" +
                                    "Node size will be scaled automatically to fit this constraint.");
                }
                else
                {
                    LogSystem.Debug("Gird width and depth are not able to over num " + maxNodeNumInWidth + " and " + maxNodeNumInDepth);
                    return(false);
                }
            }

            float nodeWidthSize = Mathf.Clamp(nodeSize, newSize.x / (float)maxNodeNumInWidth, Mathf.Infinity);
            float nodeDepthSize = Mathf.Clamp(nodeSize, newSize.y / (float)maxNodeNumInDepth, Mathf.Infinity);

            nodeSize = Mathf.Max(nodeWidthSize, nodeDepthSize);

            newSize.x = newSize.x < nodeSize ? nodeSize : newSize.x;
            newSize.y = newSize.y < nodeSize ? nodeSize : newSize.y;

            gridSize = newSize;

            nodeNumInWidth = Mathf.FloorToInt(gridSize.x / nodeSize);
            nodeNumInDepth = Mathf.FloorToInt(gridSize.y / nodeSize);

            if (Mathf.Approximately(gridSize.x / nodeSize, Mathf.CeilToInt(gridSize.x / nodeSize)))
            {
                nodeNumInWidth = Mathf.CeilToInt(gridSize.x / nodeSize);
            }

            if (Mathf.Approximately(gridSize.y / nodeSize, Mathf.CeilToInt(gridSize.y / nodeSize)))
            {
                nodeNumInDepth = Mathf.CeilToInt(gridSize.y / nodeSize);
            }

            float remainderX = gridSize.x - ((float)nodeNumInWidth * nodeSize);
            float remainderY = gridSize.y - ((float)nodeNumInDepth * nodeSize);

            Vector3 newCenter = new Vector3(gridCoordinateCenter.x + remainderX * 0.5f, gridCoordinateCenter.y + 0.5f, gridCoordinateCenter.z + remainderY * 0.5f);

            Matrix4x4 m = Matrix4x4.TRS(newCenter, Quaternion.Euler(Vector3.zero), new Vector3(nodeSize, 1, nodeSize));

            m_Matrix        = m;
            m_InverseMatrix = m.inverse;

            return(true);
        }
Exemple #18
0
    internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem)
    {
        Msg_RC_NpcTarget targetmsg = msg as Msg_RC_NpcTarget;

        if (null == targetmsg)
        {
            return;
        }
        LogSystem.Debug("NpcTarget, npc:{0} target:{1} robot:{2} {3}", targetmsg.npc_id, targetmsg.target_id, networkSystem.Robot.LobbyNetworkSystem.User, LobbyRobot.Robot.GetDateTime());
    }
        private void Load(ScriptableData.ScriptableDataFile dataFile)
        {
            lock (m_Lock)
            {
                for (int i = 0; i < dataFile.ScriptableDatas.Count; i++)
                {
                    if (dataFile.ScriptableDatas[i].GetId() == "skill")
                    {
                        ScriptableData.FunctionData funcData = dataFile.ScriptableDatas[i].First;
                        if (null != funcData)
                        {
                            ScriptableData.CallData callData = funcData.Call;
                            if (null != callData && callData.HaveParam())
                            {
                                int id = int.Parse(callData.GetParamId(0));
                                if (!m_SkillInstances.ContainsKey(id))
                                {
                                    SkillInstance instance = new SkillInstance();
                                    instance.Init(dataFile.ScriptableDatas[i]);
                                    m_SkillInstances.Add(id, instance);

                                    LogSystem.Debug("ParseSkill {0}", id);
                                }
                                //else
                                //{
                                //repeated skill config.
                                //}
                            }
                        }
                    }
                }

                /*
                 * foreach (ScriptableData.ScriptableDataInfo info in dataFile.ScriptableDatas) {
                 * if (info.GetId() == "skill") {
                 *  ScriptableData.FunctionData funcData = info.First;
                 *  if (null != funcData) {
                 *    ScriptableData.CallData callData = funcData.Call;
                 *    if (null != callData && callData.HaveParam()) {
                 *      int id = int.Parse(callData.GetParamId(0));
                 *      if (!m_SkillInstances.ContainsKey(id)) {
                 *        SkillInstance instance = new SkillInstance();
                 *        instance.Init(info);
                 *        m_SkillInstances.Add(id, instance);
                 *
                 *        LogSystem.Debug("ParseSkill {0}", id);
                 *      } else {
                 *        //repeated skill config.
                 *      }
                 *    }
                 *  }
                 * }
                 * }*/
            }
        }
 public void AddState(State state)
 {
     if (state == null)
     {
         return;
     }
     if (state_dict_.ContainsKey(state.id))
     {
         LogSystem.Debug("add state failed, state already exist " + state.id);
         return;
     }
     state_dict_.Add(state.id, state);
     state.fsm = this;
 }
Exemple #21
0
        private void OpenSceneIfPending(DateTime now)
        {
            if (_pendingSceneToOpen != null)
            {
                LogSystem.Debug("WORLD: opening scene {0}", _pendingSceneToOpen.GetType().Name);

                // Time.
                if (_time.SinceGameStart <= float.Epsilon)
                {
                    _time.MarkAsGameStarted(now);
                }

                _time.MarkAsSceneStarted(now);
                _time.Update(now);

                // Call new scene initialization, in this moment the scene decide which components will be kept
                // on world and wich objects will be removed.
                _pendingSceneToOpen.Initialize();

                // Remove the scene survivors from components to remove.
                var sceneSurvivables = _componentsToRemove
                                       .Where(c => (c is ISceneSurvivable) && ((ISceneSurvivable)c).CanSurvive(CurrentScene, _pendingSceneToOpen));
                sceneSurvivables.EnableAll();
                _componentsToRemove = _componentsToRemove.Except(sceneSurvivables).ToList();

                // Remove the components selected by the scene to be removed from world.
                foreach (var c in _componentsToRemove)
                {
                    Components.Remove(c);
                    _updatables.Remove(c as IUpdatable);
                    _drawables.Remove(c as IDrawable);
                    PhysicSystem.RemoveCollidable(c as ICollidable);
                }

                _componentsToRemove.Clear();

                // Change the current world scene.
                CurrentScene = _pendingSceneToOpen;

                _pendingSceneToOpen = null;

                LogSystem.Debug("WORLD: scene opened");
            }
            else
            {
                _time.Update(now);
            }
        }
Exemple #22
0
        private void HandleSyncSignInCount(JsonMessage lobbyMsg)
        {
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_SyncSignInCount protoData = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_SyncSignInCount;
            if (null != protoData)
            {
                RoleInfo roleInfo = LobbyClient.Instance.CurrentRole;
                if (null != roleInfo)
                {
                    roleInfo.RestSignInCount     = protoData.m_RestSignInCountCurDay;
                    roleInfo.SignInCountCurMonth = protoData.m_SignInCountCurMonth;
                    GfxSystem.PublishGfxEvent("ge_sync_sign_count", "ui");
                }
                LogSystem.Debug("Sync SignIn Count, count = {0}, cur SignInCountCurMonth = {1}", protoData.m_RestSignInCountCurDay, protoData.m_SignInCountCurMonth);
            }
        }
Exemple #23
0
 private void SignInAndGetReward()
 {
     try
     {
         LogSystem.Debug("Try SignIn and GetReward");
         JsonMessage msg = new JsonMessage(JsonMessageID.SignInAndGetReward);
         msg.m_JsonData.Set("m_Guid", m_Guid);
         ArkCrossEngineMessage.Msg_CL_SignInAndGetReward protoData = new ArkCrossEngineMessage.Msg_CL_SignInAndGetReward();
         protoData.m_Guid = m_Guid;
         msg.m_ProtoData  = protoData;
         SendMessage(msg);
     }
     catch (Exception ex)
     {
         LogSystem.Error("Exception:{0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
Exemple #24
0
        internal void Start(uint key, string ip, int port, int heroId, int campId, int sceneId)
        {
            StartNetClient();

            m_Key     = key;
            m_Ip      = ip;
            m_Port    = port;
            m_HeroId  = heroId;
            m_CampId  = campId;
            m_SceneId = sceneId;

            m_IsWaitStart    = false;
            m_IsConnected    = false;
            m_WaitDisconnect = false;
            m_CanSendMessage = false;

            LogSystem.Debug("NetworkSystem.Start key {0} ip {1} port {2} hero {3} camp {4} scene {5}", key, ip, port, heroId, campId, sceneId);
        }
        private static JsonMessage DecodeJsonMessage(string msgStr)
        {
            JsonMessage msg = null;

            if (s_Inited)
            {
                try
                {
#if DEBUG
                    LogSystem.Debug("DecodeJsonMessage:{0}", msgStr);
#endif

                    int ix = msgStr.IndexOf('|');
                    if (ix > 0)
                    {
                        int id  = int.Parse(msgStr.Substring(0, ix));
                        int ix2 = msgStr.IndexOf('|', ix + 1);
                        msg = new JsonMessage(id);
                        if (ix2 > 0)
                        {
                            string jsonStr  = msgStr.Substring(ix + 1, ix2 - ix - 1);
                            string protoStr = msgStr.Substring(ix2 + 1);
                            msg.m_JsonData = JsonMapper.ToObject(jsonStr);
                            Type t = s_MessageHandlers[id].m_ProtoType;
                            if (null != t)
                            {
                                byte[] bytes = Convert.FromBase64String(protoStr);
                                msg.m_ProtoData = Encoding.Decode(t, bytes);
                            }
                        }
                        else
                        {
                            string jsonStr = msgStr.Substring(ix + 1);
                            msg.m_JsonData = JsonMapper.ToObject(jsonStr);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogSystem.Error("[Exception] DecodeJsonMessage:{0} throw:{1}\n{2}", msgStr, ex.Message, ex.StackTrace);
                }
            }
            return(msg);
        }
Exemple #26
0
        ////////////////////////////////////////////////////////////////////////////////////
        private void HandleSignInAndGetRewardResult(JsonMessage lobbyMsg)
        {
            JsonData jsonData = lobbyMsg.m_JsonData;

            ArkCrossEngineMessage.Msg_LC_SignInAndGetRewardResult protoData = lobbyMsg.m_ProtoData as ArkCrossEngineMessage.Msg_LC_SignInAndGetRewardResult;
            bool rewardResult = false;

            if (null != protoData)
            {
                if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Succeed)
                {
                    // 成功
                    rewardResult = true;
                    LogSystem.Debug("SignIn succeed");
                    RoleInfo roleInfo = LobbyClient.Instance.CurrentRole;
                    if (null != roleInfo)
                    {
                        --roleInfo.RestSignInCount;
                        ++roleInfo.SignInCountCurMonth;
                    }
                }
                else
                {
                    if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Failure_CostError)
                    {
                        // 次数不足
                        LogSystem.Debug("Do not have enough sign in time.");
                    }
                    else if (protoData.m_ResultCode == (int)GeneralOperationResult.LC_Failure_Overflow)
                    {
                        LogSystem.Debug("Sign in count can not exceed datetime.");
                        // 签到次数不能超过日期数
                    }
                    else
                    {
                        LogSystem.Debug("Unknonw error.");
                        // 未知错误
                    }
                }
            }
            GfxSystem.PublishGfxEvent("ge_sign_award_result", "ui", rewardResult);
        }
Exemple #27
0
        public static void MoveChildToNode(GameObject obj, string childname, string nodename)
        {
            Transform child = GetChildNodeByName(obj, childname);

            if (child == null)
            {
                LogSystem.Debug("----not find child! {0} on {1}", childname, obj.name);
                return;
            }
            Transform togglenode = TriggerUtil.GetChildNodeByName(obj, nodename);

            if (togglenode == null)
            {
                LogSystem.Debug("----not find node! {0} on {1}", nodename, obj.name);
                return;
            }
            child.parent        = togglenode;
            child.localRotation = UnityEngine.Quaternion.identity;
            child.localPosition = UnityEngine.Vector3.zero;
        }
        internal bool SendMessage(string msgStr)
        {
            bool ret = false;

            try
            {
                if (IsConnected)
                {
                    m_WebSocket.Send(msgStr);
#if DEBUG
                    LogSystem.Debug("SendToLobby {0}", msgStr);
#endif
                    ret = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error("SendMessage throw exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
            return(ret);
        }
Exemple #29
0
        protected void Logging(string message, LogType en)
        {
            try
            {
                string threadInfo = GetThreadId();
                message = new StringBuilder().Append("- RequestUrl: ").Append(RequestUrl)
                          .Append("\n- UserName: "******"\n- ThreadInfo: ").Append(threadInfo)
                          .Append(message).ToString();
                switch (en)
                {
                case LogType.Debug:
                    LogSystem.Debug(message);
                    break;

                case LogType.Info:
                    LogSystem.Info(message);
                    break;

                case LogType.Warn:
                    LogSystem.Warn(message);
                    break;

                case LogType.Error:
                    LogSystem.Error(message);
                    break;

                case LogType.Fatal:
                    LogSystem.Fatal(message);
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error("AdapterBase.Logging.Exception.", ex);
            }
        }
Exemple #30
0
 internal object Decode(Type t, byte[] msgbuf)
 {
     m_DataStream.SetLength(0);
     m_DataStream.Write(msgbuf, 0, msgbuf.Length);
     m_DataStream.Position = 0;
     try
     {
         object msg = m_Serializer.Deserialize(m_DataStream, null, t);
         if (msg == null)
         {
             LogSystem.Debug("decode message error:can't find {0} len({1}) !!!", t.Name, msgbuf.Length);
             return(null);
         }
         //LogSystem.Debug("decode message:id {0} len({1})[{2}]", id, msgbuf.Length - 2, jsonData.GetType().Name);
         return(msg);
     }
     catch (Exception ex)
     {
         LogSystem.Error("decode message error:{0} len({1}) {2}\n{3}\nData:\n{4}", t.Name, msgbuf.Length, ex.Message, ex.StackTrace, CrossEngineHelper.BinToHex(msgbuf));
         throw ex;
     }
 }