public void OnGfxHitTarget(int id, int impactId, int targetId, int hitCount)
        {
            UserInfo playerSelf = WorldSystem.Instance.GetPlayerSelf();

            if (id == WorldSystem.Instance.PlayerSelfId && playerSelf != null)
            {
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (hitCount > 0)
                {
                    long lastHitTime = playerSelf.LastHitTime;
                    if (lastHitTime + 1500 > curTime)
                    {
                        playerSelf.MultiHitCount = playerSelf.MultiHitCount + hitCount;
                    }
                }
                WorldSystem.Instance.GetPlayerSelf().LastHitTime = curTime;
                GfxSystem.PublishGfxEvent("ge_hitcount", "ui", playerSelf.MultiHitCount);
            }
            CharacterInfo src    = WorldSystem.Instance.GetCharacterById(id);
            CharacterInfo target = WorldSystem.Instance.GetCharacterById(targetId);

            if (null != src && null != target)
            {
                ImpactSystem.Instance.SendImpactToCharacter(src, impactId, targetId);
            }
        }
Example #2
0
        internal void Init(SceneContextInfo context, int id, int objId, float faceDir)
        {
            m_SceneContext = context;
            m_CurTotalTime = 0;
            m_Id           = id;
            m_LastTime     = TimeUtility.GetLocalMilliseconds();
            m_FaceDir      = faceDir;
            m_ObjId        = objId;
            CharacterInfo info = m_SceneContext.GetCharacterInfoById(m_ObjId);

            if (null != info)
            {
                float curFaceDir = info.GetMovementStateInfo().GetFaceDir();
                m_DeltaDir = ((faceDir + c_2PI) - curFaceDir) % c_2PI;
                if (m_DeltaDir > c_PI)
                {
                    m_DeltaDir -= c_2PI;
                    m_TotalTime = -m_DeltaDir * c_TimePerRadian;
                }
                else
                {
                    m_TotalTime = m_DeltaDir * c_TimePerRadian;
                }
            }
            else
            {
                m_TotalTime = 0;
                m_DeltaDir  = 0;
            }
            //LogSystem.Debug("FaceController {0}, obj:{1}, faceDir:{2} deltaDir:{3} totalTime:{4} isTerminated:{5}", id, objId, faceDir, m_DeltaDir, m_TotalTime, m_IsTerminated);
        }
Example #3
0
 private void TickPve()
 {
     if (null != m_PlayerSelf)
     {
         long curTime = TimeUtility.GetLocalMilliseconds();
         if (m_PlayerSelf.LastHitTime + 1500 < curTime)
         {
             m_PlayerSelf.MultiHitCount = 0;
             GfxSystem.PublishGfxEvent("ge_hitcount", "ui", 0);
         }
     }
 }
Example #4
0
            public void Tick()
            {
#if !USE_DISK_LOG
                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastFlushTime + 10000 < curTime)
                {
                    m_LastFlushTime = curTime;

                    RequestFlush();
                    GfxSystem.GfxLog("LogicLogger.Tick.");
                }
#endif
            }
Example #5
0
        internal void Tick()
        {
            long time = TimeUtility.GetLocalMilliseconds();
            int  ct   = m_StoryLogicInfos.Count;

            for (int ix = ct - 1; ix >= 0; --ix)
            {
                StoryInstanceInfo info = m_StoryLogicInfos[ix];
                info.m_StoryInstance.Tick(time);
                if (info.m_StoryInstance.IsTerminated)
                {
                    RecycleStorylInstance(info);
                    m_StoryLogicInfos.RemoveAt(ix);
                }
            }
        }
Example #6
0
            public void Log(string format, params object[] args)
            {
                string msg = string.Format(format, args);

#if USE_DISK_LOG
                m_LogStream.WriteLine(msg);
#else
                m_LogQueue.Enqueue(msg);
                if (m_LogQueue.Count >= c_FlushCount)
                {
                    m_LastFlushTime = TimeUtility.GetLocalMilliseconds();

                    RequestFlush();
                }
#endif
            }
Example #7
0
        private void TickImpl()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

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

                CallGfxLog(string.Format("GfxSystem.Tick actionNum:{0}", m_GfxInvoker.CurActionNum));
            }
            m_GfxInvoker.HandleActions(4096);
            HandleInput();
            HandleSync();
            HandleLoadingProgress();
            ResourceManager.Instance.Tick();
        }
Example #8
0
        public override void Adjust()
        {
            CharacterInfo info = m_SceneContext.GetCharacterInfoById(m_ObjId);

            if (null != info)
            {
                float curTime = TimeUtility.GetLocalMilliseconds();
                float delta   = curTime - m_LastTime;
                m_LastTime      = curTime;
                m_CurTotalTime += delta;
                float moveDir = info.GetMovementStateInfo().GetMoveDir();
                if (m_CurTotalTime >= m_TotalTime || Math.Abs(moveDir - m_MoveDir) <= 0.1f)
                {
                    info.GetMovementStateInfo().SetMoveDir(m_MoveDir);

                    LogSystem.Debug("MoveDir adjust {0}", m_MoveDir);

                    m_IsTerminated = true;
                }
                else
                {
                    float offset = c_PI - (m_MoveDir + c_2PI - moveDir) % c_2PI;
                    if (offset * m_DeltaDir <= 0)
                    {
                        info.GetMovementStateInfo().SetMoveDir(m_MoveDir);

                        LogSystem.Debug("MoveDir adjust {0}", m_MoveDir);

                        m_IsTerminated = true;
                    }
                    else
                    {
                        float newMoveDir = (moveDir + c_2PI + delta * m_DeltaDir / m_TotalTime) % c_2PI;
                        info.GetMovementStateInfo().SetMoveDir(newMoveDir);

                        LogSystem.Debug("MoveDirController {0}, obj:{1}, moveDir:{2}->{3}, delta:{4} totalTime:{5} deltaDir:{6} targetDir:{7}", m_Id, m_ObjId, moveDir, newMoveDir, delta, m_TotalTime, m_DeltaDir, m_MoveDir);
                    }
                }
            }
            else
            {
                m_IsTerminated = true;
            }
        }
Example #9
0
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetLocalMilliseconds();

            if (m_LastTickTime + c_TickInterval < curTime)
            {
                m_LastTickTime = curTime;

                DBConn.KeepConnection();
                try {
                    MySqlConnection conn = DBConn.MySqlConn;
                    using (MySqlCommand cmd = new MySqlCommand("select * from GowStar where 1=2", conn)) {
                        cmd.ExecuteNonQuery();
                    }
                } catch (Exception ex) {
                    LogSys.Log(LOG_TYPE.INFO, "DbThread.Tick keep connection exception:{0}\n{1}", ex.Message, ex.StackTrace);
                }
            }
        }
Example #10
0
        protected override void OnTick()
        {
            //这里是在逻辑线程执行的tick,渲染线程的在GameControler.cs:TickGame里。
            try {
                TimeUtility.SampleClientTick();

                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastLogTime + 10000 < curTime)
                {
                    m_LastLogTime = curTime;

                    GfxSystem.GfxLog("LogicThread.Tick actionNum {0}", this.CurActionNum);
                }

                NetworkSystem.Instance.Tick();
                LobbyNetworkSystem.Instance.Tick();
                PlayerControl.Instance.Tick();
                WorldSystem.Instance.Tick();

                GameControler.LogicLoggerInstance.Tick();
            } catch (Exception ex) {
                GfxSystem.GfxLog("GameLogicThread.Tick throw Exception:{0}\n{1}", ex.Message, ex.StackTrace);
            }
        }