Exemple #1
0
        public static int CreateBuff(int tmplBuffId, string modDesc)            //A*(x+B)+C
        {
            // TODO : code to catch exception while tmplBuff == null
            SkBuff tmplBuff = s_SkBuffTbl[tmplBuffId];
            SkBuff buff     = new SkBuff();

            buff._id         = ++s_maxId;
            buff._icon       = tmplBuff._icon;
            buff._desc       = tmplBuff._desc;
            buff._name       = tmplBuff._name;
            buff._type       = tmplBuff._type;
            buff._priority   = tmplBuff._priority;
            buff._stackLimit = tmplBuff._stackLimit;
            buff._lifeTime   = tmplBuff._lifeTime;
            buff._interval   = tmplBuff._interval;
            buff._mods       = SkAttribsModifier.Create(modDesc);
            buff._eff        = tmplBuff._eff;
            buff._effBeg     = tmplBuff._effBeg;
            buff._effEnd     = tmplBuff._effEnd;
            s_SkBuffTbl.Add(buff._id, buff);
            if (s_maxId < buff._id)
            {
                s_maxId = buff._id;
            }
            return(s_maxId);
        }
        public static void LoadData()
        {
            if (s_SkTriggerEventTbl != null)
            {
                return;
            }

            SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("skTriggerEvent");

            //reader.Read(); // skip title if needed
            s_SkTriggerEventTbl = new Dictionary <int, SkTriggerEvent>();
            while (reader.Read())
            {
                SkTriggerEvent skEvent = new SkTriggerEvent();
                skEvent._id = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_id")));

                skEvent._cond       = SkCond.Create(reader.GetString(reader.GetOrdinal("_cond")));
                skEvent._force      = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_force")));
                skEvent._modsCaster = SkAttribsModifier.Create(reader.GetString(reader.GetOrdinal("_modsCaster")));
                skEvent._modsTarget = SkAttribsModifier.Create(reader.GetString(reader.GetOrdinal("_modsTarget")));
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effOnHitCaster"))), out skEvent._effOnHitCaster);
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effOnHitTarget"))), out skEvent._effOnHitTarget);

                try{
                    s_SkTriggerEventTbl.Add(skEvent._id, skEvent);
                }catch (Exception e)     {
                    Debug.LogError("Exception on skTriggerEvent " + skEvent._id + " " + e);
                }
            }
        }
Exemple #3
0
        public static SkAttribsModifier Create(string desc)
        {
            if (desc.Equals("0") || desc.Equals(""))
            {
                return(null);
            }

            SkAttribsModifier modifier = new SkAttribsModifier();

            string[] strMods = desc.Split('#');                 // use this as splitter because it is not used in expression
            foreach (string strMod in strMods)
            {
                string[] descOp = strMod.Split(new Char[] { ',' }, 2);
                switch (descOp[0].ToLower())
                {
                case "mat":     {
                    SkAttribsOpMAT op = new SkAttribsOpMAT(descOp[1]);
                    modifier._tmpOps.Add(op);
                    modifier._tmpOpsIdxs.Add(op._idx);
                }
                break;

                case "mad":
                    modifier._ops.Add(new SkAttribsOpMAD(descOp[1]));
                    break;

                case "exp":
                {
                    SkAttribsOpEXP op = new SkAttribsOpEXP(descOp[1]);
                    if (op._bTmpOp)
                    {
                        modifier._tmpOps.Add(op);
                        modifier._tmpOpsIdxs.Add(op._idx);
                    }
                    else
                    {
                        modifier._ops.Add(op);
                    }
                }
                break;

                case "get":
                    modifier._ops.Add(new SkAttribsOpGET(descOp[1]));
                    break;

                case "rnd":
                    modifier._ops.Add(new SkAttribsOpRND(descOp[1]));
                    break;

                default:
                    Debug.Log("[Error]:Unrecognized atttribModifier." + strMod);
                    continue;
                }
            }
            return(modifier);
        }
Exemple #4
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);
        }
Exemple #5
0
        public static void LoadData()
        {
            if (s_SkBuffTbl != null)
            {
                return;
            }

            SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("skBuff");

            //reader.Read(); // skip title if needed
            s_SkBuffTbl = new Dictionary <int, SkBuff>();
            while (reader.Read())
            {
                SkBuff buff = new SkBuff();
                buff._id         = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_id")));
                buff._desc       = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_desc")));
                buff._icon       = reader.GetString(reader.GetOrdinal("_icon"));
                buff._name       = reader.GetString(reader.GetOrdinal("_name"));
                buff._type       = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_type")));
                buff._priority   = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_priority")));
                buff._stackLimit = Convert.ToInt32(reader.GetString(reader.GetOrdinal("_stackLimit")));
                buff._lifeTime   = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_timeActive")));
                buff._interval   = Convert.ToSingle(reader.GetString(reader.GetOrdinal("_timeInterval")));
                buff._mods       = SkAttribsModifier.Create(reader.GetString(reader.GetOrdinal("_mods")));
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_eff"))), out buff._eff);
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effBeg"))), out buff._effBeg);
                SkEffect.s_SkEffectTbl.TryGetValue(Convert.ToInt32(reader.GetString(reader.GetOrdinal("_effEnd"))), out buff._effEnd);

                try{
                    s_SkBuffTbl.Add(buff._id, buff);
                }catch (Exception e)     {
                    Debug.LogError("Exception on skBuff " + buff._id + " " + e);
                }
                if (s_maxId < buff._id)
                {
                    s_maxId = buff._id;
                }
            }
        }