예제 #1
0
        private void OnUserSkill(UserInfo user, int skillId)
        {
            Scene scene = user.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo();
                if (null == skillInfo || !skillInfo.IsSkillActivated)
                {
                    scene.SkillSystem.StartSkill(user.GetId(), skillId);

                    Msg_CRC_Skill skillBuilder = new Msg_CRC_Skill();
                    skillBuilder.role_id  = user.GetId();
                    skillBuilder.skill_id = skillId;
                    ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position();
                    posBuilder1.x               = user.GetMovementStateInfo().GetPosition3D().X;
                    posBuilder1.z               = user.GetMovementStateInfo().GetPosition3D().Z;
                    skillBuilder.stand_pos      = posBuilder1;
                    skillBuilder.face_direction = (float)user.GetMovementStateInfo().GetFaceDir();
                    skillBuilder.want_face_dir  = (float)user.GetMovementStateInfo().GetFaceDir();

                    LogSystem.Debug("Send Msg_CRC_Skill, EntityId={0}, SkillId={1}",
                                    user.GetId(), skillId);
                    scene.NotifyAreaUser(user, skillBuilder, false);
                }
            }
        }
예제 #2
0
        internal static Msg_RC_UserMove BuildUserMoveMessage(UserInfo user)
        {
            Msg_RC_UserMove userMoveBuilder = new Msg_RC_UserMove();

            if (user.GetMovementStateInfo().IsMoving)
            {
                userMoveBuilder.role_id        = user.GetId();
                userMoveBuilder.is_moving      = true;
                userMoveBuilder.move_direction = (float)user.GetMovementStateInfo().GetMoveDir();
                userMoveBuilder.face_direction = (float)user.GetMovementStateInfo().GetFaceDir();
                userMoveBuilder.cur_pos_x      = user.GetMovementStateInfo().GetPosition3D().X;
                userMoveBuilder.cur_pos_z      = user.GetMovementStateInfo().GetPosition3D().Z;
                UserAiStateInfo data = user.GetAiStateInfo();
                userMoveBuilder.target_pos_x         = user.GetMovementStateInfo().TargetPosition.X;
                userMoveBuilder.target_pos_z         = user.GetMovementStateInfo().TargetPosition.Z;
                userMoveBuilder.velocity_coefficient = (float)user.VelocityCoefficient;
            }
            else
            {
                userMoveBuilder.role_id   = user.GetId();
                userMoveBuilder.is_moving = false;
                userMoveBuilder.cur_pos_x = user.GetMovementStateInfo().GetPosition3D().X;
                userMoveBuilder.cur_pos_z = user.GetMovementStateInfo().GetPosition3D().Z;
            }
            return(userMoveBuilder);
        }
예제 #3
0
        public void DestroyHero()
        {
            UserInfo user = GetPlayerSelf();

            if (null != user)
            {
                EntityManager.Instance.DestroyUserView(user.GetId());
                DestroyCharacterById(user.GetId());
            }
        }
