GetLocalMilliseconds() public static method

public static GetLocalMilliseconds ( ) : long
return long
        private void OnCommand(int worldId, int src, int dest, string command)
        {
            const string c_QuitLobby    = "QuitLobby";
            const string c_ReloadConfig = "ReloadConfig";

            try {
                if (worldId == UserServerConfig.WorldId)
                {
                    if (0 == command.CompareTo(c_QuitLobby))
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "receive {0} command, save data and then quitting ...", command);
                        if (!m_WaitQuit)
                        {
                            //收到关闭服务器指令,退出前保存数据
                            m_UserProcessScheduler.DefaultUserThread.QueueAction(m_UserProcessScheduler.DoLastSaveUserData);
                            m_GlobalProcessThread.QueueAction(m_GlobalProcessThread.DoLastSaveGlobalData);
                            m_LastWaitQuitTime = TimeUtility.GetLocalMilliseconds();
                            m_WaitQuit         = true;
                        }
                    }
                    else if (0 == command.CompareTo(c_ReloadConfig))
                    {
                        CenterHubApi.ReloadConfigScript();
                        UserServerConfig.Init();
                        LogSys.Log(LOG_TYPE.WARN, "receive {0} command.", command);
                    }
                }
                else
                {
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Beispiel #2
0
        internal void ActivateSkill(int actorId, int skillId, int seq)
        {
            EntityViewModel view = GetEntityViewById(actorId);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity    = view.Entity;
                SkillInfo  skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    SkillInfo curSkillInfo = entity.GetSkillStateInfo().GetCurSkillInfo();
                    if (null != curSkillInfo && (curSkillInfo.ConfigData.interruptPriority < skillInfo.ConfigData.interruptPriority))
                    {
                        GfxSkillSystem.Instance.StopSkill(actorId, curSkillInfo.SkillId, 0, true);
                        if (skillId == view.Entity.ManualSkillId)
                        {
                            LogSystem.Warn("ManualSkill {0} interrupt {1}.", skillId, curSkillInfo.SkillId);
                        }
                    }
                    if (skillId == view.Entity.ManualSkillId)
                    {
                        LogSystem.Warn("ManualSkill {0} activate.", skillId);
                    }
                    entity.GetSkillStateInfo().SetCurSkillInfo(skillId);
                    skillInfo.IsSkillActivated = true;
                    skillInfo.CdEndTime        = TimeUtility.GetLocalMilliseconds() + (long)skillInfo.ConfigData.cooldown;
                    if (skillInfo.ConfigData.addmp > 0 && !ClientModule.Instance.IsRoomScene)
                    {
                        //回蓝
                        entity.SetEnergy(Operate_Type.OT_Relative, skillInfo.ConfigData.addmp);
                        entity.EntityManager.FireDamageEvent(actorId, 0, false, false, 0, -skillInfo.ConfigData.addmp);
                    }
                }
            }
        }
Beispiel #3
0
        internal void Tick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime + c_TickInterval <= curTime || UserServer.Instance.WaitQuit)
            {
                m_LastTickTime = curTime;

                foreach (var pair in m_UnusedNicknames)
                {
                    if (pair.Value.Modified)
                    {
                        TableNicknameInfo record = pair.Value.ToProto();
                        UserServer.Instance.DataCacheThread.DSGSaveNickname(record);
                        pair.Value.Modified = false;
                    }
                }
                foreach (var pair in m_UsedNicknames)
                {
                    if (pair.Value.Modified)
                    {
                        TableNicknameInfo record = pair.Value.ToProto();
                        UserServer.Instance.DataCacheThread.DSGSaveNickname(record);
                        pair.Value.Modified = false;
                    }
                }
            }
        }
        public void SetAttackerInfo(int attackId, bool isKiller, bool isNormalAttack, bool isCritical, int hpDamage, int npDamage)
        {
            if (isKiller)
            {
                KillerId = attackId;
            }
            long curTime = TimeUtility.GetLocalMilliseconds();

            LastAttackedTime = curTime;
            AttackerInfo info;

            if (!AttackerInfos.TryGetValue(attackId, out info))
            {
                AttackerInfos.Add(attackId, new AttackerInfo {
                    m_AttackTime = curTime, m_HpDamage = hpDamage, m_NpDamage = npDamage
                });
            }
            else
            {
                info.m_AttackTime       = curTime;
                info.m_HpDamage        += hpDamage;
                info.m_NpDamage        += npDamage;
                AttackerInfos[attackId] = info;
            }
            EntityManager.FireDamageEvent(GetId(), attackId, isNormalAttack, isCritical, hpDamage, npDamage);
        }
