示例#1
0
        public void LoadData(int resId)
        {
            SetLinkId(resId);
            m_LevelupConfig = NpcConfigProvider.Instance.GetNpcLevelupConfigById(resId);
            Data_NpcConfig npcCfg = NpcConfigProvider.Instance.GetNpcConfigById(resId);

            if (null != npcCfg)
            {
                m_NpcType = npcCfg.m_NpcType;
                switch (m_NpcType)
                {
                case (int)NpcTypeEnum.Mecha:
                    m_IsMecha = true;
                    break;

                case (int)NpcTypeEnum.Horse:
                    m_IsHorse = true;
                    break;

                case (int)NpcTypeEnum.Task:
                    m_IsTask = true;
                    break;

                case (int)NpcTypeEnum.PvpTower:
                    m_IsPvpTower = true;
                    break;
                }
                m_NpcFigure         = npcCfg.m_NpcFigure;
                m_CanMove           = npcCfg.m_CanMove;
                m_CanHitMove        = npcCfg.m_CanHitMove;
                m_CanRotate         = npcCfg.m_CanRotate;
                m_Scale             = npcCfg.m_Scale;
                m_ParticleScale     = npcCfg.m_ParticleScale;
                m_CauseStiff        = npcCfg.m_CauseStiff;
                m_AcceptStiff       = npcCfg.m_AcceptStiff;
                m_AcceptStiffEffect = npcCfg.m_AcceptStiffEffect;

                m_IsAttachControler = npcCfg.m_IsAttachControler;
                m_AttachNodeName    = npcCfg.m_AttachNodeName;
                m_BornAnimTimeMs    = npcCfg.m_BornAnimTime;

                SetName(npcCfg.m_Name);
                SetLevel(npcCfg.m_Level);
                SetModel(npcCfg.m_Model);
                SetBornEffect(npcCfg.m_BornEffect);
                SetBornEffectTime(npcCfg.m_BornEffectTime);
                SetActionList(npcCfg.m_ActionList);

                AvoidanceRadius = npcCfg.m_AvoidanceRadius;
                if (null != npcCfg.m_Shape)
                {
                    Shape = (Shape)npcCfg.m_Shape.Clone();
                }
                else
                {
                    Shape = new Circle(new Vector3(0, 0, 0), 1);
                }

                ViewRange           = npcCfg.m_ViewRange;
                GohomeRange         = npcCfg.m_GohomeRange;
                ReleaseTime         = npcCfg.m_ReleaseTime;
                SuperArmor          = npcCfg.m_SuperArmor;
                m_MeetEnemyImpact   = npcCfg.m_MeetEnemyImpact;
                m_MeetEnemyStayTime = npcCfg.m_MeetEnemyStayTime;
                m_MeetEnemyWalkTime = npcCfg.m_MeetEnemyWalkTime;

                int   hp                 = (int)npcCfg.m_AttrData.GetAddHpMax(0, npcCfg.m_Level);
                int   energy             = (int)npcCfg.m_AttrData.GetAddEpMax(0, npcCfg.m_Level);
                float moveSpeed          = npcCfg.m_AttrData.GetAddSpd(0, npcCfg.m_Level);
                float walkSpeed          = npcCfg.m_AttrData.GetAddWalkSpd(0, npcCfg.m_Level);
                float runSpeed           = npcCfg.m_AttrData.GetAddRunSpd(0, npcCfg.m_Level);
                int   hpMax              = (int)npcCfg.m_AttrData.GetAddHpMax(0, npcCfg.m_Level);
                int   energyMax          = (int)npcCfg.m_AttrData.GetAddEpMax(0, npcCfg.m_Level);
                float hpRecover          = npcCfg.m_AttrData.GetAddHpRecover(0, npcCfg.m_Level);
                float energyRecover      = npcCfg.m_AttrData.GetAddEpRecover(0, npcCfg.m_Level);
                int   attackBase         = (int)npcCfg.m_AttrData.GetAddAd(0, npcCfg.m_Level);
                int   aDefenceBase       = (int)npcCfg.m_AttrData.GetAddADp(0, npcCfg.m_Level);
                int   mDefenceBase       = (int)npcCfg.m_AttrData.GetAddMDp(0, npcCfg.m_Level);
                float critical           = npcCfg.m_AttrData.GetAddCri(0, npcCfg.m_Level);
                float criticalPow        = npcCfg.m_AttrData.GetAddPow(0, npcCfg.m_Level);
                float criticalBackHitPow = npcCfg.m_AttrData.GetAddBackHitPow(0, npcCfg.m_Level);
                float criticalCrackPow   = npcCfg.m_AttrData.GetAddCrackPow(0, npcCfg.m_Level);
                float fireDam            = npcCfg.m_AttrData.GetAddFireDam(0, npcCfg.m_Level);
                float fireErd            = npcCfg.m_AttrData.GetAddFireErd(0, npcCfg.m_Level);
                float iceDam             = npcCfg.m_AttrData.GetAddIceDam(0, npcCfg.m_Level);
                float iceErd             = npcCfg.m_AttrData.GetAddIceErd(0, npcCfg.m_Level);
                float poisonDam          = npcCfg.m_AttrData.GetAddPoisonDam(0, npcCfg.m_Level);
                float poisonErd          = npcCfg.m_AttrData.GetAddPoisonErd(0, npcCfg.m_Level);
                float weight             = npcCfg.m_AttrData.GetAddWeight(0, npcCfg.m_Level);
                float rps                = npcCfg.m_AttrData.GetAddRps(0, npcCfg.m_Level);
                float attackRange        = npcCfg.m_AttrData.GetAddAttackRange(0, npcCfg.m_Level);

                GetBaseProperty().SetMoveSpeed(Operate_Type.OT_Absolute, moveSpeed);
                GetBaseProperty().SetWalkSpeed(Operate_Type.OT_Absolute, walkSpeed);
                GetBaseProperty().SetRunSpeed(Operate_Type.OT_Absolute, runSpeed);
                GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, hpMax);
                GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, energyMax);
                GetBaseProperty().SetHpRecover(Operate_Type.OT_Absolute, hpRecover);
                GetBaseProperty().SetEnergyRecover(Operate_Type.OT_Absolute, energyRecover);
                GetBaseProperty().SetAttackBase(Operate_Type.OT_Absolute, attackBase);
                GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, aDefenceBase);
                GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, mDefenceBase);
                GetBaseProperty().SetCritical(Operate_Type.OT_Absolute, critical);
                GetBaseProperty().SetCriticalPow(Operate_Type.OT_Absolute, criticalPow);
                GetBaseProperty().SetCriticalBackHitPow(Operate_Type.OT_Absolute, criticalBackHitPow);
                GetBaseProperty().SetCriticalCrackPow(Operate_Type.OT_Absolute, criticalCrackPow);
                GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, fireDam);
                GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, fireErd);
                GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, iceDam);
                GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, iceErd);
                GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, poisonDam);
                GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, poisonErd);
                GetBaseProperty().SetWeight(Operate_Type.OT_Absolute, weight);
                GetBaseProperty().SetRps(Operate_Type.OT_Absolute, rps);
                GetBaseProperty().SetAttackRange(Operate_Type.OT_Absolute, attackRange);

                // ¼¼ÄÜÊý¾Ý
                for (int i = 0; i < npcCfg.m_SkillList.Count; i++)
                {
                    SkillInfo skillInfo = new SkillInfo(npcCfg.m_SkillList[i]);
                    GetSkillStateInfo().AddSkill(skillInfo);
                }
                if (npcCfg.m_DeadSkill > 0)
                {
                    if (null == GetSkillStateInfo().GetSkillInfoById(npcCfg.m_DeadSkill))
                    {
                        SkillInfo deadSkillInfo = new SkillInfo(npcCfg.m_DeadSkill);
                        GetSkillStateInfo().AddSkill(deadSkillInfo);
                    }
                    m_DeadSkillId = npcCfg.m_DeadSkill;
                }

                NpcAttrCalculator.Calc(this);
                SetHp(Operate_Type.OT_Absolute, GetActualProperty().HpMax);
                SetEnergy(Operate_Type.OT_Absolute, GetActualProperty().EnergyMax);
                m_Cross2StandTime = npcCfg.m_Cross2StandTime;
                m_Cross2RunTime   = npcCfg.m_Cross2Runtime;
                m_DeadAnimTime    = npcCfg.m_DeadAnimTime;
                for (int i = 0; i < npcCfg.m_TauntSound.Count; ++i)
                {
                    m_TauntSound.Add(npcCfg.m_TauntSound[i]);
                }
                for (int i = 0; i < npcCfg.m_HitSounds.Count; ++i)
                {
                    m_HitSounds.Add(npcCfg.m_HitSounds[i]);
                }
                for (int i = 0; i < npcCfg.m_DeadSound.Count; ++i)
                {
                    m_DeadSound.Add(npcCfg.m_DeadSound[i]);
                }
            }
        }
