Exemplo n.º 1
0
    public void TryPlaySkill(int id, Ilife user, Ilife lockedTarget = null)
    {
        SkillConfig config = ConfigManager.Instance.GetSkillConfig(id);

        if (null == config)
        {
            Debuger.Log("can't load skill id: " + id);
            return;
        }

        //check cd
        SkillCd cd = null;

        if (m_CdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill
                return;
            }
        }

        if (m_BeginCdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill
                return;
            }
        }

        if (m_PlayingSkill.ContainsKey(id))
        {
            //can't play
            return;
        }

        //per handle
        HandleTarget target = HandleTarget.GetHandleTarget(user);

        if (LimitMethods.HandleLimitExec(target, config.PerLimitId, null))
        {
            FuncMethods.HandleFuncExec(target, config.PerFuncId, null);

            m_LockedTargetList.Add(id, lockedTarget);

            if (config.BeginCd <= 0)
            {
                TriggerExecSkill(user, config);
            }
            else
            {
                if (m_BeginCdStore.ContainsKey(config.Id))
                {
                    m_BeginCdStore.Add(config.Id, new SkillCd(config.InitCd, config, user));
                }
                else
                {
                    m_BeginCdStore[config.Id] = new SkillCd(config.InitCd, config, user);
                }
            }
        }
    }