Пример #1
0
 public void SendImpactToCharacter(CharacterInfo sender, int impactId, int targetId)
 {
     //LogSystem.Debug("character {0} send impact {1} to character {2}", sender.GetId(), impactId, targetId);
     if (null != sender)
     {
         CharacterInfo target = sender.SceneContext.GetCharacterInfoById(targetId);
         if (null != target)
         {
             ImpactLogicData impactLogicData = (ImpactLogicData)SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_IMPACT, impactId);
             if (null != impactLogicData)
             {
                 IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactLogicData.ImpactLogicId);
                 if (null != logic)
                 {
                     ImpactInfo impactInfo = new ImpactInfo();
                     impactInfo.m_IsActivated      = true;
                     impactInfo.m_ImpactId         = impactLogicData.ImpactId;
                     impactInfo.ConfigData         = impactLogicData;
                     impactInfo.m_StartTime        = TimeUtility.GetServerMilliseconds();
                     impactInfo.m_ImpactDuration   = impactLogicData.ImpactTime;
                     impactInfo.m_ImpactSenderId   = sender.GetId();
                     impactInfo.m_HasEffectApplyed = false;
                     target.GetSkillStateInfo().AddImpact(impactInfo);
                 }
             }
         }
     }
 }
Пример #2
0
        private void TickUsers()
        {
            for (LinkedListNode <UserInfo> linkNode = m_UserMgr.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    LogSystem.Debug("UserAttrCalculate LevelChanged:{0} WeaponChanged:{1} BuffChanged:{2} EquipmentChanged:{3}", info.LevelChanged, info.GetShootStateInfo().WeaponChanged, info.GetSkillStateInfo().BuffChanged, info.GetEquipmentStateInfo().EquipmentChanged);
                    UserAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetShootStateInfo().WeaponChanged        = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                }
            }
            UserInfo player = WorldSystem.Instance.GetPlayerSelf();

            if (null != player && player.Hp <= 0)
            {
                if (player.DeadTime <= 0)
                {
                    GfxSystem.PublishGfxEvent("ge_show_relive", "ui", null);
                    player.DeadTime = TimeUtility.GetServerMilliseconds();
                }
            }
        }
Пример #3
0
 protected override void UpdateIdle()
 {
     if ((int)AiStateId.Idle == m_Npc.GetAiStateInfo().CurState)
     {
         if (!GetOwner().IsDead() && m_CharacterAnimationInfo.IsIdle())
         {
             if (m_IdleState == IdleState.kNotIdle)
             {
                 PlayAnimation(Animation_Type.AT_Stand);
                 m_IdleState     = IdleState.kBegin;
                 m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                 m_IdleInterval  = Helper.Random.Next(3, 7) * 1000;
             }
             else if (m_IdleState == IdleState.kBegin)
             {
                 if (TimeUtility.GetServerMilliseconds() - m_BeginIdleTime > m_IdleInterval)
                 {
                     PlayAnimation(GetNextIdleAnim());
                     PlayQueuedAnimation(Animation_Type.AT_Stand);
                     m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                     m_IdleInterval  = Helper.Random.Next(3, 7) * 1000;
                 }
             }
             else
             {
                 m_IdleState = IdleState.kNotIdle;
             }
         }
     }
     else
     {
         base.UpdateIdle();
     }
 }
Пример #4
0
        public void Init(int id, int objId, float faceDir)
        {
            m_CurTotalTime = 0;
            m_Id           = id;
            m_LastTime     = TimeUtility.GetServerMilliseconds();
            m_FaceDir      = faceDir;
            m_ObjId        = objId;
            CharacterInfo info = WorldSystem.Instance.GetCharacterById(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);
        }
Пример #5
0
        private static void MoveToNext(NpcInfo npc, AiData_ForMoveCommand data)
        {
            if (++data.Index >= data.WayPoints.Count)
            {
                data.IsFinish = true;
                return;
            }

            var     move_info = npc.GetMovementStateInfo();
            Vector3 from      = move_info.GetPosition3D();
            Vector3 to        = data.WayPoints[data.Index];
            float   move_dir  = MoveDirection(from, to);

            float now      = TimeUtility.GetServerMilliseconds();
            float distance = Geometry.Distance(from, to);
            float speed    = npc.GetActualProperty().MoveSpeed;

            data.EstimateFinishTime = now + 1000 * (distance / speed);
            DLog._("ai_move", "[{0}]: now({1}), from({2}), to({3}), distance({4}), speed({5}), move_time({6}), estimate({7})",
                   npc.GetId(), now, from.ToString(), to.ToString(), distance, speed, 1000 * (distance / speed), data.EstimateFinishTime);

            move_info.IsMoving = true;
            move_info.SetMoveDir(move_dir);
            move_info.SetFaceDir(move_dir);
        }