示例#2
0
    public void SaveSelected()
    {
#if UNITY_EDITOR
        // Get player id
        int        id = -1;
        int        normalAttackSkillId = -1;
        List <int> skillList           = new List <int>();

        ArkCrossEngine.FileReaderProxy.MakeSureAllHandlerRegistered();
        ArkCrossEngine.PlayerConfigProvider.Instance.Clear();
        ArkCrossEngine.PlayerConfigProvider.Instance.LoadPlayerConfig(Application.dataPath + "\\StreamingAssets\\Public\\PlayerConfig.txt", "PlayerConfig");
        var players = ArkCrossEngine.PlayerConfigProvider.Instance.PlayerConfigMgr.GetData();
        foreach (var p in players)
        {
            ArkCrossEngine.Data_PlayerConfig cfg = (ArkCrossEngine.Data_PlayerConfig)p.Value;

            if (cfg.m_Model.Contains(gameObject.name))
            {
                id = cfg.m_ActionList[0];
                normalAttackSkillId = cfg.m_FixedSkillList[1];
                skillList           = cfg.m_PreSkillList;
                break;
            }
        }
        // Get npc id
        if (id == -1)
        {
            ArkCrossEngine.NpcConfigProvider.Instance.Clear();
            ArkCrossEngine.NpcConfigProvider.Instance.LoadNpcConfig(Application.dataPath + "\\StreamingAssets\\Public\\NpcConfig.txt", "NPCConfig");

            var npcs = ArkCrossEngine.NpcConfigProvider.Instance.NpcConfigMgr.GetData();
            foreach (var npc in npcs)
            {
                ArkCrossEngine.Data_NpcConfig cfg = (ArkCrossEngine.Data_NpcConfig)npc.Value;

                if (cfg.m_Model.Contains(gameObject.name))
                {
                    id = cfg.m_ActionList[0];
                    break;
                }
            }
        }

        // Error
        if (id == -1)
        {
            UnityEditor.EditorUtility.DisplayDialog("SkillEdit", "没有找到当前选中角色的id,请联系程序!", "OK");
            return;
        }

        // Read ActionConfig.txt
        string[] lineTexts = File.ReadAllLines(Application.dataPath + "\\StreamingAssets\\Public\\ActionConfig.txt");
        for (int i = 1; i < lineTexts.Length; ++i)
        {
            string newLine;
            // idle
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.idleAnim, id, new int[] { 8, 9, 10, 11, 12, 16 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // walk
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.walkAnim, id, new int[] { 13 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // run
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.runAnim, id, new int[] { 14, 15, 17 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // hurt
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.hurtAnim, id, new int[] { 18, 19, 20 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // dead
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.deadAnim, id, new int[] { 22 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // getup
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.getupAnim, id, new int[] { 28, 29 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // airup
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.airupAnim, id, new int[] { 30 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // airdown
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.airdownAnim, id, new int[] { 31 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // airhurt
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.airhurtAnim, id, new int[] { 32 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
            // airground
            if (_SetActionAnim(lineTexts[i], 角色行动动画配置.airgroundAnim, id, new int[] { 33 }, out newLine))
            {
                lineTexts[i] = newLine;
            }
        }


        // Save
        StreamWriter sw = new StreamWriter(Application.dataPath + "\\StreamingAssets\\Public\\ActionConfig.txt", false, Encoding.UTF8);

        foreach (string s in lineTexts)
        {
            sw.WriteLine(s);
        }
        sw.Flush();
        sw.Close();

        // Load skill files
        ArkCrossEngine.SkillConfigProvider.Instance.Clear();
        ArkCrossEngine.SkillConfigProvider.Instance.CollectData(ArkCrossEngine.SkillConfigType.SCT_SKILL, Application.dataPath + "\\StreamingAssets\\Public\\Skill\\SkillData.txt", "SkillConfig");

        // Normal attack skill
        _GenerateSkillFile(normalAttackSkillId, 普通攻击第一段.技能动画, 普通攻击第一段.攻击类型, 普通攻击第一段.动画长度, true);

        // Other skills
        int[] activeSkillLst = new int[6];
        foreach (int skillId in skillList)
        {
            var cat = _GetSkillCategory(skillId);
            if (cat >= ArkCrossEngine.SkillCategory.kSkillA && cat <= ArkCrossEngine.SkillCategory.kSkillE)
            {
                activeSkillLst[cat - ArkCrossEngine.SkillCategory.kSkillA] = skillId;
            }
        }

        int idx = 0;
        foreach (int skillId in activeSkillLst)
        {
            if (skillId > 0)
            {
                SkillCfg c = 技能配置[idx++];
                if (c.技能动画.Length > 0)
                {
                    _GenerateSkillFile(skillId, c.技能动画, c.攻击类型, c.动画长度, false);
                }
            }
        }

        UnityEditor.EditorUtility.DisplayDialog("SkillEdit", "保存完毕!", "OK");
#endif
    }