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);
                }
            }
        }
        private void OnImpactSkill(CharacterInfo sender, int skillId)
        {
            Scene scene = sender.SceneContext.CustomData as Scene;

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

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

                    LogSystem.Debug("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                    sender.GetId(), skillId);
                    scene.NotifyAreaUser(sender, skillBuilder);
                }
            }
        }
Esempio n. 3
0
        internal static Msg_RC_CreateNpc BuildCreateNpcMessage(NpcInfo npc)
        {
            Msg_RC_CreateNpc bder = new Msg_RC_CreateNpc();

            bder.npc_id  = npc.GetId();
            bder.unit_id = npc.GetUnitId();
            Vector3 pos = npc.GetMovementStateInfo().GetPosition3D();

            ArkCrossEngineMessage.Position pos_bd = new ArkCrossEngineMessage.Position();
            pos_bd.x            = (float)pos.X;
            pos_bd.z            = (float)pos.Z;
            bder.cur_pos        = pos_bd;
            bder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();
            bder.link_id        = npc.GetLinkId();
            if (npc.GetUnitId() <= 0)
            {
                bder.camp_id = npc.GetCampId();
            }
            if (npc.OwnerId > 0)
            {
                bder.owner_id = npc.OwnerId;
            }
            bder.level = npc.GetLevel();
            return(bder);
        }