Beispiel #5
0
        internal void Tick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime + c_TickInterval <= curTime || UserServer.Instance.WaitQuit)
            {
                m_LastTickTime = curTime;

                foreach (var pair in m_Datas)
                {
                    if (pair.Value.Modified)
                    {
                        TableGlobalData record = pair.Value.ToProto();
                        UserServer.Instance.DataCacheThread.SaveGlobalData(record);
                        pair.Value.Modified = false;
                    }
                    if (pair.Value.Deleted)
                    {
                        UserServer.Instance.DataCacheThread.DeleteGlobalData(pair.Key);
                        m_WaitDeletedDatas.Add(pair.Key);
                    }
                }
                foreach (var key in m_WaitDeletedDatas)
                {
                    m_Datas.Remove(key);
                }
                m_WaitDeletedDatas.Clear();
            }
        }
 internal void Tick()
 {
     var ds_thread = UserServer.Instance.DataCacheThread;
     if (ds_thread.DataStoreAvailable) {
         if (!m_IsDataLoaded) {
             return;
         }
     }
     long curTime = TimeUtility.GetLocalMilliseconds();
     if (m_LastTickTime + c_TickInterval < curTime) {
         m_LastTickTime = curTime;
         //清理过期邮件
         int ct = m_WholeMails.Count;
         for (int index = ct - 1; index >= 0; --index) {
             MailInfo mailInfo = m_WholeMails[index];
             if (null != mailInfo) {
                 if (mailInfo.m_ExpiryDate < DateTime.Now) {
                     m_WholeMails.RemoveAt(index);
                 }
             }
         }
         foreach (KeyValuePair<ulong, List<MailInfo>> pair in m_UserMails) {
             var mails = pair.Value;
             int mailCt = mails.Count;
             for (int index = mailCt - 1; index >= 0; --index) {
                 MailInfo mailInfo = mails[index];
                 if (null != mailInfo) {
                     if (mailInfo.m_ExpiryDate < DateTime.Now) {
                         mails.RemoveAt(index);
                     }
                 }
             }
         }
     }
 }