Пример #6
0
 public void Tick()
 {
     if (0 == m_LastTickTime)
     {
         m_LastTickTime = TimeUtility.GetServerMilliseconds();
     }
     else
     {
         long delta = TimeUtility.GetServerMilliseconds() - m_LastTickTime;
         m_LastTickTime = TimeUtility.GetServerMilliseconds();
         if (null != m_NpcMgr)
         {
             for (LinkedListNode <NpcInfo> linkNode = m_NpcMgr.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 NpcInfo npc = linkNode.Value;
                 TickNpc(npc, delta);
             }
         }
         if (null != m_UserMgr)
         {
             for (LinkedListNode <UserInfo> linkNode = m_UserMgr.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 UserInfo user = linkNode.Value;
                 TickUser(user, delta);
             }
         }
     }
 }
Пример #7
0
        private void TickPreloading()
        {
            long curTime = TimeUtility.GetServerMilliseconds();

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

                bool canStart = true;
                foreach (User us in m_Room.RoomUsers)
                {
                    if (!us.IsEntered && !us.IsTimeout())
                    {
                        canStart = false;
                    }
                }

                if (canStart)
                {
                    LoadObjects();
                    CalculateDropOut();
                    m_StorySystem.StartStory(1);
                    for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        UserInfo user = linkNode.Value;
                        UserAttrCalculator.Calc(user);
                        user.LevelChanged = false;
                        user.SetHp(Operate_Type.OT_Absolute, user.GetActualProperty().HpMax);
                        user.SetEnergy(Operate_Type.OT_Absolute, user.GetActualProperty().EnergyMax);
                    }
                    //先让各客户端创建自己与场景相关信息
                    foreach (User us in m_Room.RoomUsers)
                    {
                        if (us.IsEntered)
                        {
                            SyncUserToSelf(us);
                            SyncSceneObjectsToUser(us);
                        }
                    }
                    //再通知其他客户端看见自己
                    foreach (User us in m_Room.RoomUsers)
                    {
                        if (us.IsEntered)
                        {
                            SyncUserToOthers(us);
                        }
                    }
                    //给观察者发初始玩家与场景对象信息
                    foreach (Observer observer in m_Room.RoomObservers)
                    {
                        if (null != observer && !observer.IsIdle && observer.IsEntered)
                        {
                            SyncForNewObserver(observer);
                        }
                    }
                }
            }
        }
