示例#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);
        }
示例#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);
        }
示例#3
0
        void Awake()
        {
            SkData skDigTerrain = new SkData();

            skDigTerrain._condToLoop    = SkCond.Create("lasthit");
            skDigTerrain._pretimeOfMain = new float[] { 0.5f };
            skDigTerrain._postimeOfMain = new float[] { 0.5f };
            skDigTerrain._events        = new List <List <SkTriggerEvent> >();
            skDigTerrain._events.Add(new List <SkTriggerEvent>());
            SkTriggerEvent skDigEvent = new SkTriggerEvent();

            skDigEvent._cond       = SkCond.Create("CondToDig");
            skDigEvent._modsTarget = SkAttribsModifier.Create("mad,0,1,-1");
            skDigTerrain._events[0].Add(skDigEvent);
            SkData.s_SkillTbl = new Dictionary <int, SkData>();
            SkData.s_SkillTbl.Add(0, skDigTerrain);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
0
        public static void LoadData()
        {
            if (s_SkillTbl != null)
            {
                return;
            }
#if DBG_COL_ATK
            SkDebug.LoadIds();
#endif
            SkEffect.LoadData();
            SkBuff.LoadData();
            SkTriggerEvent.LoadData();

            SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("skMain");
            //reader.Read(); // skip title if needed
            s_SkillTbl = new Dictionary <int, SkData>();
            while (reader.Read())
            {
                SkData skill = new SkData();
                skill._id                = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_id")));
                skill._desc              = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_desc")));
                skill._icon              = reader.GetString(reader.GetOrdinal("_icon"));
                skill._name              = reader.GetString(reader.GetOrdinal("_name"));
                skill._interruptable     = reader.GetString(reader.GetOrdinal("_interruptable")).Equals("1");
                skill._coolingTime       = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_coolingTime")));
                skill._coolingTimeType   = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_coolingTimeType")));
                skill._coolingTimeShared = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_coolingTimeShared")));

                skill._pretimeOfPrepare = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_pretimeOfPrepare")));
                skill._postimeOfPrepare = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_postimeOfPrepare")));
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effPrepare"))), out skill._effPrepare);

                skill._condToLoop      = SkCond.Create(reader.GetString(reader.GetOrdinal("_cond")));
                skill._pretimeOfMain   = ToSingleArray(reader.GetString(reader.GetOrdinal("_pretimeOfMain")));
                skill._timeOfMain      = ToSingleArray(reader.GetString(reader.GetOrdinal("_timeOfMain")));
                skill._postimeOfMain   = ToSingleArray(reader.GetString(reader.GetOrdinal("_postimeOfMain")));
                skill._effMainEachTime = ToSkEffectArray(reader.GetString(reader.GetOrdinal("_effMainEachTime")));
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effMainOneTime"))), out skill._effMainOneTime);

                string[] strEventsList = reader.GetString(reader.GetOrdinal("_triggerEvents")).Split(';');
                foreach (string strEvents in strEventsList)
                {
                    List <SkTriggerEvent> curEvents = new List <SkTriggerEvent>();
                    string[] strCurEvents           = strEvents.Split(',');
                    foreach (string strEvent in strCurEvents)
                    {
                        int            eventId = Convert.ToInt32(strEvent);
                        SkTriggerEvent curEvent;
                        SkTriggerEvent.s_SkTriggerEventTbl.TryGetValue(eventId, out curEvent);
                        if (curEvent != null)
                        {
                            curEvents.Add(curEvent);
                        }
                    }
                    skill._events.Add(curEvents);
                }

                skill._pretimeOfEnding = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_pretimeOfEnding")));
                skill._postimeOfEnding = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_postimeOfEnding")));
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effEnding"))), out skill._effEnding);

                try{
                    s_SkillTbl.Add(skill._id, skill);
                }catch (Exception e)     {
                    Debug.LogError("Exception on skMain " + skill._id + " " + e);
                }
            }

            new Thread(new ThreadStart(SkInst.s_ExpCompiler.Compile)).Start();
            //SkInst.s_ExpCompiler.Compile();
        }