Beispiel #7
0
        public void ActivateSkill(int actorId, int skillId, int seq)
        {
            EntityViewModel view = GetEntityViewById(actorId);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity    = view.Entity;
                SkillInfo  skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    SkillInfo curSkillInfo = entity.GetSkillStateInfo().GetCurSkillInfo();
                    if (null != curSkillInfo && (curSkillInfo.ConfigData.skillData.interruptPriority < skillInfo.ConfigData.skillData.interruptPriority))
                    {
                        GfxSkillSystem.Instance.StopSkill(actorId, curSkillInfo.SkillId, 0, true);
                        if (skillId == view.Entity.ManualSkillId)
                        {
                            LogSystem.Warn("ManualSkill {0} interrupt {1}.", skillId, curSkillInfo.SkillId);
                        }
                    }
                    if (skillId == view.Entity.ManualSkillId)
                    {
                        LogSystem.Warn("ManualSkill {0} activate.", skillId);
                    }
                    entity.GetSkillStateInfo().SetCurSkillInfo(skillId);
                    skillInfo.IsSkillActivated = true;
                    skillInfo.CdEndTime        = TimeUtility.GetLocalMilliseconds() + (long)skillInfo.ConfigData.skillData.cooldown;
                    if (skillInfo.ConfigData.skillData.addsc > 0 && PluginFramework.Instance.IsBattleScene)
                    {
                        //回蓝
                        entity.Energy += skillInfo.ConfigData.skillData.addsc;
                        entity.EntityManager.FireDamageEvent(actorId, 0, false, false, 0, -skillInfo.ConfigData.skillData.addsc);
                    }
                }
            }
        }
        protected override void OnTick()
        {
            try {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastTickTime != 0)
                {
                    long elapsedTickTime = curTime - m_LastTickTime;
                    if (elapsedTickTime > c_WarningTickTime)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "SceneLoadThread Tick:{0}", elapsedTickTime);
                    }
                }
                m_LastTickTime = curTime;

                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    DebugPoolCount((string msg) => {
                        LogSys.Log(LOG_TYPE.INFO, "SceneLoadThread.ActionQueue {0}", msg);
                    });
                    LogSys.Log(LOG_TYPE.MONITOR, "SceneLoadThread.ActionQueue Current Action {0}", this.CurActionNum);
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Beispiel #9
0
        internal bool CheckOperation(ulong guid)
        {
            bool          ret     = true;
            long          curTime = TimeUtility.GetLocalMilliseconds();
            OperationInfo opInfo;

            if (m_OperationInfos.TryGetValue(guid, out opInfo))
            {
                if (opInfo.m_LastTime + c_MonitorInterval < curTime)
                {
                    opInfo.m_Count    = 0;
                    opInfo.m_LastTime = curTime;
                }
                else
                {
                    ++opInfo.m_Count;
                    if (opInfo.m_Count > c_MaxOperationCount)
                    {
                        ret = false;
                    }
                }
            }
            else
            {
                opInfo            = new OperationInfo();
                opInfo.m_LastTime = curTime;
                m_OperationInfos.TryAdd(guid, opInfo);
            }
            return(ret);
        }
Beispiel #10
0
 internal void RequestSave(Msg_LD_Save msg, MyAction <Msg_DL_SaveResult> callback = null)
 {
     lock (m_SaveRequestQueuesLock) {
         msg.SerialNo = GenNextSerialNo();
         KeyString key = KeyString.Wrap(msg.PrimaryKeys);
         ConcurrentDictionary <KeyString, ConcurrentQueue <SaveRequestInfo> > dict;
         if (!m_SaveRequestQueues.TryGetValue(msg.MsgId, out dict))
         {
             dict = m_SaveRequestQueues.AddOrUpdate(msg.MsgId, new ConcurrentDictionary <KeyString, ConcurrentQueue <SaveRequestInfo> >(), (k, v) => v);
         }
         ConcurrentQueue <SaveRequestInfo> queue;
         if (!dict.TryGetValue(key, out queue))
         {
             queue = dict.AddOrUpdate(key, new ConcurrentQueue <SaveRequestInfo>(), (k, v) => v);
         }
         SaveRequestInfo info = m_SaveRequestPool.Alloc();
         info.m_Request  = msg;
         info.m_Callback = callback;
         if (queue.Count == 0)
         {
             //当前队列为空时直接发送消息
             info.m_LastSendTime = TimeUtility.GetLocalMilliseconds();
             m_DataStoreChannel.Send(msg);
         }
         queue.Enqueue(info);
     }
 }
Beispiel #11
0
        private void OnSaveReply(Msg_DL_SaveResult msg, PBChannel channel, int src, uint session)
        {
            KeyString key = KeyString.Wrap(msg.PrimaryKeys);
            ConcurrentDictionary <KeyString, ConcurrentQueue <SaveRequestInfo> > dict;

            if (m_SaveRequestQueues.TryGetValue(msg.MsgId, out dict))
            {
                ConcurrentQueue <SaveRequestInfo> reqQueue;
                if (dict.TryGetValue(key, out reqQueue))
                {
                    SaveRequestInfo info;
                    if (reqQueue.TryPeek(out info))
                    {
                        if (info.m_Request.SerialNo == msg.SerialNo)
                        {
                            if (null != info.m_Callback)
                            {
                                info.m_Callback(msg);
                            }
                            SaveRequestInfo delInfo;
                            if (reqQueue.TryDequeue(out delInfo))
                            {
                                m_SaveRequestPool.Recycle(delInfo);
                            }
                            //发送队列中的下一个消息
                            if (reqQueue.TryPeek(out info))
                            {
                                info.m_LastSendTime = TimeUtility.GetLocalMilliseconds();
                                m_DataStoreChannel.Send(info.m_Request);
                            }
                        }
                    }
                }
            }
        }
