Exemple #1
0
        private void CalcPvpCombatInfo(int killerLinkId, int killedLinkId, string killerNickname, string killedNickname)
        {
            int totalKillCountForBlue = 0;
            int totalKillCountForRed  = 0;

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

            Msg_RC_PvpCombatInfo builder = new Msg_RC_PvpCombatInfo();

            builder.kill_hero_count_for_blue = totalKillCountForBlue;
            builder.kill_hero_count_for_red  = totalKillCountForRed;
            builder.link_id_for_killer       = killerLinkId;
            builder.link_id_for_killed       = killedLinkId;
            builder.killer_nickname          = killerNickname;
            builder.killed_nickname          = killedNickname;

            NotifyAllUser(builder);
        }
Exemple #2
0
        private void RemoveObjectImpl(CharacterInfo obj)
        {
            UserInfo user = obj.CastUserInfo();

            if (null != user)
            {
                int camp = user.GetCampId();
                if (camp_users_.ContainsKey(camp))
                {
                    List <UserInfo> users = camp_users_[camp];
                    users.Remove(user);
                }
            }
        }
Exemple #3
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);
        }
Exemple #4
0
        private void SyncSceneObjectsToUser(User user)
        {
            if (null != user)
            {
                UserInfo userInfo = user.Info;
                Room     room     = GetRoom();
                if (null != userInfo && null != room && null != room.GetActiveScene())
                {
                    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);
                            if (npc.AppendAttrId > 0)
                            {
                                bder.add_attr_id = npc.AppendAttrId;
                            }
                            user.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          = "";
                    user.SendMessage(combat_bd);
                }
            }
        }
Exemple #5
0
        private void AddObjectImpl(CharacterInfo obj)
        {
            UserInfo user = obj.CastUserInfo();

            if (null != user)
            {
                int             camp  = user.GetCampId();
                List <UserInfo> users = null;
                if (!camp_users_.ContainsKey(camp))
                {
                    users = new List <UserInfo>();
                    camp_users_.Add(camp, users);
                }
                else
                {
                    users = camp_users_[camp];
                }
                if (!users.Contains(user))
                {
                    users.Add(user);
                }
            }
        }
        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);
                    }
                }
            }
        }
Exemple #7
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);
                    }
                }
            }
        }
Exemple #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);
                }
            }
        }