예제 #4
0
        internal static void Execute(object msg, User user)
        {
            Msg_CR_PickUpNpc pickUpNpcMsg = msg as Msg_CR_PickUpNpc;

            if (null != pickUpNpcMsg)
            {
                UserInfo userInfo = user.Info;
                if (null != userInfo)
                {
                    Scene scene = user.OwnRoom.GetActiveScene();
                    if (null != scene)
                    {
                        NpcInfo npc = scene.SceneContext.GetCharacterInfoById(pickUpNpcMsg.npc_id) as NpcInfo;
                        if (null != npc && npc.OwnerId == userInfo.GetId())
                        {
                            npc.NeedDelete = true;
                            DropOutInfo info = npc.GetAiStateInfo().AiDatas.GetData <DropOutInfo>();
                            if (null != info)
                            {
                                userInfo.Money += info.Value;
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        public UserInfo AddUser(int id, int resId)
        {
            UserInfo user = NewUserInfo(id);

            user.LoadData(resId);
            m_Users.Add(user.GetId(), user);
            return(user);
        }
예제 #6
0
        internal static Msg_RC_UserFace BuildUserFaceMessage(UserInfo user)
        {
            Msg_RC_UserFace builder = new Msg_RC_UserFace();

            builder.face_direction = (float)user.GetMovementStateInfo().GetFaceDir();
            builder.role_id        = user.GetId();
            return(builder);
        }
예제 #7
0
        public void StartGame()
        {
            UserInfo user = GetPlayerSelf();

            if (null != user)
            {
                EntityManager.Instance.DestroyUserView(user.GetId());
                DestroyCharacterById(user.GetId());
            }
            user = CreatePlayerSelf(1, NetworkSystem.Instance.HeroId);
            user.SetCampId(NetworkSystem.Instance.CampId);
            Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit;

            if (null != unit)
            {
                user.GetMovementStateInfo().SetPosition(unit.m_Pos);
                user.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                user.SetHp(Operate_Type.OT_Absolute, user.GetActualProperty().HpMax);
            }
            EntityManager.Instance.CreatePlayerSelfView(1);
            UserView view = EntityManager.Instance.GetUserViewById(1);

            if (null != view)
            {
                view.Visible = true;
            }

            foreach (Data_Unit npcUnit in m_CurScene.StaticData.m_UnitMgr.GetData().Values)
            {
                if (npcUnit.m_IsEnable)
                {
                    NpcInfo npc = m_NpcMgr.GetNpcInfoByUnitId(npcUnit.GetId());
                    if (null == npc)
                    {
                        npc = m_NpcMgr.AddNpc(npcUnit);
                    }
                    if (null != npc)
                    {
                        EntityManager.Instance.CreateNpcView(npc.GetId());
                    }
                }
            }
            GfxSystem.PublishGfxEvent("ge_on_game_start", "story");
            LogSystem.Debug("start game");
        }
예제 #8
0
        private void OnUserStopSkill(UserInfo user)
        {
            Scene scene = user.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                SkillInfo skillInfo = user.GetSkillStateInfo().GetCurSkillInfo();
                if (null == skillInfo || skillInfo.IsSkillActivated)
                {
                    scene.SkillSystem.StopSkill(user.GetId());
                }

                Msg_CRC_StopSkill skillBuilder = new Msg_CRC_StopSkill();
                skillBuilder.role_id = user.GetId();

                LogSystem.Debug("Send Msg_CRC_StopSkill, EntityId={0}",
                                user.GetId());
                scene.NotifyAreaUser(user, skillBuilder, false);
            }
        }
예제 #9
0
        public void ChangeHero()
        {
            UserInfo user = GetPlayerSelf();

            if (null != user)
            {
                Vector3 pos  = user.GetMovementStateInfo().GetPosition3D();
                float   dir  = user.GetMovementStateInfo().GetFaceDir();
                int     hp   = user.Hp;
                int     rage = user.Rage;

                EntityManager.Instance.DestroyUserView(user.GetId());
                DestroyCharacterById(user.GetId());

                NetworkSystem.Instance.HeroId = (NetworkSystem.Instance.HeroId + 1) % 4;
                if (NetworkSystem.Instance.HeroId == 0)
                {
                    NetworkSystem.Instance.HeroId = 1;
                }

                user = CreatePlayerSelf(1, NetworkSystem.Instance.HeroId);
                user.SetCampId(NetworkSystem.Instance.CampId);

                /*Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit;
                 * if (null != unit) {
                 * user.GetMovementStateInfo().SetPosition(unit.m_Pos);
                 * user.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                 * user.SetHp(Operate_Type.OT_Absolute, 1000);
                 * }*/
                user.GetMovementStateInfo().SetPosition(pos);
                user.GetMovementStateInfo().SetFaceDir(dir);
                user.SetHp(Operate_Type.OT_Absolute, hp);
                user.SetRage(Operate_Type.OT_Absolute, rage);
                EntityManager.Instance.CreatePlayerSelfView(1);
                UserView view = EntityManager.Instance.GetUserViewById(1);
                if (null != view)
                {
                    view.Visible = true;
                }
            }
        }
예제 #10
0
        private void ReleaseControl(UserInfo user)
        {
            if (null != user.ControlledObject)
            {
                int controller = user.GetId();
                int controlled = user.ControlledObject.GetId();
                CharacterInfo.ReleaseControlObject(user, user.ControlledObject);

                Msg_RC_ControlObject builder = DataSyncUtility.BuildControlObjectMessage(controller, controlled, false);
                NotifyAllUser(builder);
            }
        }
예제 #11
0
        internal static Msg_RC_SyncCombatStatisticInfo BuildSyncCombatStatisticInfo(UserInfo user)
        {
            Msg_RC_SyncCombatStatisticInfo builder = new Msg_RC_SyncCombatStatisticInfo();
            CombatStatisticInfo            info    = user.GetCombatStatisticInfo();

            builder.role_id          = user.GetId();
            builder.kill_hero_count  = info.KillHeroCount;
            builder.assit_kill_count = info.AssitKillCount;
            builder.kill_npc_count   = info.KillNpcCount;
            builder.dead_count       = info.DeadCount;
            return(builder);
        }
예제 #12
0
        private void RefreshItemSkills(UserInfo user)
        {
            user.RefreshItemSkills((int id) =>
            {
                return(user.GetSkillStateInfo().GetImpactInfoById(id));
            }, (int id) =>
            {
            });
            Msg_RC_RefreshItemSkills builder = new Msg_RC_RefreshItemSkills();

            builder.role_id = user.GetId();
            NotifyAllUser(builder);
        }
예제 #13
0
        private void UserLeaveCampSight(UserInfo leave_user_info, int campid)
        {
            User leave_user = leave_user_info.CustomData as User;

            IList <UserInfo> camp_users = m_SightManager.GetCampUsers(campid);

            foreach (UserInfo user_impl in camp_users)
            {
                if (user_impl == null)
                {
                    continue;
                }
                User user = user_impl.CustomData as User;
                if (leave_user_info.GetId() != user_impl.GetId())
                {
                    user.RemoveICareUser(leave_user);
                    Msg_RC_Disappear bder = new Msg_RC_Disappear();
                    bder.role_id = leave_user_info.GetId();
                    user.SendMessage(bder);
                }
            }
        }
예제 #14
0
        internal static Msg_RC_Revive BuildReviveMessage(UserInfo user)
        {
            Msg_RC_Revive builder = new Msg_RC_Revive();

            builder.camp_id        = user.GetCampId();
            builder.face_direction = user.GetMovementStateInfo().GetFaceDir();
            builder.hero_id        = user.GetLinkId();
            builder.is_player_self = true;
            builder.position       = new ArkCrossEngineMessage.Position();
            builder.position.x     = user.GetMovementStateInfo().GetPosition3D().X;
            builder.position.z     = user.GetMovementStateInfo().GetPosition3D().Z;
            builder.role_id        = user.GetId();
            return(builder);
        }
예제 #15
0
 private void TickDebugSpaceInfo()
 {
     if (GlobalVariables.Instance.IsDebug)
     {
         bool needDebug = false;
         foreach (User user in m_Room.RoomUsers)
         {
             if (user.IsDebug)
             {
                 needDebug = true;
                 break;
             }
         }
         if (needDebug)
         {
             Msg_RC_DebugSpaceInfo builder = new Msg_RC_DebugSpaceInfo();
             for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 UserInfo info = linkNode.Value;
                 Msg_RC_DebugSpaceInfo.DebugSpaceInfo infoBuilder = new Msg_RC_DebugSpaceInfo.DebugSpaceInfo();
                 infoBuilder.obj_id    = info.GetId();
                 infoBuilder.is_player = true;
                 infoBuilder.pos_x     = (float)info.GetMovementStateInfo().GetPosition3D().X;
                 infoBuilder.pos_z     = (float)info.GetMovementStateInfo().GetPosition3D().Z;
                 infoBuilder.face_dir  = (float)info.GetMovementStateInfo().GetFaceDir();
                 builder.space_infos.Add(infoBuilder);
             }
             for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
             {
                 NpcInfo info = linkNode.Value;
                 Msg_RC_DebugSpaceInfo.DebugSpaceInfo infoBuilder = new Msg_RC_DebugSpaceInfo.DebugSpaceInfo();
                 infoBuilder.obj_id    = info.GetId();
                 infoBuilder.is_player = false;
                 infoBuilder.pos_x     = (float)info.GetMovementStateInfo().GetPosition3D().X;
                 infoBuilder.pos_z     = (float)info.GetMovementStateInfo().GetPosition3D().Z;
                 infoBuilder.face_dir  = (float)info.GetMovementStateInfo().GetFaceDir();
                 builder.space_infos.Add(infoBuilder);
             }
             foreach (User user in m_Room.RoomUsers)
             {
                 if (user.IsDebug)
                 {
                     user.SendMessage(builder);
                 }
             }
         }
     }
 }
예제 #16
0
        private void DropNpc(Vector3 pos, int money, string model, string particle)
        {
            //给每个玩家掉落一个
            Data_Unit unit = new Data_Unit();

            unit.m_Id       = -1;
            unit.m_LinkId   = 100001;
            unit.m_AiLogic  = (int)AiStateLogicId.DropOut_AutoPick;
            unit.m_RotAngle = 0;
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo userInfo = linkNode.Value;
                if (null != userInfo)
                {
                    float x = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    float z = CrossEngineHelper.Random.NextFloat() * 4 - 2;
                    pos.X += x;
                    pos.Z += z;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetPosition(pos);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId((int)CampIdEnum.Friendly);
                    npcInfo.OwnerId   = userInfo.GetId();
                    npcInfo.DropMoney = money;

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = DropOutType.GOLD;
                    dropInfo.Value    = money;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;
                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = userInfo.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npcInfo);
                        us.SendMessage(builder);
                    }
                }
            }
        }
예제 #17
0
 public void Create(UserInfo user)
 {
     Init();
     if (null != user)
     {
         m_User = user;
         m_User.OnBeginAttack = ResetShootAnimation;
         MovementStateInfo msi = m_User.GetMovementStateInfo();
         Vector3           pos = msi.GetPosition3D();
         float             dir = msi.GetFaceDir();
         CreateActor(m_User.GetId(), m_User.GetModel(), pos, dir, m_User.Scale);
         InitAnimationSets();
         UpdateWeaponModel(m_User);
         if (user.GetId() == WorldSystem.Instance.PlayerSelfId)
         {
             GfxSystem.MarkPlayerSelf(Actor);
         }
     }
 }
예제 #18
0
        private void UserEnterCampSight(UserInfo enter_user_info, int campid)
        {
            User enter_user = enter_user_info.CustomData as User;

            if (enter_user == null)
            {
                return;
            }
            IList <UserInfo> camp_users = m_SightManager.GetCampUsers(campid);

            foreach (UserInfo user_info in camp_users)
            {
                User user = user_info.CustomData as User;
                if (user == null)
                {
                    continue;
                }
                if (enter_user_info.GetId() != user_info.GetId())
                {
                    user.AddICareUser(enter_user);
                    //send message
                    Vector3 enter_user_pos = enter_user_info.GetMovementStateInfo().GetPosition3D();
                    ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position();
                    pos_bd0.x = enter_user_pos.X;
                    pos_bd0.z = enter_user_pos.Z;
                    Msg_RC_Enter bder = new Msg_RC_Enter();
                    bder.role_id   = enter_user.RoleId;
                    bder.hero_id   = enter_user.HeroId;
                    bder.camp_id   = enter_user.CampId;
                    bder.position  = pos_bd0;
                    bder.face_dir  = (float)enter_user_info.GetMovementStateInfo().GetFaceDir();
                    bder.is_moving = enter_user_info.GetMovementStateInfo().IsMoving;
                    bder.move_dir  = (float)enter_user_info.GetMovementStateInfo().GetMoveDir();
                    user.SendMessage(bder);

                    Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(enter_user_info);
                    user.SendMessage(propBuilder);
                    DataSyncUtility.SyncBuffListToUser(enter_user_info, user);
                }
            }
        }
예제 #19
0
 internal void SyncForNewUser(User user)
 {
     if (null != user)
     {
         UserInfo userInfo = user.Info;
         Room     room     = GetRoom();
         if (null != userInfo && null != room && null != room.GetActiveScene())
         {
             //同步玩家数据给自己
             SyncUserToSelf(user);
             //同步玩家数据给其他玩家
             SyncUserToOthers(user);
             //同步其他玩家数据给自己
             SyncOthersToUser(user);
             //同步场景数据给自己
             SyncSceneObjectsToUser(user);
             //同步玩家数据给观察者
             SyncUserToObservers(user);
             //剧情脚本处理
             m_StorySystem.SendMessage("userenterscene", userInfo.GetId());
         }
     }
 }
예제 #20
0
        private void FindPath(UserInfo playerself, Vector3 targetpos, float towards)
        {
            CharacterView view = EntityManager.Instance.GetUserViewById(playerself.GetId());

            if (view != null && view.ObjectInfo.IsGfxMoveControl && Vector3.Zero != targetpos)
            {
                return;
            }
            playerself.GetMovementStateInfo().SetFaceDir(towards);
            PlayerMovement.Motion m = Vector3.Zero == targetpos ? PlayerMovement.Motion.Stop : PlayerMovement.Motion.Moving;
            pm_.MotionChanged = pm_.MotionStatus != m || m_lastDir != towards;
            m_lastDir         = towards;
            pm_.MotionStatus  = m;
            pm_.MoveDir       = towards;
            if (Vector3.Zero == targetpos)
            {
                pm_.MotionStatus = PlayerMovement.Motion.Stop;
            }

            /*
             * UserAiStateInfo aiInfo = playerself.GetAiStateInfo();
             * if(null == aiInfo)
             * return;
             * if (Vector3.Zero == targetpos) {
             * StopFindPath(playerself, aiInfo);
             * return;
             * }
             * bool ret = (m_lastDir > towards) ? ((m_lastDir - towards) > Math.PI / 4.0f) : ((towards - m_lastDir) > Math.PI / 4.0f);
             * if (ret) {
             * StopFindPath(playerself, aiInfo);
             * m_lastDir = towards;
             * }
             * aiInfo.TargetPos = targetpos;
             * aiInfo.ChangeToState((int)AiStateId.Move);
             */
        }
예제 #21
0
        internal static void Execute(object msg, User user)
        {
            Msg_CRC_Create enter_msg = msg as Msg_CRC_Create;

            if (enter_msg == null)
            {
                return;
            }
            LogSys.Log(LOG_TYPE.DEBUG, "user {0}({1}) enter.", user.RoleId, user.GetKey());
            user.UserControlState = (int)UserControlState.User;
            user.IsEntered        = true;

            Room room = user.OwnRoom;

            if (null != room)
            {
                Scene scene = room.GetActiveScene();
                if (null != scene)
                {
                    UserInfo userInfo = user.Info;
                    if (null != userInfo)
                    {
                        userInfo.GetXSoulInfo().GetAllXSoulPartData().Clear();
                        foreach (var pair in user.XSouls.GetAllXSoulPartData())
                        {
                            userInfo.GetXSoulInfo().SetXSoulPartData(pair.Key, pair.Value);
                        }
                        foreach (var pair in userInfo.GetXSoulInfo().GetAllXSoulPartData())
                        {
                            XSoulPartInfo part_info = pair.Value;
                            foreach (int impactid in part_info.GetActiveImpacts())
                            {
                                //LogSys.Log(LOG_TYPE.DEBUG, "---add xsoul impact to self: " + impactid);
                                ImpactSystem.Instance.SendImpactToCharacter(userInfo, impactid, userInfo.GetId(),
                                                                            -1, -1, userInfo.GetMovementStateInfo().GetPosition3D(),
                                                                            userInfo.GetMovementStateInfo().GetFaceDir());
                            }
                        }
                        if (scene.SceneState == SceneState.Running)
                        {
                            Data_Unit unit = scene.MapData.ExtractData(DataMap_Type.DT_Unit, userInfo.GetUnitId()) as Data_Unit;
                            if (null != unit)
                            {
                                userInfo.GetMovementStateInfo().SetPosition(unit.m_Pos);
                                userInfo.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                                userInfo.RevivePoint = unit.m_Pos;
                            }
                            scene.SyncForNewUser(user);
                        }
                    }
                }
            }
        }
예제 #22
0
 private void OnSkillPursuit(UserInfo user)
 {
     GfxSystem.PublishGfxEvent("Ai_InputSkillPursuitCmd", "Input", user.GetId());
 }
예제 #23
0
 private void UserAttack(UserInfo user, float x, float y, float z)
 {
     GfxSystem.PublishGfxEvent("Ai_InputAttackCmd", "Input", user.GetId(), x, y, z);
 }
예제 #24
0
        public bool ChangeNextScene(int sceneId)
        {
            GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            /*==========================
             * 登录场景Loading的ID为6
             * 游戏结束时跳回该场景
             */
            if (sceneId == 6)
            {
                UserInfo user = GetPlayerSelf();
                if (null != user)
                {
                    EntityManager.Instance.DestroyUserView(user.GetId());
                    DestroyCharacterById(user.GetId());
                }
                if (null != m_CurScene)
                {
                    /*
                     * if (m_CurScene.ResId == sceneId) {
                     * return true;
                     * }
                     */
                    m_CurScene.Release();
                    m_CurScene = null;
                }
                Data_SceneConfig sceneConfig = SceneConfigProvider.Instance.GetSceneConfigById(sceneId);
                GfxSystem.LoadScene(sceneConfig.m_ClientSceneFile, OnLoadFinish);
                return(true);
            }
            //==============================

            //GfxSystem.PublishGfxEvent("ge_load_ui_in_game", "ui", sceneId);

            if (null != m_CurScene)
            {
                /*
                 * if (m_CurScene.ResId == sceneId) {
                 * return true;
                 * }
                 */
                m_CurScene.Release();
                m_CurScene = null;
            }
            m_CurScene = new SceneResource();
            if (null != m_CurScene)
            {
                m_CurScene.Init(sceneId);
                if (null != m_CurScene.SceneConfig)
                {
                    Data_SceneConfig scene_config = SceneConfigProvider.Instance.GetSceneConfigById(m_CurScene.ResId);
                    m_SpatialSystem.Init(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile, scene_config.m_ReachableSet);
                    m_SpatialSystem.LoadPatch(FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile + ".patch");
                    m_SpatialSystem.LoadObstacle(FilePathDefine_Client.C_RootPath + scene_config.m_ObstacleFile, 1 / scene_config.m_TiledDataScale);

                    LogSystem.Debug("init SpatialSystem:{0}", FilePathDefine_Client.C_RootPath + scene_config.m_BlockInfoFile);
                    LogSystem.Debug("GameSystem.ChangeNextScene:{0}", m_CurScene.ResId);
                    if (sceneId == 6)
                    {
                        UserInfo user = GetPlayerSelf();
                        if (null != user)
                        {
                            EntityManager.Instance.DestroyUserView(user.GetId());
                            DestroyCharacterById(user.GetId());
                        }
                    }
                    return(true);
                }
            }


            return(false);
        }
예제 #25
0
        /**
         * @brief 逻辑循环
         */
        public void Tick()
        {
            TimeSnapshot.Start();
            TimeSnapshot.DoCheckPoint();
            if (m_CurScene == null || !m_CurScene.IsSuccessEnter)
            {
                return;
            }
            m_Profiler.sceneTickTime = TimeSnapshot.DoCheckPoint();

            EntityManager.Instance.Tick();
            m_Profiler.entityMgrTickTime = TimeSnapshot.DoCheckPoint();

            ControlSystem.Instance.Tick();
            m_Profiler.controlSystemTickTime = TimeSnapshot.DoCheckPoint();

            m_Profiler.movementSystemTickTime = TimeSnapshot.DoCheckPoint();

            m_SpatialSystem.Tick();
            m_Profiler.spatialSystemTickTime = TimeSnapshot.DoCheckPoint();
            if (m_Profiler.spatialSystemTickTime > 50000)
            {
                LogSystem.Warn("*** SpatialSystem tick time is {0}", m_Profiler.spatialSystemTickTime);
                for (LinkedListNode <UserInfo> node = UserManager.Users.FirstValue; null != node; node = node.Next)
                {
                    UserInfo userInfo = node.Value;
                    if (null != userInfo)
                    {
                        LogSystem.Warn("===>User:{0} Pos:{1}", userInfo.GetId(), userInfo.GetMovementStateInfo().GetPosition3D().ToString());
                    }
                }
                for (LinkedListNode <NpcInfo> node = NpcManager.Npcs.FirstValue; null != node; node = node.Next)
                {
                    NpcInfo npcInfo = node.Value;
                    if (null != npcInfo)
                    {
                        LogSystem.Warn("===>Npc:{0} Pos:{1}", npcInfo.GetId(), npcInfo.GetMovementStateInfo().GetPosition3D().ToString());
                    }
                }
            }

            m_AiSystem.Tick();
            m_Profiler.aiSystemTickTime = TimeSnapshot.DoCheckPoint();

            //obj特殊逻辑处理
            TickUsers();
            m_Profiler.usersTickTime = TimeSnapshot.DoCheckPoint();

            TickNpcs();
            m_Profiler.npcsTickTime = TimeSnapshot.DoCheckPoint();

            try {
                TickSystemByCharacters();
            } catch (Exception e) {
                GfxSystem.GfxLog("Exception:{0}\n{1}", e.Message, e.StackTrace);
            }
            m_Profiler.combatSystemTickTime = TimeSnapshot.DoCheckPoint();

            if (IsPveScene())
            {
                TickPve();
            }

            long tickTime = TimeSnapshot.End();

            if (tickTime > 100000)
            {
                LogSystem.Debug("*** PerformanceWarning: {0}", m_Profiler.GenerateLogString(tickTime));
            }
        }
예제 #26
0
        internal void DropNpc(int ownerId, int fromNpcId, DropOutType dropType, string model, string particle, int num)
        {
            if (ownerId > 0)
            {
                UserInfo user = UserManager.GetUserInfo(ownerId);
                if (null == user)
                {
                    NpcInfo npc = NpcManager.GetNpcInfo(ownerId);
                    while (null != npc)
                    {
                        user = UserManager.GetUserInfo(npc.OwnerId);
                        if (null != user)
                        {
                            break;
                        }
                        else
                        {
                            npc = NpcManager.GetNpcInfo(npc.OwnerId);
                        }
                    }
                }
                if (null != user)
                {
                    Data_Unit unit = new Data_Unit();
                    unit.m_Id = -1;
                    switch (dropType)
                    {
                    case DropOutType.GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.GOLD;
                        break;

                    case DropOutType.HP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.HP;
                        break;

                    case DropOutType.MP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MP;
                        break;

                    case DropOutType.MULT_GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD;
                        break;
                    }
                    unit.m_RotAngle = 0;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId(user.GetCampId());
                    npcInfo.OwnerId = user.GetId();

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = dropType;
                    dropInfo.Value    = num;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;

                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = user.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model);
                        us.SendMessage(builder);
                    }
                }
            }
            else
            {
                int      ct   = UserManager.Users.Count;
                int      rd   = CrossEngineHelper.Random.Next(0, ct);
                UserInfo user = null;
                if (UserManager.Users.TryGetValue(rd, out user))
                {
                    Data_Unit unit = new Data_Unit();
                    unit.m_Id = -1;
                    switch (dropType)
                    {
                    case DropOutType.GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.GOLD;
                        break;

                    case DropOutType.HP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.HP;
                        break;

                    case DropOutType.MP:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MP;
                        break;

                    case DropOutType.MULT_GOLD:
                        unit.m_LinkId = (int)DropNpcTypeEnum.MUTI_GOLD;
                        break;
                    }
                    unit.m_RotAngle = 0;

                    NpcInfo npcInfo = NpcManager.AddNpc(unit);
                    npcInfo.GetMovementStateInfo().SetFaceDir(0);
                    npcInfo.GetMovementStateInfo().IsMoving = false;
                    npcInfo.SetAIEnable(true);
                    npcInfo.SetCampId(user.GetCampId());
                    npcInfo.OwnerId = user.GetId();

                    DropOutInfo dropInfo = new DropOutInfo();
                    dropInfo.DropType = dropType;
                    dropInfo.Value    = num;
                    dropInfo.Model    = model;
                    dropInfo.Particle = particle;

                    npcInfo.GetAiStateInfo().AiDatas.AddData <DropOutInfo>(dropInfo);
                    npcInfo.SetModel(dropInfo.Model);

                    User us = user.CustomData as User;
                    if (null != us)
                    {
                        Msg_RC_DropNpc builder = DataSyncUtility.BuildDropNpcMessage(npcInfo, fromNpcId, (int)dropType, num, model);
                        us.SendMessage(builder);
                    }
                }
            }
        }