Esempio n. 4
0
        private void SyncUserToObservers(User infoUser)
        {
            Room room = GetRoom();

            if (null != infoUser && null != room && null != room.GetActiveScene())
            {
                UserInfo userInfo = infoUser.Info;
                if (null != userInfo)
                {
                    Vector3 pos = userInfo.GetMovementStateInfo().GetPosition3D();

                    ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position();
                    pos_bd0.x = pos.X;
                    pos_bd0.z = pos.Z;
                    Msg_CRC_Create bd0 = new Msg_CRC_Create();
                    bd0.role_id        = infoUser.RoleId;
                    bd0.hero_id        = infoUser.HeroId;
                    bd0.camp_id        = infoUser.CampId;
                    bd0.role_level     = infoUser.Level;
                    bd0.is_player_self = false;
                    bd0.position       = pos_bd0;
                    bd0.face_dirction  = (float)userInfo.GetMovementStateInfo().GetFaceDir();
                    for (int index = 0; index < userInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                    {
                        bd0.skill_levels.Add(userInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                    }
                    bd0.scene_start_time = StartTime;
                    bd0.nickname         = infoUser.Name;
                    NotifyAllObserver(bd0);

                    DataSyncUtility.SyncBuffListToObservers(userInfo, this);

                    Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(userInfo);
                    NotifyAllObserver(propBuilder);

                    Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(userInfo);
                    NotifyAllObserver(combatBuilder);

                    LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to observers", infoUser.RoleId);
                }
            }
        }
Esempio n. 5
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);
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        private void SyncUserToUserHelper(User infoUser, User user, bool isSelf)
        {
            Room room = GetRoom();

            if (null != infoUser && null != user && null != room && null != room.GetActiveScene())
            {
                UserInfo userInfo = infoUser.Info;
                if (null != userInfo)
                {
                    Vector3 pos = userInfo.GetMovementStateInfo().GetPosition3D();
                    ArkCrossEngineMessage.Position pos_bd0 = new ArkCrossEngineMessage.Position();
                    pos_bd0.x = pos.X;
                    pos_bd0.z = pos.Z;
                    Msg_CRC_Create bd0 = new Msg_CRC_Create();
                    bd0.role_id        = infoUser.RoleId;
                    bd0.hero_id        = infoUser.HeroId;
                    bd0.camp_id        = infoUser.CampId;
                    bd0.role_level     = infoUser.Level;
                    bd0.is_player_self = isSelf;
                    bd0.position       = pos_bd0;
                    bd0.face_dirction  = (float)userInfo.GetMovementStateInfo().GetFaceDir();
                    for (int index = 0; index < userInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                    {
                        bd0.skill_levels.Add(userInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                    }
                    bd0.scene_start_time = StartTime;
                    bd0.nickname         = infoUser.Name;
                    user.SendMessage(bd0);
                    ///
                    if (infoUser.PresetIndex >= 0)
                    {
                        Msg_RC_UpdateUserBattleInfo uusMsg = new Msg_RC_UpdateUserBattleInfo();
                        uusMsg.role_id      = infoUser.Info.GetId();
                        uusMsg.preset_index = infoUser.PresetIndex;
                        for (int i = 0; i < infoUser.Skill.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.PresetInfo preset_info = new Msg_RC_UpdateUserBattleInfo.PresetInfo();
                            preset_info.skill_id    = infoUser.Skill[i].SkillId;
                            preset_info.skill_level = infoUser.Skill[i].SkillLevel;
                            uusMsg.skill_info.Add(preset_info);
                        }
                        for (int i = 0; i < infoUser.Equip.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.EquipInfo equip_info = new Msg_RC_UpdateUserBattleInfo.EquipInfo();
                            equip_info.equip_id              = infoUser.Equip[i].ItemId;
                            equip_info.equip_level           = infoUser.Equip[i].ItemLevel;
                            equip_info.equip_random_property = infoUser.Equip[i].ItemRandomProperty;
                            uusMsg.equip_info.Add(equip_info);
                        }
                        for (int i = 0; i < infoUser.Legacy.Count; i++)
                        {
                            Msg_RC_UpdateUserBattleInfo.LegacyInfo legacy_info = new Msg_RC_UpdateUserBattleInfo.LegacyInfo();
                            legacy_info.legacy_id              = infoUser.Legacy[i].ItemId;
                            legacy_info.legacy_level           = infoUser.Legacy[i].ItemLevel;
                            legacy_info.legacy_random_property = infoUser.Legacy[i].ItemRandomProperty;
                            legacy_info.legacy_IsUnlock        = infoUser.Legacy[i].IsUnlock;
                            uusMsg.legacy_info.Add(legacy_info);
                        }
                        foreach (XSoulPartInfo part in infoUser.XSouls.GetAllXSoulPartData().Values)
                        {
                            Msg_RC_UpdateUserBattleInfo.XSoulDataInfo xsoul_info = new Msg_RC_UpdateUserBattleInfo.XSoulDataInfo();
                            xsoul_info.ItemId     = part.XSoulPartItem.ItemId;
                            xsoul_info.Level      = part.XSoulPartItem.Level;
                            xsoul_info.Experience = part.XSoulPartItem.Experience;
                            xsoul_info.ModelLevel = part.ShowModelLevel;
                            uusMsg.XSouls.Add(xsoul_info);
                        }
                        if (null != infoUser.Partner)
                        {
                            Msg_RC_UpdateUserBattleInfo.PartnerDataInfo partner_info = new Msg_RC_UpdateUserBattleInfo.PartnerDataInfo();
                            partner_info.PartnerId    = infoUser.Partner.Id;
                            partner_info.PartnerLevel = infoUser.Partner.CurAdditionLevel;
                            partner_info.PartnerStage = infoUser.Partner.CurSkillStage;
                            uusMsg.Partners.Add(partner_info);
                        }
                        user.SendMessage(uusMsg);
                    }
                    ///
                    DataSyncUtility.SyncBuffListToUser(userInfo, user);

                    Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(userInfo);
                    user.SendMessage(propBuilder);

                    Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(userInfo);
                    user.SendMessage(combatBuilder);

                    LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to user {1}", infoUser.RoleId, user.RoleId);
                }
            }
        }
Esempio n. 8
0
        internal void SyncForNewObserver(Observer observer)
        {
            if (null != observer)
            {
                Room room = GetRoom();
                if (null != room && null != room.GetActiveScene())
                {
                    //同步其他玩家数据与物品给自己
                    foreach (User other in room.RoomUsers)
                    {
                        if (!other.IsEntered)
                        {
                            continue;
                        }
                        UserInfo otherInfo = other.Info;
                        if (null != otherInfo)
                        {
                            Vector3 pos = otherInfo.GetMovementStateInfo().GetPosition3D();
                            ArkCrossEngineMessage.Position pos_bd = new ArkCrossEngineMessage.Position();
                            pos_bd.x = (float)pos.X;
                            pos_bd.z = (float)pos.Z;
                            Msg_CRC_Create bd = new Msg_CRC_Create();
                            bd.role_id        = other.RoleId;
                            bd.hero_id        = other.HeroId;
                            bd.camp_id        = other.CampId;
                            bd.role_level     = other.Level;
                            bd.is_player_self = false;
                            bd.position       = pos_bd;
                            bd.face_dirction  = (float)otherInfo.GetMovementStateInfo().GetFaceDir();
                            for (int index = 0; index < otherInfo.GetSkillStateInfo().GetAllSkill().Count; index++)
                            {
                                bd.skill_levels.Add(otherInfo.GetSkillStateInfo().GetSkillInfoByIndex(index).SkillLevel);
                            }
                            bd.scene_start_time = StartTime;
                            bd.nickname         = other.Name;
                            observer.SendMessage(bd);

                            DataSyncUtility.SyncBuffListToObserver(otherInfo, observer);

                            Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(otherInfo);
                            observer.SendMessage(propBuilder);

                            Msg_RC_SyncCombatStatisticInfo combatBuilder = DataSyncUtility.BuildSyncCombatStatisticInfo(otherInfo);
                            observer.SendMessage(combatBuilder);

                            LogSys.Log(LOG_TYPE.DEBUG, "send user {0} msg to observer {1}", other.RoleId, observer.Guid);
                        }
                    }
                    //同步场景数据给观察者
                    for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        NpcInfo npc = linkNode.Value;
                        if (null != npc)
                        {
                            Msg_RC_CreateNpc bder = DataSyncUtility.BuildCreateNpcMessage(npc);
                            observer.SendMessage(bder);
                        }
                    }

                    int totalKillCountForBlue = 0;
                    int totalKillCountForRed  = 0;
                    for (LinkedListNode <UserInfo> linkNode = UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next)
                    {
                        UserInfo user_info = linkNode.Value;
                        if (user_info.GetCampId() == (int)CampIdEnum.Blue)
                        {
                            totalKillCountForBlue += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                        else
                        {
                            totalKillCountForRed += user_info.GetCombatStatisticInfo().KillHeroCount;
                        }
                    }

                    Msg_RC_PvpCombatInfo combat_bd = new Msg_RC_PvpCombatInfo();
                    combat_bd.kill_hero_count_for_blue = totalKillCountForBlue;
                    combat_bd.kill_hero_count_for_red  = totalKillCountForRed;
                    combat_bd.link_id_for_killer       = -1;
                    combat_bd.link_id_for_killed       = -1;
                    combat_bd.killed_nickname          = "";
                    combat_bd.killer_nickname          = "";
                    observer.SendMessage(combat_bd);
                }
            }
        }