예제 #1
0
        private NpcInfo CreateParterner(UserInfo owner, PartnerInfo partnerInfo)
        {
            if (null == owner)
            {
                return(null);
            }
            if (null == partnerInfo)
            {
                return(null);
            }
            Data_Unit data = new Data_Unit();

            data.m_Id         = -1;
            data.m_LinkId     = partnerInfo.LinkId;
            data.m_CampId     = owner.GetCampId();
            data.m_Pos        = owner.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 = WorldSystem.Instance.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)(owner.GetActualProperty().AttackBase *inheritAttackAttrPercent));
                    npc.GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, owner.GetActualProperty().FireDamage *inheritAttackAttrPercent);
                    npc.GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, owner.GetActualProperty().IceDamage *inheritAttackAttrPercent);
                    npc.GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, owner.GetActualProperty().PoisonDamage *inheritAttackAttrPercent);
                    // defence
                    npc.GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, (int)(owner.GetActualProperty().HpMax *inheritDefenceAttrPercent));
                    npc.GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, (int)(owner.GetActualProperty().EnergyMax *inheritDefenceAttrPercent));
                    npc.GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, (int)(owner.GetActualProperty().ADefenceBase *inheritDefenceAttrPercent));
                    npc.GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, (int)(owner.GetActualProperty().MDefenceBase *inheritDefenceAttrPercent));
                    npc.GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, owner.GetActualProperty().FireERD *inheritDefenceAttrPercent);
                    npc.GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, owner.GetActualProperty().IceERD *inheritDefenceAttrPercent);
                    npc.GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, owner.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.IsArenaPartner = 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);
                    }
                }
                owner.LastSummonPartnerTime = TimeUtility.GetServerMilliseconds();
                npc.SkillController         = new SwordManSkillController(npc, GfxModule.Skill.GfxSkillSystem.Instance);
                npc.OwnerId     = owner.GetId();
                owner.PartnerId = npc.GetId();
                npc.SetLevel(owner.GetLevel());
                EntityManager.Instance.CreateNpcView(npc.GetId());
                if (partnerInfo.BornSkill > 0)
                {
                    SkillInfo skillInfo = new SkillInfo(partnerInfo.BornSkill);
                    npc.GetSkillStateInfo().AddSkill(skillInfo);
                    npc.SkillController.ForceStartSkill(partnerInfo.BornSkill);
                }
                CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId());
                if (null != view)
                {
                    GfxSystem.SetLayer(view.Actor, "PhysicObj");
                }
            }
            return(npc);
        }