예제 #27
0
 private void UserSkill(UserInfo user)
 {
     GfxSystem.PublishGfxEvent("Ai_InputSkillCmd", "Input", user.GetId());
 }
예제 #28
0
 public void Execute(UserInfo user, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
 {
     if (user.GetAIEnable())
     {
         UserAiStateInfo userAi = user.GetAiStateInfo();
         if (userAi.CommandQueue.Count <= 0)
         {
             int curState = userAi.CurState;
             if (curState > (int)AiStateId.Invalid && curState < (int)AiStateId.MaxNum)
             {
                 if (m_Handlers.ContainsKey(curState))
                 {
                     UserAiStateHandler handler = m_Handlers[curState];
                     if (null != handler)
                     {
                         handler(user, aiCmdDispatcher, deltaTime);
                     }
                 }
                 else
                 {
                     LogSystem.Error("Illegal ai state: " + curState + " user:" + user.GetId());
                 }
             }
             else
             {
                 OnStateLogicInit(user, aiCmdDispatcher, deltaTime);
                 ChangeToState(user, (int)AiStateId.Idle);
             }
         }
         ExecuteCommandQueue(user, deltaTime);
     }
 }
예제 #29
0
        internal void SummonPartner(Msg_CR_SummonPartner msg)
        {
            UserInfo userInfo = UserManager.GetUserInfo(msg.obj_id);

            if (null != userInfo)
            {
                // summonpartner
                PartnerInfo partnerInfo = userInfo.GetPartnerInfo();
                if (null != partnerInfo && (TimeUtility.GetServerMilliseconds() - userInfo.LastSummonPartnerTime > partnerInfo.CoolDown || userInfo.LastSummonPartnerTime == 0))
                {
                    Data_Unit data = new Data_Unit();
                    data.m_Id         = -1;
                    data.m_LinkId     = partnerInfo.LinkId;
                    data.m_CampId     = userInfo.GetCampId();
                    data.m_Pos        = userInfo.GetMovementStateInfo().GetPosition3D();
                    data.m_RotAngle   = 0;
                    data.m_AiLogic    = partnerInfo.GetAiLogic();
                    data.m_AiParam[0] = "";
                    data.m_AiParam[1] = "";
                    data.m_AiParam[2] = partnerInfo.GetAiParam().ToString();
                    data.m_IsEnable   = true;
                    NpcInfo npc = NpcManager.AddNpc(data);
                    if (null != npc)
                    {
                        AppendAttributeConfig aac       = AppendAttributeConfigProvider.Instance.GetDataById(partnerInfo.GetAppendAttrConfigId());
                        float inheritAttackAttrPercent  = partnerInfo.GetInheritAttackAttrPercent();
                        float inheritDefenceAttrPercent = partnerInfo.GetInheritDefenceAttrPercent();
                        if (null != aac)
                        {
                            // attack
                            npc.GetBaseProperty().SetAttackBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().AttackBase *inheritAttackAttrPercent));
                            npc.GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireDamage *inheritAttackAttrPercent);
                            npc.GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceDamage *inheritAttackAttrPercent);
                            npc.GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonDamage *inheritAttackAttrPercent);
                            // defence
                            npc.GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().HpMax *inheritDefenceAttrPercent));
                            npc.GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().EnergyMax *inheritDefenceAttrPercent));
                            npc.GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().ADefenceBase *inheritDefenceAttrPercent));
                            npc.GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().MDefenceBase *inheritDefenceAttrPercent));
                            npc.GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireERD *inheritDefenceAttrPercent);
                            npc.GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceERD *inheritDefenceAttrPercent);
                            npc.GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonERD *inheritDefenceAttrPercent);
                            // reset hp & energy
                            npc.SetHp(Operate_Type.OT_Absolute, npc.GetBaseProperty().HpMax);
                            npc.SetEnergy(Operate_Type.OT_Absolute, npc.GetBaseProperty().EnergyMax);
                        }
                        npc.SetAIEnable(true);
                        npc.GetSkillStateInfo().RemoveAllSkill();
                        npc.BornTime = TimeUtility.GetServerMilliseconds();
                        List <int> skillList = partnerInfo.GetSkillList();
                        if (null != skillList)
                        {
                            for (int i = 0; i < skillList.Count; ++i)
                            {
                                SkillInfo skillInfo = new SkillInfo(skillList[i]);
                                npc.GetSkillStateInfo().AddSkill(skillInfo);
                            }
                        }
                        userInfo.LastSummonPartnerTime = TimeUtility.GetServerMilliseconds();
                        npc.OwnerId        = userInfo.GetId();
                        userInfo.PartnerId = npc.GetId();
                        if (partnerInfo.BornSkill > 0)
                        {
                            SkillInfo skillInfo = new SkillInfo(partnerInfo.BornSkill);
                            npc.GetSkillStateInfo().AddSkill(skillInfo);
                        }
                        ArkCrossEngineMessage.Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npc);
                        NotifyAllUser(builder);
                    }
                }
            }
        }