Пример #8
0
        private void CalcKillIncome(UserInfo user)
        {
            long curTime = TimeUtility.GetServerMilliseconds();

            if (m_IsPvpScene)
            {
                int lvl2 = user.GetLevel();
                int lvl1 = lvl2 - 1;
                if (lvl1 < 0)
                {
                    lvl1 = 0;
                }
                PlayerLevelupExpConfig cfg1 = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(lvl1);
                PlayerLevelupExpConfig cfg2 = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(lvl2);
                if (null != cfg1 && null != cfg2)
                {
                    int      exp    = (cfg2.m_ConsumeExp - cfg1.m_ConsumeExp) * 70 / 100;
                    UserInfo killer = UserManager.GetUserInfo(user.KillerId);
                    if (null != killer)
                    {
                        //被英雄击杀连杀数清0
                        user.GetCombatStatisticInfo().ClearContinueKillCount();
                        //击杀英雄连死数清0
                        killer.GetCombatStatisticInfo().ClearContinueDeadCount();

                        user.GetCombatStatisticInfo().AddContinueDeadCount(1);
                        killer.GetCombatStatisticInfo().AddContinueKillCount(1);

                        killer.GetCombatStatisticInfo().AddKillHeroCount(1);
                        if (killer.GetCombatStatisticInfo().LastKillHeroTime + 10000 < curTime)
                        {
                            killer.GetCombatStatisticInfo().ClearMultiKillCount();
                        }
                        killer.GetCombatStatisticInfo().AddMultiKillCount(1);
                        killer.GetCombatStatisticInfo().LastKillHeroTime = curTime;

                        User us       = killer.CustomData as User;
                        User killedUs = user.CustomData as User;
                        if (us != null && killedUs != null)
                        {
                            CalcPvpCombatInfo(killer.GetLinkId(), user.GetLinkId(), us.Name, killedUs.Name);
                        }
                        if (user.AttackerInfos.Count > 0)
                        {
                            foreach (int id in user.AttackerInfos.Keys)
                            {
                                UserInfo assit = UserManager.GetUserInfo(id);
                                CharacterInfo.AttackerInfo attackInfo = user.AttackerInfos[id];
                                if (null != assit && killer != assit && attackInfo.m_AttackTime + 5000 >= curTime)
                                {
                                    assit.GetCombatStatisticInfo().AddAssitKillCount(1);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #9
0
 internal void MpveEndBattle(int kill_npc_ct)
 {
     if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive)
     {
         return;
     }
     foreach (User user in room_users_)
     {
         if (user != null)
         {
             Msg_RL_UserQuit.Builder unqBuilder = Msg_RL_UserQuit.CreateBuilder();
             unqBuilder.SetRoomID(cur_room_id_);
             unqBuilder.SetUserGuid(user.Guid);
             unqBuilder.SetIsBattleEnd(true);
             connector_.SendMsgToLobby(unqBuilder.Build());
         }
     }
     //向Lobby发送战斗结束消息:RoomID,胜方阵营,开始时间,结束时间。。。
     Msg_RL_BattleEnd.Builder beBuilder = Msg_RL_BattleEnd.CreateBuilder();
     beBuilder.SetRoomID(RoomID);
     Msg_RL_BattleEnd.Types.WinnerCampEnum winCamp = Msg_RL_BattleEnd.Types.WinnerCampEnum.None;
     beBuilder.SetWinnerCamp(winCamp);
     //战斗数据
     foreach (User user in room_users_)
     {
         if (user != null)
         {
             var battleRecord = user.Info.GetCombatStatisticInfo();
             Msg_RL_UserBattleInfo.Builder ubrBuilder = Msg_RL_UserBattleInfo.CreateBuilder();
             ubrBuilder.SetUserGuid(user.Guid);
             Msg_RL_UserBattleInfo.Types.BattleResultEnum result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Unfinish;
             if (kill_npc_ct > 0)
             {
                 result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Win;
             }
             else
             {
                 result = Msg_RL_UserBattleInfo.Types.BattleResultEnum.Lost;
             }
             ubrBuilder.SetBattleResult(result);
             ubrBuilder.SetMoney(user.Info.Money);
             CombatStatisticInfo combatInfo = user.Info.GetCombatStatisticInfo();
             ubrBuilder.SetHitCount(combatInfo.HitCount);
             ubrBuilder.SetKillNpcCount(kill_npc_ct);
             ubrBuilder.SetMaxMultiHitCount(combatInfo.MaxMultiHitCount);
             ubrBuilder.SetTotalDamageToMyself(combatInfo.TotalDamageToMyself);
             ubrBuilder.SetTotalDamageFromMyself(combatInfo.TotalDamageFromMyself);
             beBuilder.AddUserBattleInfos(ubrBuilder.Build());
         }
     }
     connector_.SendMsgToLobby(beBuilder.Build());
     this.CurrentState = RoomState.Finish;
     m_FinishTime      = TimeUtility.GetServerMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) MpveEndBattle.", RoomID, LocalID);
 }
Пример #10
0
 public void Init(int id, int objId, float dx, float dy, float dz, float totalTime)
 {
     m_Id           = id;
     m_ObjId        = objId;
     m_Dx           = dx;
     m_Dy           = dy;
     m_Dz           = dz;
     m_CurTotalTime = 0;
     m_LastTime     = TimeUtility.GetServerMilliseconds();
     m_TotalTime    = totalTime;
 }
Пример #11
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.GetServerMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) Deactive.", RoomID, LocalID);
 }
Пример #12
0
        private static void UpdateCharacterHitCount(CharacterInfo character, int hit_count)
        {
            UserInfo user = character as UserInfo;

            if (user == null)
            {
                return;
            }
            CombatStatisticInfo combat_info = user.GetCombatStatisticInfo();

            combat_info.MultiHitCount = hit_count;
            combat_info.LastHitTime   = TimeUtility.GetServerMilliseconds();
        }
Пример #13
0
 private static bool WayPointArrived(NpcInfo npc, AiData_ForMoveCommand data)
 {
     if (TimeUtility.GetServerMilliseconds() >= data.EstimateFinishTime)
     {
         var     move_info = npc.GetMovementStateInfo();
         Vector3 to        = data.WayPoints[data.Index];
         Vector3 now       = move_info.GetPosition3D();
         float   distance  = Geometry.Distance(now, to);
         DLog._("ai_move", "[{0}]: closest distance({1}) ", npc.GetId(), distance);
         return(true);
     }
     return(false);
 }
Пример #14
0
 private void BeginFollow(DashFireSpatial.ISpaceObject targetObj)
 {
     if (m_Status == SearchLightStatus.kPatrol)
     {
         m_BeginFollowPos = m_CurPos;
     }
     m_CurFollowObj = targetObj;
     if (m_NextTriggerTime == 0)
     {
         m_NextTriggerTime = TimeUtility.GetServerMilliseconds() + TriggerInterval;
         OnTrigger();
     }
     m_Status = SearchLightStatus.kFollow;
 }
Пример #15
0
        protected override void OnTick()
        {
            try
            {
                long curTime = TimeUtility.GetServerMilliseconds();
                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_);
                    });
                }

                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.GetActiveScene();
                            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);
            }
        }