Beispiel #12
0
 public void Finish(int winnerCampID)
 {
     if (IsFieldRoom)
     {
         return;
     }
     if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive)
     {
         return;
     }
     foreach (User user in m_RoomUserMgr.RoomUsers)
     {
         if (user != null)
         {
             Msg_RL_UserDrop unqBuilder = new Msg_RL_UserDrop();
             unqBuilder.RoomId      = m_RoomId;
             unqBuilder.UserGuid    = user.Guid;
             unqBuilder.IsBattleEnd = true;
             m_Connector.SendMsgToLobby(unqBuilder);
             user.LastNotifyUserDropTime = TimeUtility.GetLocalMilliseconds();
         }
     }
     this.CurrentState = RoomState.Finish;
     m_FinishTime      = TimeUtility.GetLocalMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) EndBattle.", RoomId, LocalID);
 }
Beispiel #13
0
 public bool AddNewUser(User newUser)
 {
     foreach (User us in m_RoomUsers)
     {
         if (us != null && us.Guid == newUser.Guid)
         {
             //当前玩家已在游戏房间内
             if (us.GetKey() == newUser.GetKey())
             {
                 LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                            m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                 LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey());
                 m_UserPool.FreeUser(newUser.LocalID);
                 return(true);
             }
             else if (us.UserControlState != (int)UserControlState.User)
             {
                 LogSys.Log(LOG_TYPE.DEBUG, "Add user success: User already in the room! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                            m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                 LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for old {1} {2}, [Room.AddNewUser]", us.LocalID, us.Guid, us.GetKey());
                 RemoveUser(us);
                 break;
             }
             else
             {
                 LogSys.Log(LOG_TYPE.DEBUG, "Add user false: User already in the room and online! RoomId:{0}, Guid:{1}, OldUser[{2}]({3}) NewUser[{4}]({5}) ",
                            m_RoomId, us.Guid, us.LocalID, us.GetKey(), newUser.LocalID, newUser.GetKey());
                 LogSys.Log(LOG_TYPE.INFO, "FreeUser {0} for new {1} {2}, [Room.AddNewUser]", newUser.LocalID, newUser.Guid, newUser.GetKey());
                 m_UserPool.FreeUser(newUser.LocalID);
                 return(false);
             }
         }
     }
     newUser.EnterRoomTime      = TimeUtility.GetLocalMilliseconds();
     newUser.OwnRoomUserManager = this;
     newUser.RegisterObservers(m_RoomObservers);
     newUser.CharacterCreateTime = TimeUtility.GetLocalMilliseconds();
     newUser.TimeCounter         = 0;
     if ((int)UserControlState.Ai == newUser.UserControlState)
     {
         newUser.IsEntered = true;
     }
     if (null != m_ActiveScene && m_ActiveScene.SceneState == SceneState.Running)
     {
         Scene scene = m_ActiveScene;
         scene.EnterScene(newUser);
     }
     foreach (User otheruser in m_RoomUsers)
     {
         if (otheruser != null)
         {
             otheruser.AddSameRoomUser(newUser);
             newUser.AddSameRoomUser(otheruser);
         }
     }
     m_RoomUsers.Add(newUser);
     LogSys.Log(LOG_TYPE.DEBUG, "Add user success ! RoomId:{0} , UserGuid:{1}({2})",
                m_RoomId, newUser.Guid, newUser.GetKey());
     return(true);
 }
