Esempio n. 1
0
    /// <summary>
    /// 按类型添加技能到相应的技能字典
    /// </summary>
    public void AddSkill(string id)
    {
        if (id == string.Empty)
        {
            return;
        }
        SkillData tempSkill = ResMgr.Instance.Load <SkillData>(id);

        if (tempSkill == null)
        {
            return;
        }
        if (tempSkill.skillTag == SkillTag.FixSkill)
        {
            if (tempSkill.key != ReflectKey.none)
            {
                switch (tempSkill.key)
                {
                case ReflectKey.attack:
                    tempCB = KeyCodeMgr.Instance.Attack;
                    break;

                case ReflectKey.jump:
                    tempCB = KeyCodeMgr.Instance.Jump;
                    break;

                case ReflectKey.sprint:
                    tempCB = KeyCodeMgr.Instance.Sprint;
                    break;

                case ReflectKey.superSprint:
                    tempCB = KeyCodeMgr.Instance.SuperSprint;
                    break;

                case ReflectKey.recover:
                    tempCB = KeyCodeMgr.Instance.Recover;
                    break;
                }
                if (tempCB.SkillID == null)
                {
                    tempCB.AttachSkill(id);
                }
            }
            if (!FixSkill.ContainsKey(id))
            {
                FixSkill.Add(id, tempSkill);
            }
            tempSkill.owner = GameManager.Instance.playerGO;
            //处理此技能所附带的连击技能
            while (tempSkill.isBatter)
            {
                SkillData batter = ResMgr.Instance.Load <SkillData>(tempSkill.nextBatterID);
                if (!FixSkill.ContainsKey(batter.skillID))
                {
                    FixSkill.Add(batter.skillID, batter);
                }
                batter.owner        = GameManager.Instance.playerGO;
                batter.coolDownTime = -batter.coolTime;
                if (batter.nextBatterID == tempSkill.skillID)
                {
                    break;
                }
                tempSkill = batter;
            }
            //只有平砍是需要单独处理组合按键,其他有组合按键的技能都由物品带来,无需额外处理
            if (tempSkill.hasComboKey && tempSkill.key == ReflectKey.attack)
            {
                SkillData up = ResMgr.Instance.Load <SkillData>(tempSkill.upKeySkillID);
                if (up != null && !FixSkill.ContainsKey(up.skillID))
                {
                    FixSkill.Add(up.skillID, up);
                }
                up.owner        = GameManager.Instance.playerGO;
                up.coolDownTime = -up.coolTime;
                SkillData down = ResMgr.Instance.Load <SkillData>(tempSkill.downKeySkillID);
                if (down != null && !FixSkill.ContainsKey(down.skillID))
                {
                    FixSkill.Add(down.skillID, down);
                }
                down.owner        = GameManager.Instance.playerGO;
                down.coolDownTime = -down.coolTime;
            }
            if (tempSkill.canBeChangeByBadge)
            {
                SkillData that = ResMgr.Instance.Load <SkillData>(tempSkill.skillIDIfChanged);
                that.owner = GameManager.Instance.playerGO;
            }
        }
        else
        {
            if (!badgeSkill.ContainsKey(id))
            {
                badgeSkill.Add(id, tempSkill);
            }
            tempSkill.owner = GameManager.Instance.playerGO;
        }
        if (tempSkill.hasCoolTime)
        {
            tempSkill.coolDownTime = -tempSkill.coolTime;
        }
    }