Пример #16
0
        public override void Adjust()
        {
            long curTime = TimeUtility.GetServerMilliseconds();

            if (m_LastAdjustTime + 100 < curTime)
            {
                m_LastAdjustTime = curTime;

                UserInfo myself = WorldSystem.Instance.GetPlayerSelf();
                if (null != myself)
                {
                    float   moveDir = myself.GetMovementStateInfo().GetMoveDir();
                    Vector2 pos     = myself.GetMovementStateInfo().GetPosition2D();
                    if (!myself.GetMovementStateInfo().IsMoving)//玩家已经停止移动,控制停止
                    {
                        m_IsTerminated = true;
                        NetworkSystem.Instance.SyncPlayerMoveStop();

                        LogSystem.Debug("MoveController finish because stop move, adjust MoveDir:{0}", moveDir);
                    }
                    else if (!Geometry.IsSameDouble(WorldSystem.Instance.InputMoveDir, m_InputDir))//玩家输入的移动方向改变,控制停止
                    {
                        m_IsTerminated = true;

                        LogSystem.Debug("MoveController finish because change move dir, adjust MoveDir:{0}", moveDir);
                    }
                    else if (CanGo(myself, pos.X, pos.Y, m_InputDir, c_ForecastDistance * 3, false))//如果输入移动方向可以行走,则恢复移动方向,并停止控制
                    {
                        m_DirOffset = 0;
                        myself.GetMovementStateInfo().SetMoveDir(m_InputDir);
                        DoMove();
                        m_IsTerminated = true;

                        LogSystem.Debug("MoveController finish because restore move dir, adjust MoveDir:{0}", moveDir);
                    }
                }
                else
                {
                    m_IsTerminated = true;

                    LogSystem.Debug("MoveController finish because can't find player");
                }
                if (m_IsTerminated)
                {
                    WorldSystem.Instance.MoveDirAdjustCount = 0;
                }
            }
        }
Пример #17
0
        // 脚本里控制怪物的真实死亡时间。
        private void OnNpcDead(int characterId)
        {
            CharacterInfo info = WorldSystem.Instance.GetCharacterById(characterId);

            if (info.Hp > 0)
            {
                LogSystem.Error("Npc {0} receive dead command while hp > 0", characterId);
            }
            else if (info.DeadTime > 0)
            {
                LogSystem.Error("Npc {0} has received dead command already", characterId);
            }
            else
            {
                info.DeadTime = TimeUtility.GetServerMilliseconds();
            }
        }