Beispiel #14
0
        private void OnAiAddImpact(EntityInfo npc, int impactId)
        {
            Scene scene = npc.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                ImpactInfo impactInfo = new ImpactInfo(impactId);
                impactInfo.StartTime      = TimeUtility.GetLocalMilliseconds();
                impactInfo.ImpactSenderId = npc.GetId();
                impactInfo.SkillId        = 0;
                if (null != impactInfo.ConfigData)
                {
                    npc.GetSkillStateInfo().AddImpact(impactInfo);
                    int seq = impactInfo.Seq;
                    if (scene.SkillSystem.StartSkill(npc.GetId(), impactInfo.ConfigData, seq))
                    {
                        Msg_RC_AddImpact addImpactBuilder = new Msg_RC_AddImpact();
                        addImpactBuilder.sender_id = npc.GetId();
                        addImpactBuilder.target_id = npc.GetId();
                        addImpactBuilder.impact_id = impactId;
                        addImpactBuilder.skill_id  = -1;
                        addImpactBuilder.duration  = impactInfo.DurationTime;
                        scene.NotifyAllUser(RoomMessageDefine.Msg_RC_AddImpact, addImpactBuilder);
                    }
                }
            }
        }
Beispiel #15
0
        private void OnAiSkill(EntityInfo npc, int skillId)
        {
            Scene scene = npc.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo();
                if (null == skillInfo || !skillInfo.IsSkillActivated)
                {
                    SkillInfo curSkillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId);
                    if (null != curSkillInfo)
                    {
                        long curTime = TimeUtility.GetLocalMilliseconds();
                        if (!curSkillInfo.IsInCd(curTime))
                        {
                            if (scene.SkillSystem.StartSkill(npc.GetId(), curSkillInfo.ConfigData, 0))
                            {
                                Msg_RC_NpcSkill skillBuilder = DataSyncUtility.BuildNpcSkillMessage(npc, skillId);

                                LogSystem.Info("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                               npc.GetId(), skillId);
                                scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcSkill, skillBuilder);
                            }
                        }
                    }
                }
            }
        }
Beispiel #16
0
        internal void ActivateSkill(int objId, int skillId, int seq)
        {
            EntityInfo entity = m_Scene.EntityManager.GetEntityInfo(objId);

            if (null != entity)
            {
                SkillInfo skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    SkillInfo curSkillInfo = entity.GetSkillStateInfo().GetCurSkillInfo();
                    if (null != curSkillInfo && (curSkillInfo.ConfigData.interruptPriority < skillInfo.ConfigData.interruptPriority))
                    {
                        m_Scene.SkillSystem.StopSkill(objId, curSkillInfo.SkillId, 0, true);
                        if (skillId == entity.ManualSkillId)
                        {
                            LogSystem.Warn("ManualSkill {0} interrupt {1}.", skillId, curSkillInfo.SkillId);
                        }
                    }
                    if (skillId == entity.ManualSkillId)
                    {
                        LogSystem.Warn("ManualSkill {0} activate.", skillId);
                    }
                    entity.GetSkillStateInfo().SetCurSkillInfo(skillId);
                    skillInfo.IsSkillActivated = true;
                    skillInfo.CdEndTime        = TimeUtility.GetLocalMilliseconds() + (long)skillInfo.ConfigData.cooldown;
                    if (skillInfo.ConfigData.addmp > 0)
                    {
                        //回蓝
                        entity.SetEnergy(Operate_Type.OT_Relative, skillInfo.ConfigData.addmp);
                        entity.EntityManager.FireDamageEvent(objId, 0, false, false, 0, -skillInfo.ConfigData.addmp);
                    }
                }
            }
        }
 public void Tick()
 {
     if (0 == m_LastTickTime)
     {
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
         LogSystem.Info("MovementSystem LastTickTime:{0}", m_LastTickTime);
     }
     else
     {
         long delta = TimeUtility.GetLocalMilliseconds() - m_LastTickTime;
         m_LastTickTime = TimeUtility.GetLocalMilliseconds();
         if (delta > 1000)
         {
             delta = 1000;
         }
         if (null != m_EntityMgr)
         {
             for (LinkedListNode <EntityInfo> node = m_EntityMgr.Entities.FirstNode; null != node; node = node.Next)
             {
                 EntityInfo npc = node.Value;
                 if (null != npc)
                 {
                     MoveNpc(npc, delta);
                 }
             }
         }
     }
 }
