Example #1
0
        public static SkCoolInfo GetSkillCoolingInfo(SkEntity caster, SkData skData)
        {
            List <SkInst> insts = SkInstPool.Instance._skInsts;

            foreach (SkInst it in insts)
            {
                if (it._caster == caster)
                {
                    if (it._skData._id == skData._id && it._skData._coolingTime > PETools.PEMath.Epsilon)
                    {
                        SkCoolInfo cinfo = new SkCoolInfo();
                        cinfo._bShare    = false;
                        cinfo._fMaxTime  = it._skData._coolingTime;
                        cinfo._fLeftTime = it._skData._coolingTime - (Time.time - it._startTime);
                        return(cinfo);
                    }
                    else if (it._skData._coolingTimeType == skData._coolingTimeType && it._skData._coolingTimeShared > PETools.PEMath.Epsilon)
                    {
                        SkCoolInfo cinfo = new SkCoolInfo();
                        cinfo._bShare    = true;
                        cinfo._fMaxTime  = it._skData._coolingTimeShared;
                        cinfo._fLeftTime = it._skData._coolingTimeShared - (Time.time - it._startTime);
                        return(cinfo);
                    }
                }
            }
            return(null);
        }
Example #2
0
        // skill instances management
        //============================
        public static SkInst StartSkill(SkEntity caster, SkEntity target, int skId, ISkPara para = null, bool bStartImm = true)
        {
            SkData skData = null;

            if (!SkData.s_SkillTbl.TryGetValue(skId, out skData))
            {
                Debug.LogError("[SkInst]:Invalid skill id:" + skId);
                return(null);
            }

                        #if DBG_COL_ATK
            //if(!SkDebug.IsDebuggingID(skId))	return null;
                        #endif
            // cool check
            SkCoolInfo cinfo = GetSkillCoolingInfo(caster, skData);
            if (cinfo != null && cinfo._fLeftTime > 0)
            {
                //Debug.LogError("[SkInst]:Skill id:" + skId +" in cooling..");
                return(null);
            }

            SkInst inst = new SkInst();
            SkInstPool.Instance._skInsts.Add(inst);
            inst._skData    = skData;
            inst._para      = para;
            inst._caster    = caster;
            inst._target    = target;
            inst._coroutine = bStartImm ? new CoroutineStoppable(caster, inst.Exec()) : null;
            return(inst);
        }
Example #3
0
        public static float GetSkillCoolingPercent(SkEntity caster, int skId)
        {
            SkData skData = null;

            if (!SkData.s_SkillTbl.TryGetValue(skId, out skData))
            {
                //Debug.LogError("[SkInst]:Invalid skill id:" + skId);
                return(-1);
            }
            SkCoolInfo cinfo = GetSkillCoolingInfo(caster, skData);

            if (cinfo != null && cinfo._fLeftTime > 0)
            {
                return(cinfo._fLeftTime / cinfo._fMaxTime);
            }
            return(0);
        }
Example #4
0
        public static bool IsSkillRunnable(SkEntity caster, int skId)
        {
            SkData skData = null;

            if (!SkData.s_SkillTbl.TryGetValue(skId, out skData))
            {
                return(false);
            }
            // cool check
            SkCoolInfo cinfo = GetSkillCoolingInfo(caster, skData);

            if (cinfo != null && cinfo._fLeftTime > 0)
            {
                return(false);
            }
            return(true);
        }