Пример #18
0
        private bool IsNpcBornOver(NpcInfo npc)
        {
            if (npc == null)
            {
                return(false);
            }
            long cur_time       = TimeUtility.GetServerMilliseconds();
            long born_anim_time = npc.BornAnimTimeMs;

            if ((npc.BornTime + born_anim_time) > cur_time)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #19
0
        internal void Tick()
        {
            long time  = TimeUtility.GetServerMilliseconds();
            long delta = (time - m_LastTickTime) * 1000;

            m_LastTickTime = time;
            int ct = m_SkillLogicInfos.Count;

            for (int ix = ct - 1; ix >= 0; --ix)
            {
                SkillLogicInfo info = m_SkillLogicInfos[ix];
                CharacterInfo  obj  = CurScene.SceneContext.GetCharacterInfoById(info.SenderId);
                if (null != obj)
                {
                    info.SkillInst.Tick(obj, delta);

                    //DashFire.LogSystem.Debug("Skill {0} tick {1}.", info.SkillId, time);
                }
                if (null == obj || info.SkillInst.IsFinished)
                {
                    //DashFire.LogSystem.Warn("Skill {0} finished (time finish).", info.SkillId);

                    if (info.SkillInst.IsControlMove)
                    {
                        if (null != obj)
                        {
                            obj.GetMovementStateInfo().IsSkillMoving = false;
                        }
                        info.SkillInst.IsControlMove = false;
                    }
                    if (null != obj)
                    {
                        SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(info.SkillId);
                        if (null != skillInfo)
                        {
                            skillInfo.IsSkillActivated = false;
                        }
                    }
                    RecycleSkillInstance(info.Info);
                    m_SkillLogicInfos.RemoveAt(ix);
                }
            }
        }
Пример #20
0
        protected override void OnTick()
        {
            try
            {
                long curTime = TimeUtility.GetServerMilliseconds();
                if (m_LastLogTime + 60000 < curTime)
                {
                    m_LastLogTime = curTime;

                    DebugPoolCount((string msg) =>
                    {
                        LogSys.Log(LOG_TYPE.INFO, "SceneLoadThread.ActionQueue {0}", msg);
                    });
                }
            }
            catch (Exception ex)
            {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Пример #21
0
        private void Follow(long deltaTime)
        {
            long now = TimeUtility.GetServerMilliseconds();

            if (now >= m_NextTriggerTime)
            {
                m_NextTriggerTime = now + TriggerInterval;
                OnTrigger();
            }
            if (Geometry.IsSamePoint(m_CurPos, m_CurFollowObj.GetPosition()))
            {
                return;
            }
            Vector3 new_pos = Move(m_CurPos, m_CurFollowObj.GetPosition(), FollowSpeed, deltaTime);

            if (Geometry.DistanceSquare(new_pos, m_BeginFollowPos) <= m_MaxFollowRange * m_MaxFollowRange)
            {
                m_CurPos = new_pos;
            }
        }
Пример #22
0
        public void Tick(CharacterInfo character, int impactId)
        {
            ImpactInfo impactInfo = character.GetSkillStateInfo().GetImpactInfoById(impactId);

            if (null != impactInfo)
            {
                if (impactInfo.m_IsActivated)
                {
                    float damageDelayTime = float.Parse(impactInfo.ConfigData.ExtraParams[0]);
                    if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + damageDelayTime * 1000 && !impactInfo.m_HasEffectApplyed)
                    {
                        int damage = int.Parse(impactInfo.ConfigData.ExtraParams[1]);
                        if (!character.IsHaveStateFlag(CharacterState_Type.CST_Invincible))
                        {
                            ApplyDamage(impactInfo.m_ImpactSenderId, character, damage);
                        }
                        impactInfo.m_HasEffectApplyed = true;
                        if (impactInfo.ConfigData.ExtraParams.Count >= 3)
                        {
                            int rage = int.Parse(impactInfo.ConfigData.ExtraParams[2]);
                            if (character.IsUser)
                            {
                                character.SetRage(Operate_Type.OT_Relative, rage);
                            }
                            else
                            {
                                CharacterInfo user = character.SceneContext.GetCharacterInfoById(impactInfo.m_ImpactSenderId);
                                if (user != null && user.IsUser)
                                {
                                    user.SetRage(Operate_Type.OT_Relative, rage);
                                }
                            }
                        }
                    }
                    if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + impactInfo.m_ImpactDuration)
                    {
                        impactInfo.m_IsActivated = false;
                    }
                }
            }
        }
Пример #23
0
        public NpcInfo AddNpc(int id, Data_Unit unit)
        {
            NpcInfo npc = NewNpcInfo(id);

            npc.SceneContext = m_SceneContext;
            npc.LoadData(unit);
            npc.IsBorning = true;
            npc.SetAIEnable(false);
            npc.SetStateFlag(Operate_Type.OT_AddBit, CharacterState_Type.CST_Invincible);
            npc.BornTime = TimeUtility.GetServerMilliseconds();
            m_Npcs.Add(npc.GetId(), npc);
            if (null != m_SceneContext && null != m_SceneContext.SpatialSystem)
            {
                m_SceneContext.SpatialSystem.AddObj(npc.SpaceObject);
            }
            if (null != m_SceneContext && null != m_SceneContext.SightManager)
            {
                m_SceneContext.SightManager.AddObject(npc);
            }
            return(npc);
        }
Пример #24
0
        public override void Adjust()
        {
            CharacterInfo info = WorldSystem.Instance.GetCharacterById(m_ObjId);

            if (null != info)
            {
                if (!info.GetMovementStateInfo().IsMoving)
                {
                    m_IsTerminated = true;
                }
                else
                {
                    float curTime = TimeUtility.GetServerMilliseconds();
                    float delta   = curTime - m_LastTime;
                    m_LastTime      = curTime;
                    m_CurTotalTime += delta;
                    if (m_CurTotalTime > m_TotalTime)
                    {
                        delta -= m_CurTotalTime - m_TotalTime;
                    }

                    float dx = (float)(m_Dx * delta / m_TotalTime);
                    float dy = (float)(m_Dy * delta / m_TotalTime);
                    float dz = (float)(m_Dz * delta / m_TotalTime);

                    Vector2 pos = info.GetMovementStateInfo().GetPosition2D() + new Vector2(dx, dz);
                    info.GetMovementStateInfo().SetPosition2D(pos);

                    if (m_CurTotalTime >= m_TotalTime)
                    {
                        m_IsTerminated = true;
                    }
                }
            }
            else
            {
                m_IsTerminated = true;
            }
        }
Пример #25
0
        private void UpdateStatus(DashFireSpatial.ISpatialSystem spatial_system)
        {
            List <ISpaceObject> in_objs = spatial_system.GetObjectInCircle(m_CurPos, SearchRadius);

            switch (m_Status)
            {
            case SearchLightStatus.kPatrol:
            case SearchLightStatus.kReturn:
                ISpaceObject target = GetFirstUser(in_objs);
                if (target != null)
                {
                    BeginFollow(target);
                }
                break;

            case SearchLightStatus.kFollow:
                if (!IsContainObj(in_objs, m_CurFollowObj))
                {
                    ISpaceObject new_target = GetFirstUser(in_objs);
                    if (new_target != null)
                    {
                        BeginFollow(new_target);
                    }
                    else
                    {
                        BeginExFollow();
                    }
                }
                break;

            case SearchLightStatus.kExFollow:
                if (TimeUtility.GetServerMilliseconds() > m_ExFollowTime + ExFollowTimeMs)
                {
                    BeginReturn();
                }
                break;
            }
        }
Пример #26
0
        public void Tick(CharacterInfo character, int impactId)
        {
            ImpactInfo impactInfo = character.GetSkillStateInfo().GetImpactInfoById(impactId);

            if (null == impactInfo)
            {
                return;
            }
            if (!impactInfo.m_IsActivated)
            {
                return;
            }
            if (!impactInfo.m_HasEffectApplyed)
            {
                character.SetStateFlag(Operate_Type.OT_AddBit, CharacterState_Type.CST_Invincible);
                impactInfo.m_HasEffectApplyed = true;
            }
            if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + impactInfo.m_ImpactDuration)
            {
                character.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible);
                impactInfo.m_IsActivated = false;
            }
        }