Beispiel #18
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime != 0)
            {
                long elapsedTickTime = curTime - m_LastTickTime;
                if (elapsedTickTime > c_WarningTickTime)
                {
                    LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread Tick:{0}", elapsedTickTime);
                }
            }
            m_LastTickTime = curTime;
            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;

                DebugPoolCount((string msg) => {
                    LogSys.Log(LOG_TYPE.INFO, "GlobalProcessThread.ActionQueue {0}", msg);
                });
                LogSys.Log(LOG_TYPE.MONITOR, "GlobalProcessThread.ActionQueue Current Action {0}", this.CurActionNum);
            }
            //逻辑Tick
            GlobalData.Instance.Tick();
            UserServer.Instance.UserProcessScheduler.NicknameSystem.Tick();
            m_MailSystem.Tick();
            //全局数据存储
            long saveStartTime = 0;
            var  dsThread      = UserServer.Instance.DataCacheThread;

            if (dsThread.DataStoreAvailable)
            {
                if (m_GuidCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveGuid(m_GuidSystem.GuidList, m_GuidCounter.NextSaveCount);
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Guid SaveCount:{0}, Time:{1}", m_GuidCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_GuidCounter.IncreaseNextSaveCount();
                }
                if (m_MailCounter.IsTimeToSave(curTime))
                {
                    saveStartTime = TimeUtility.GetLocalMilliseconds();
                    dsThread.SaveMail(m_MailSystem.TotalMailList, m_MailCounter.NextSaveCount);
                    dsThread.SaveDeletedMail(m_MailSystem.TotalDeletedMailList, m_MailCounter.NextSaveCount);
                    m_MailSystem.ResetDeletedMailList();
                    LogSys.Log(LOG_TYPE.DEBUG, "GlobalDataSave Mail SaveCount:{0}, Time:{1}", m_MailCounter.NextSaveCount, TimeUtility.GetLocalMilliseconds() - saveStartTime);
                    m_MailCounter.IncreaseNextSaveCount();
                }
                if (m_IsLastSave && IsLastSaveAllDone())
                {
                    if (m_LastSaveFinished == false)
                    {
                        //全局数据(Guid、邮件)存储完成
                        LogSys.Log(LOG_TYPE.MONITOR, "DoLastSaveGlobalData Step_2: GlobalData last save done");
                        m_IsLastSave       = false;
                        m_LastSaveFinished = true;
                    }
                }
            }
        }
        public bool CastSkill(int objId, int skillId)
        {
            bool       ret = false;
            EntityInfo obj = GetEntityById(objId);

            if (null != obj)
            {
                SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    if (!skillInfo.IsInCd(TimeUtility.GetLocalMilliseconds()))
                    {
                        int targetId = 0;
                        if (null != SelectedTarget)
                        {
                            targetId = SelectedTarget.TargetId;
                        }
                        if (!IsBattleState)
                        {
                            Network.NetworkSystem.Instance.SyncPlayerSkill(obj, skillId, targetId, obj.GetMovementStateInfo().GetFaceDir());
                        }
                        else
                        {
                            AiStateInfo aiInfo = obj.GetAiStateInfo();
                            aiInfo.Target = targetId;
                            GfxSkillSystem.Instance.StartSkill(objId, skillInfo.ConfigData, 0);
                        }
                        ret = true;
                    }
                }
            }
            return(ret);
        }