예제 #2
0
        public override bool IsSatifyUser(CharacterInfo entity)
        {
            List <int> skillList = Converter.ConvertNumericList <int>(Config.ActionParam);
            long       curTime   = TimeUtility.GetServerMilliseconds();

            for (int i = 0; i < skillList.Count; i++)
            {
                if (skillList[i] > 0)
                {
                    if (entity.GetSkillStateInfo().GetSkillInfoById(skillList[i]) == null)
                    {
                        return(false);
                    }
                    SkillInfo skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillList[i]);
                    if (null == skillInfo || skillInfo.IsInCd(curTime / 1000.0f))
                    {
                        return(false);
                    }
                }
                else
                {
                    AiSkillComboList aiSkillComboConfig = AiSkillComboListProvider.Instance.GetDataById(skillList[i] * -1);
                    if (null != aiSkillComboConfig)
                    {
                        for (int j = 0; j < aiSkillComboConfig.SkillList.Count; j++)
                        {
                            if (entity.GetSkillStateInfo().GetSkillInfoById(aiSkillComboConfig.SkillList[i]) == null)
                            {
                                return(false);
                            }
                            SkillInfo skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(aiSkillComboConfig.SkillList[i]);
                            if (null == skillInfo || skillInfo.IsInCd(curTime / 1000.0f))
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            /*
             * foreach (int comboId in skillList) {
             * if (comboId > 0) {
             *  if (entity.GetSkillStateInfo().GetSkillInfoById(comboId) == null) {
             *    return false;
             *  }
             * } else {
             *  AiSkillComboList aiSkillComboConfig = AiSkillComboListProvider.Instance.GetDataById(comboId * -1);
             *  if (null != aiSkillComboConfig) {
             *    foreach (int skillId in aiSkillComboConfig.SkillList) {
             *      if (entity.GetSkillStateInfo().GetSkillInfoById(skillId) == null) {
             *        return false;
             *      }
             *    }
             *  } else {
             *    return false;
             *  }
             * }
             * }*/
            return(true);
        }
예제 #3
0
        private UserInfo CreateArenaTarget(ArenaTargetInfo target)
        {
            if (target == null)
            {
                return(null);
            }
            int      image_res_id = target.HeroId;
            UserInfo image_player = m_UserMgr.AddUser(image_res_id);

            if (null != image_player)
            {
                image_player.SceneContext = m_SceneContext;
                int campid = NetworkSystem.Instance.CampId == (int)CampIdEnum.Blue ? (int)CampIdEnum.Red : (int)CampIdEnum.Blue;
                image_player.SetCampId(campid);
                Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(campid)) as Data_Unit;
                if (null != unit)
                {
                    image_player.GetAiStateInfo().AiLogic = unit.m_AiLogic;
                    image_player.SetAIEnable(true);
                    image_player.GetMovementStateInfo().SetPosition(unit.m_Pos);
                    image_player.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle);
                }
                image_player.SetLevel(target.Level);
                image_player.SetNickName(target.Nickname);
                image_player.SkillController = new SwordManSkillController(image_player, GfxModule.Skill.GfxSkillSystem.Instance);
                if (null != m_SpatialSystem)
                {
                    m_SpatialSystem.AddObj(image_player.SpaceObject);
                }
                /// skills
                if (null != target.Skills)
                {
                    image_player.GetSkillStateInfo().RemoveAllSkill();
                    int skill_ct = target.Skills.Count;
                    for (int i = 0; i < skill_ct; i++)
                    {
                        SkillInfo info = target.Skills[i];
                        if (null != info)
                        {
                            SkillCategory cur_skill_pos = SkillCategory.kNone;
                            if (info.Postions.Presets[0] == SlotPosition.SP_A)
                            {
                                cur_skill_pos = SkillCategory.kSkillA;
                            }
                            else if (info.Postions.Presets[0] == SlotPosition.SP_B)
                            {
                                cur_skill_pos = SkillCategory.kSkillB;
                            }
                            else if (info.Postions.Presets[0] == SlotPosition.SP_C)
                            {
                                cur_skill_pos = SkillCategory.kSkillC;
                            }
                            else if (info.Postions.Presets[0] == SlotPosition.SP_D)
                            {
                                cur_skill_pos = SkillCategory.kSkillD;
                            }
                            info.Category = cur_skill_pos;
                            image_player.GetSkillStateInfo().AddSkill(info);
                            WorldSystem.Instance.AddSubSkill(image_player, info.SkillId, cur_skill_pos, info.SkillLevel);
                        }
                    }
                }
                Data_PlayerConfig playerData = PlayerConfigProvider.Instance.GetPlayerConfigById(image_player.GetLinkId());
                if (null != playerData && null != playerData.m_FixedSkillList &&
                    playerData.m_FixedSkillList.Count > 0)
                {
                    foreach (int skill_id in playerData.m_FixedSkillList)
                    {
                        SkillInfo info = new SkillInfo(skill_id, 1);
                        image_player.GetSkillStateInfo().AddSkill(info);
                    }
                }
                image_player.ResetSkill();
                /// equips
                if (null != target.Equips)
                {
                    int equip_ct = target.Equips.Length;
                    for (int i = 0; i < equip_ct; i++)
                    {
                        ItemDataInfo image_equip = target.Equips[i];
                        if (null != image_equip)
                        {
                            image_player.GetEquipmentStateInfo().ResetEquipmentData(i);
                            image_equip.ItemConfig = ItemConfigProvider.Instance.GetDataById(image_equip.ItemId);
                            if (null != image_equip.ItemConfig)
                            {
                                image_player.GetEquipmentStateInfo().SetEquipmentData(i, image_equip);
                            }
                        }
                    }
                }
                ///
                if (null != target.Legacys)
                {
                    int legacy_ct = target.Legacys.Length;
                    for (int i = 0; i < legacy_ct; i++)
                    {
                        ItemDataInfo image_legacy = target.Legacys[i];
                        if (null != image_legacy && image_legacy.IsUnlock)
                        {
                            image_player.GetLegacyStateInfo().ResetLegacyData(i);
                            image_legacy.ItemConfig = ItemConfigProvider.Instance.GetDataById(image_legacy.ItemId);
                            if (null != image_legacy.ItemConfig)
                            {
                                image_player.GetLegacyStateInfo().SetLegacyData(i, image_legacy);
                            }
                        }
                    }
                    image_player.GetLegacyStateInfo().UpdateLegacyComplexAttr();
                }
                foreach (ArenaXSoulInfo x in target.XSoulInfo)
                {
                    ItemDataInfo item = new ItemDataInfo();
                    item.ItemId     = x.ItemId;
                    item.Level      = x.Level;
                    item.Experience = x.Experience;
                    item.UpdateLevelByExperience();
                    ItemConfig config = ItemConfigProvider.Instance.GetDataById(item.ItemId);
                    if (config == null)
                    {
                        continue;
                    }
                    item.ItemConfig = config;
                    XSoulPartInfo part = new XSoulPartInfo((XSoulPart)config.m_WearParts, item);
                    part.ShowModelLevel = x.ModelLevel;
                    image_player.GetXSoulInfo().SetXSoulPartData((XSoulPart)config.m_WearParts, part);
                }
                image_player.SetPartnerInfo(target.ActivePartner);
                SetArenaCharacterCoefficient(image_player);
                UserAttrCalculator.Calc(image_player);
                image_player.SetHp(Operate_Type.OT_Absolute, image_player.GetActualProperty().HpMax);
                image_player.SetRage(Operate_Type.OT_Absolute, 0);
                image_player.SetEnergy(Operate_Type.OT_Absolute, image_player.GetActualProperty().EnergyMax);

                target.CreatedPartners.Clear();
                int total_hp = image_player.GetActualProperty().HpMax;
                //LogSystem.Error("---challenge target hp=" + image_player.GetActualProperty().HpMax);
                foreach (PartnerInfo partner in target.FightPartners)
                {
                    NpcInfo partner_npc = CreateParterner(image_player, partner);
                    if (partner_npc != null)
                    {
                        target.CreatedPartners.Add(partner.Id, partner_npc);
                        //LogSystem.Error("---parnter {0} hp={1}", partner.Id, partner_npc.GetBaseProperty().HpMax);
                        total_hp += partner_npc.GetBaseProperty().HpMax;
                    }
                }
                //LogSystem.Error("-----challenge target total hp=" + total_hp);
                EntityManager.Instance.CreateUserView(image_player.GetId());
                UserView image_view = EntityManager.Instance.GetUserViewById(image_player.GetId());
                image_view.UpdateEquipment();
                image_view.UpdateXSoulEquip();
            }
            SyncGfxUserInfo(image_player.GetId());
            return(image_player);
        }
예제 #4
0
        private void PursuitHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime)
        {
            if (npc.IsDead())
            {
                npc.GetMovementStateInfo().IsMoving = false;
                NotifyNpcMove(npc);
                return;
            }
            NpcAiStateInfo       info = npc.GetAiStateInfo();
            AiData_Npc_BossHulun data = GetAiData(npc);

            if (null != data)
            {
                CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(npc, info.Target);
                if (null != target)
                {
                    if (npc.IsUnderControl())
                    {
                        data.ControlTime += deltaTime;
                        if (data.ControlTime > m_MaxControlTime && npc.CanDisControl())
                        {
                            NotifyNpcAddImpact(npc, m_SuperArmorImpactId);
                            data.ControlTime = 0;
                            NotifyNpcSkill(npc, 380308);
                        }
                    }
                    float   dist          = (float)npc.GetActualProperty().AttackRange;
                    float   distGoHome    = (float)npc.GohomeRange;
                    Vector3 targetPos     = target.GetMovementStateInfo().GetPosition3D();
                    Vector3 srcPos        = npc.GetMovementStateInfo().GetPosition3D();
                    float   powDist       = Geometry.DistanceSquare(srcPos, targetPos);
                    float   powDistToHome = Geometry.DistanceSquare(srcPos, info.HomePos);
                    // 遇敌是播放特效, 逗留两秒。
                    if (data.WaitTime <= m_ResponseTime)
                    {
                        if (!data.HasMeetEnemy)
                        {
                            NotifyNpcMeetEnemy(npc, Animation_Type.AT_Attack);
                            data.HasMeetEnemy = true;
                        }
                        TrySeeTarget(npc, target);
                        data.WaitTime += deltaTime;
                        return;
                    }
                    if (npc.GetSkillStateInfo().IsSkillActivated())
                    {
                        SkillInfo curSkill = npc.GetSkillStateInfo().GetCurSkillInfo();
                        if (null != curSkill && curSkill.SkillId == data.ChaseTargetSkill)
                        {
                            NotifyNpcRun(npc);
                            AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, deltaTime, true, this);
                            data.IsUsingChaseSkill = true;
                        }
                        return;
                    }
                    else if (data.IsUsingChaseSkill)
                    {
                        npc.GetMovementStateInfo().IsMoving = false;
                        NotifyNpcMove(npc);
                        data.IsUsingChaseSkill = false;
                    }
                    if (1 == data.CurStage)
                    {
                        if (npc.Hp < npc.GetActualProperty().HpMax *data.StageTwoLimit)
                        {
                            data.CurStage = 2;
                            NotifyNpcSkill(npc, data.EnterStageTwoSkill);
                            data.CurSkillCombo      = null;
                            data.CurSkillComboIndex = 0;
                            return;
                        }
                        else
                        {
                            if (null == data.CurSkillCombo)
                            {
                                data.CurSkillCombo      = data.m_StageOneSkillCombo;
                                data.CurSkillComboIndex = 0;
                            }
                        }
                    }
                    else if (2 == data.CurStage)
                    {
                        if (npc.Hp < npc.GetActualProperty().HpMax *data.StageThreeLimit)
                        {
                            data.CurStage = 3;
                            NotifyNpcSkill(npc, data.EnterStageTwoSkill);
                            data.CurSkillCombo      = null;
                            data.CurSkillComboIndex = 0;
                            return;
                        }
                        else
                        {
                            if (null == data.CurSkillCombo)
                            {
                                data.CurSkillCombo      = data.m_StageTwoSkillCombo;
                                data.CurSkillComboIndex = 0;
                            }
                        }
                    }
                    else if (3 == data.CurStage)
                    {
                        if (null == data.CurSkillCombo)
                        {
                            data.CurSkillCombo      = data.m_StageThreeSkillCombo;
                            data.CurSkillComboIndex = 0;
                        }
                    }
                    if (null != data.CurSkillCombo)
                    {
                        if (data.CurSkillCombo.Length > data.CurSkillComboIndex)
                        {
                            if (TryCastSkill(npc, data.CurSkillCombo[data.CurSkillComboIndex], target))
                            {
                                data.CurSkillComboIndex = data.CurSkillComboIndex + 1;
                                return;
                            }
                        }
                        else
                        {
                            data.CurSkillCombo      = null;
                            data.CurSkillComboIndex = 0;
                        }
                    }
                    // 大于攻击距离 跑向目标
                    info.Time += deltaTime;
                    if (info.Time > m_IntervalTime)
                    {
                        NotifyNpcRun(npc);
                        info.Time = 0;
                        AiLogicUtility.PathToTargetWithoutObstacle(npc, data.FoundPath, targetPos, m_IntervalTime, true, this);
                    }
                }
                else
                {
                    NotifyNpcTargetChange(npc);
                    npc.GetMovementStateInfo().IsMoving = false;
                    NotifyNpcMove(npc);
                    info.Time = 0;
                    ChangeToState(npc, (int)AiStateId.Idle);
                }
            }
        }