Пример #27
0
        public override void Adjust()
        {
            CharacterInfo info = WorldSystem.Instance.GetCharacterById(m_ObjId);

            if (null != info)
            {
                float curTime = TimeUtility.GetServerMilliseconds();
                float delta   = curTime - m_LastTime;
                m_LastTime      = curTime;
                m_CurTotalTime += delta;
                float faceDir = info.GetMovementStateInfo().GetFaceDir();
                if (m_CurTotalTime >= m_TotalTime || Math.Abs(faceDir - m_FaceDir) <= 0.1f)
                {
                    info.GetMovementStateInfo().SetFaceDir(m_FaceDir);
                    m_IsTerminated = true;
                }
                else
                {
                    float offset = c_PI - (m_FaceDir + c_2PI - faceDir) % c_2PI;
                    if (offset * m_DeltaDir <= 0)
                    {
                        info.GetMovementStateInfo().SetFaceDir(m_FaceDir);
                        m_IsTerminated = true;
                    }
                    else
                    {
                        float newFaceDir = (faceDir + c_2PI + delta * m_DeltaDir / m_TotalTime) % c_2PI;
                        info.GetMovementStateInfo().SetFaceDir(newFaceDir);
                        //LogSystem.Debug("FaceController {0}, obj:{1}, faceDir:{2}->{3}, delta:{4} totalTime:{5} deltaDir:{6} targetDir:{7}", m_Id, m_ObjId, faceDir, newFaceDir, delta, m_TotalTime, m_DeltaDir, m_FaceDir);
                    }
                }
            }
            else
            {
                m_IsTerminated = true;
            }
        }