Beispiel #20
0
        private void TickPreloading()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastPreloadingTickTime + c_PreloadingTickInterval < curTime)
            {
                m_LastPreloadingTickTime = curTime;

                bool haveUser = false;
                bool canStart = true;
                foreach (User us in m_RoomInfo.RoomUsers)
                {
                    if (us.IsEntered)
                    {
                        haveUser = true;
                    }
                }
                if (!haveUser)
                {
                    canStart = false;
                }

                if (canStart)
                {
                    LoadObjects();
                    RoomUserManager roomUserMgr = GetRoomUserManager();
                    if (null != roomUserMgr)
                    {
                        foreach (User us in m_RoomInfo.RoomUsers)
                        {
                            EnterScene(us);
                        }
                    }
                    //先让各客户端创建自己与场景相关信息
                    foreach (User us in m_RoomInfo.RoomUsers)
                    {
                        if (us.IsEntered)
                        {
                            //发玩家阵营给玩家
                            Msg_RC_CampChanged msg = new Msg_RC_CampChanged();
                            msg.obj_id  = 0;
                            msg.camp_id = us.LobbyUserData.Camp;
                            us.SendMessage(RoomMessageDefine.Msg_RC_CampChanged, msg);
                            //将场景里的对象发给玩家
                            SyncSceneObjectsToUser(us);
                        }
                    }
                    //给观察者发初始玩家与场景对象信息
                    foreach (Observer observer in m_RoomInfo.RoomObservers)
                    {
                        if (null != observer && !observer.IsIdle && observer.IsEntered)
                        {
                            SyncForNewObserver(observer);
                        }
                    }
                    m_SceneState = SceneState.Running;
                }
            }
        }
Beispiel #21
0
 public void Disconnect()
 {
     if (null != m_Connection && NetConnectionStatus.Connected == m_Connection.Status)
     {
         m_Connection.Disconnect("disconnect");
         SetLastPingTime(TimeUtility.GetLocalMilliseconds() - m_ConnectionOverTime);
     }
 }
        protected override void OnTick()
        {
            try {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastTickTime != 0)
                {
                    long elapsedTickTime = curTime - m_LastTickTime;
                    if (elapsedTickTime > c_WarningTickTime)
                    {
                        LogSys.Log(LOG_TYPE.MONITOR, "RoomThread Tick:{0}", elapsedTickTime);
                    }
                }
                m_LastTickTime = curTime;

                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    DebugPoolCount((string msg) => {
                        LogSys.Log(LOG_TYPE.INFO, "RoomThread.ActionQueue {0}, thread {1}", msg, cur_thread_id_);
                    });
                    LogSys.Log(LOG_TYPE.MONITOR, "RoomThread.ActionQueue Current Action {0}", this.CurActionNum);
                }

                long tick_interval_us = tick_interval_ * 1000;
                TimeSnapshot.Start();
                DoTick();
                long elapsedTime = TimeSnapshot.End();
                if (elapsedTime >= tick_interval_us)
                {
                    if (elapsedTime >= tick_interval_us * 2)
                    {
                        LogSys.Log(LOG_TYPE.DEBUG, "*** Warning, RoomThread tick interval is {0} us !", elapsedTime);
                        foreach (Room room in active_room_)
                        {
                            Scene scene = room.ActiveScene;
                            if (null != scene)
                            {
                                if (scene.SceneState == SceneState.Running)
                                {
                                    SceneProfiler profiler = scene.SceneProfiler;
                                    LogSys.Log(LOG_TYPE.DEBUG, "{0}", profiler.GenerateLogString(scene.SceneResId, scene.GameTime.ElapseMilliseconds));
                                }
                            }
                        }
                    }
                    Thread.Sleep(0);
                }
                else
                {
                    Thread.Sleep((int)(tick_interval_ - elapsedTime / 1000));
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
        public bool CastSkill(int objId, int skillId)
        {
            bool       ret = false;
            EntityInfo obj = GetEntityById(objId);

            if (null != obj)
            {
                SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    if (obj.Energy >= obj.GetActualProperty().EnergyMax)
                    {
                        if (!skillInfo.IsInCd(TimeUtility.GetLocalMilliseconds()))
                        {
                            int targetId = 0;
                            if (null != SelectedTarget)
                            {
                                targetId = SelectedTarget.TargetId;
                            }
                            if (IsRoomScene)
                            {
                                Network.NetworkSystem.Instance.SyncPlayerSkill(obj, skillId, targetId, obj.GetMovementStateInfo().GetFaceDir());
                            }
                            else
                            {
                                AiStateInfo aiInfo = obj.GetAiStateInfo();
                                aiInfo.Target = targetId;
                                if (aiInfo.AiLogic == (int)AiStateLogicId.Entity_Leader)
                                {
                                    AiData_Leader data = aiInfo.AiDatas.GetData <AiData_Leader>();
                                    if (null == data)
                                    {
                                        data = new AiData_Leader();
                                        aiInfo.AiDatas.AddData(data);
                                    }
                                    data.ManualSkillId = skillId;
                                }
                                else
                                {
                                    AiData_General data = aiInfo.AiDatas.GetData <AiData_General>();
                                    if (null == data)
                                    {
                                        data = new AiData_General();
                                        aiInfo.AiDatas.AddData(data);
                                    }
                                    data.ManualSkillId = skillId;
                                }
                                aiInfo.ChangeToState((int)AiStateId.SkillCommand);
                            }
                            ret = true;
                        }
                    }
                }
            }
            return(ret);
        }
        private void DslLogicHandler(EntityInfo entity, long deltaTime)
        {
            AiStateInfo info = entity.GetAiStateInfo();

            if (null != info.AiStoryInstanceInfo)
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                info.AiStoryInstanceInfo.m_StoryInstance.Tick(curTime);
            }
        }