예제 #30
0
        private void TickUsers()
        {
            for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
            {
                UserInfo info = linkNode.Value;
                if (info.GetEquipmentStateInfo().EquipmentChanged)
                {
                    RefreshItemSkills(info);
                }
                if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged || info.GetLegacyStateInfo().LegacyChanged)
                {
                    UserAttrCalculator.Calc(info);
                    info.LevelChanged = false;
                    info.GetSkillStateInfo().BuffChanged          = false;
                    info.GetEquipmentStateInfo().EquipmentChanged = false;
                    info.GetLegacyStateInfo().LegacyChanged       = false;
                }
                if (info.Hp <= 0)
                {
                    if (info.DeadTime <= 0)
                    {
                        //计算击杀收益
                        CalcKillIncome(info);
                        info.GetCombatStatisticInfo().AddDeadCount(1);  //死亡计数+1
                                                                        //解除控制
                        ReleaseControl(info);
                        //发送玩家死亡消息
                        Msg_RC_Dead build = new Msg_RC_Dead();
                        build.role_id = info.GetId();
                        NotifyAllUser(build);
                        PlayerLevelupExpConfig cfg = PlayerConfigProvider.Instance.GetPlayerLevelupExpConfigById(info.GetLevel());
                        info.SetStateFlag(Operate_Type.OT_AddBit, CharacterState_Type.CST_BODY);

                        m_StorySystem.SendMessage("userkilled", info.GetId(), GetLivingUserCount());

                        TryFireAllUserKilled();
                        NoticeAttempRoomClosing();

                        info.DeadTime = TimeUtility.GetServerMilliseconds();
                        if (null != cfg && m_IsPvpScene)
                        {
                            info.ReviveTime = TimeUtility.GetServerMilliseconds() + cfg.m_RebornTime * 1000;
                        }
                        else
                        {
                            info.ReviveTime = TimeUtility.GetServerMilliseconds() + info.ReleaseTime + 2000;
                        }
                        NpcInfo npc = NpcManager.GetNpcInfo(info.PartnerId);
                        if (null != npc && npc.NpcType == (int)NpcTypeEnum.Partner)
                        {
                            npc.NeedDelete = true;
                        }
                    }
                    else
                    {
                        /*
                         * long delta = TimeUtility.GetServerMilliseconds() - info.DeadTime;
                         * if (delta > info.ReleaseTime) {
                         * info.DeadTime = info.ReviveTime;
                         * Msg_RC_Disappear build = new Msg_RC_Disappear();
                         * build.role_id = info.GetId();
                         * NotifyAllUser(build);
                         * }
                         */
                    }
                }
            }
        }