Пример #28
0
        protected virtual void UpdateIdle()
        {
            if (!GetOwner().IsDead() && m_CharacterAnimationInfo.IsIdle())
            {
                if (m_IdleState == IdleState.kNotIdle)
                {
                    //PlayAnimation(Animation_Type.AT_Hold);
                    string name = GetAnimationNameByType(Animation_Type.AT_Hold);
                    if (!string.IsNullOrEmpty(name))
                    {
                        GfxSystem.CrossFadeAnimation(m_Actor, name, 0.5f);
                    }

                    m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                    m_IdleState     = IdleState.kReady;
                    m_IdleInterval  = new Random().Next(1, 3) * 1000;
                }
                else if (m_IdleState == IdleState.kReady)
                {
                    if (TimeUtility.GetServerMilliseconds() - m_BeginIdleTime > m_IdleInterval)
                    {
                        string name = GetAnimationNameByType(Animation_Type.AT_Stand);
                        if (!string.IsNullOrEmpty(name))
                        {
                            GfxSystem.CrossFadeAnimation(m_Actor, name, 0.5f);
                        }
                        //PlayAnimation(Animation_Type.AT_Stand);
                        m_BeginIdleTime = TimeUtility.GetServerMilliseconds();
                    }
                }
            }
            else
            {
                m_IdleState = IdleState.kNotIdle;
            }
        }
Пример #29
0
        private void CreateNpc()
        {
            if (!m_IsTriggered)
            {
                return;
            }
            if (m_NextNpcIndex >= NpcList.Count)
            {
                m_IsTriggered = false;
                return;
            }
            long now = TimeUtility.GetServerMilliseconds();

            if (now >= m_NextNpcCreateTime)
            {
                int npc_unit_id = NpcList[m_NextNpcIndex];
                m_NextNpcIndex++;
                m_NextNpcCreateTime = now + CreateNpcInterval;
                if (OnCreateNpc != null)
                {
                    OnCreateNpc(LogicInfo, this, npc_unit_id);
                }
            }
        }
Пример #30
0
        private void OnNpcSkill(NpcInfo 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.GetServerMilliseconds();
                        if (!curSkillInfo.IsInCd(curTime / 1000.0f))
                        {
                            curSkillInfo.StartTime = curTime / 1000.0f;
                            curSkillInfo.BeginCD();
                            scene.SkillSystem.StartSkill(npc.GetId(), skillId);

                            Msg_RC_NpcSkill skillBuilder = new Msg_RC_NpcSkill();
                            skillBuilder.npc_id   = npc.GetId();
                            skillBuilder.skill_id = skillId;
                            ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position();
                            posBuilder1.x               = npc.GetMovementStateInfo().GetPosition3D().X;
                            posBuilder1.z               = npc.GetMovementStateInfo().GetPosition3D().Z;
                            skillBuilder.stand_pos      = posBuilder1;
                            skillBuilder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();

                            LogSystem.Debug("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                            npc.GetId(), skillId);
                            scene.NotifyAreaUser(npc, skillBuilder);
                        }
                    }
                }
            }
        }