Beispiel #25
0
        public long GetElapsedDroppedTime()
        {
            long time = 0;

            if (IsTimeout())
            {
                long current_time = TimeUtility.GetLocalMilliseconds();
                time = current_time - m_LastPingTime - m_ConnectionOverTime;
            }
            return(time);
        }
Beispiel #26
0
            internal void Tick()
            {
#if !USE_DISK_LOG
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastFlushTime + 10000 < curTime)
                {
                    m_LastFlushTime = curTime;

                    RequestFlush();
                }
#endif
            }
Beispiel #27
0
 private void Deactive()
 {
     //准备关闭房间
     for (int index = m_RoomUserMgr.RoomUsers.Count - 1; index >= 0; --index)
     {
         User user = m_RoomUserMgr.RoomUsers[index];
         m_RoomUserMgr.RemoveUser(user);
     }
     this.CurrentState = RoomState.Deactive;
     m_CanCloseTime    = TimeUtility.GetLocalMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) Deactive.", RoomId, LocalID);
 }
Beispiel #28
0
        internal void SampleMoveData(float x, float z, float velocity, float cosDir, float sinDir)
        {
            m_LastClientPosition.X = x;
            m_LastClientPosition.Y = 0;
            m_LastClientPosition.Z = z;
            m_LastMoveVelocity     = velocity;
            m_LastMoveDirCosAngle  = cosDir;
            m_LastMoveDirSinAngle  = sinDir;
            m_LastSampleTime       = TimeUtility.GetLocalMilliseconds();

            //LogSys.Log(LOG_TYPE.WARN, "SampleMoveData user:{0}({1},{2},{3}) x:{4} z:{5} v:{6} cos:{7} sin:{8} time:{9}", RoleId, GetKey(), Guid, Name, x, z, velocity, cosDir, sinDir, time);
        }
Beispiel #29
0
 private void Deactive()
 {
     //准备关闭房间
     for (int index = room_users_.Count - 1; index >= 0; --index)
     {
         User user = room_users_[index];
         RemoveUser(user);
     }
     this.CurrentState = RoomState.Deactive;
     can_close_time_   = TimeUtility.GetLocalMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) Deactive.", RoomID, LocalID);
 }
Beispiel #30
0
        public bool IsTimeout()
        {
            long current_time = TimeUtility.GetLocalMilliseconds();

            if (current_time <= m_EnterRoomTime + m_FirstEnterWaitTime)
            {
                return(false);
            }
            if (current_time - m_LastPingTime > m_ConnectionOverTime)
            {
                return(true);
            }
            return(false);
        }