예제 #1
0
    public Buff(int id)
    {
        if (CfgManager.GetInstance().Buffs.ContainsKey(id) == false)
        {
            Debug.LogErrorFormat("buff cfg not found: {0}", id);
            return;
        }

        cfg     = CfgManager.GetInstance().Buffs[id];
        this.id = cfg.id;

        if (cfg.operation == BuffOperation.OPERATION_HP ||
            cfg.operation == BuffOperation.OPERATION_SP ||
            cfg.operation == BuffOperation.OPERATION_DAMAGE)
        {
            bPeriod     = true;
            periodTimer = cfg.life / cfg.args[0];
        }
    }
예제 #2
0
    public void Init()
    {
        // monster
        TextAsset asset = ResourceManager.Instance.LoadAsset("cfg/monster") as TextAsset;
        JsonData  data  = JsonMapper.ToObject(asset.text);

        foreach (string key in data.Keys)
        {
            JsonData   value = data [key];
            CfgMonster cfg   = new CfgMonster();
            cfg.id     = int.Parse(key);
            cfg.name   = (string)value["name"];
            cfg.prefab = (string)value["prefab"];
            m_Monsters.Add(cfg.id, cfg);
        }

        // skill
        asset = ResourceManager.Instance.LoadAsset("cfg/skill") as TextAsset;
        data  = JsonMapper.ToObject(asset.text);
        foreach (string key in data.Keys)
        {
            JsonData value = data [key];
            CfgSkill cfg   = new CfgSkill();
            cfg.id         = int.Parse(key);
            cfg.name       = (string)value["name"];
            cfg.desc       = (string)value["desc"];
            cfg.animation  = (string)value["animation"];
            cfg.effect     = (string)value["effect"];
            cfg.sound      = (string)value["sound"];
            cfg.hiteffect  = (string)value["hiteffect"];
            cfg.spcost     = (int)value["spcost"];
            cfg.colddown   = (int)value["colddown"] / 1000f;
            cfg.targettype = (SkillTarget)(int)value["targettype"];
            cfg.aoe        = (byte)value["aoe"];
            JsonData effects = value["skilleffect"];
            cfg.skilleffects = new int[effects.Count];
            for (int i = 0; i < effects.Count; i++)
            {
                cfg.skilleffects[i] = (int)effects[i];
            }
            JsonData points = value["hitpoint"];
            cfg.hitpoints = new int[points.Count];
            for (int i = 0; i < points.Count; i++)
            {
                cfg.hitpoints[i] = (int)points[i];
            }

            m_Skills.Add(cfg.id, cfg);
        }

        // skill effect
        asset = ResourceManager.Instance.LoadAsset("cfg/skilleffect") as TextAsset;
        data  = JsonMapper.ToObject(asset.text);
        foreach (string key in data.Keys)
        {
            JsonData       value = data [key];
            CfgSkillEffect cfg   = new CfgSkillEffect();
            cfg.id        = int.Parse(key);
            cfg.name      = (string)value["name"];
            cfg.trigger   = (SkillEffectTrigger)(int)value["trigger"];
            cfg.operation = (SkillEffectOperation)(int)value["operation"];
            JsonData args = value["args"];
            cfg.args = new int[args.Count];
            for (int i = 0; i < args.Count; i++)
            {
                cfg.args[i] = (int)args[i];
            }
            m_SkillEffects.Add(cfg.id, cfg);
        }

        // skill summon
        asset = ResourceManager.Instance.LoadAsset("cfg/skillsummon") as TextAsset;
        data  = JsonMapper.ToObject(asset.text);
        foreach (string key in data.Keys)
        {
            JsonData       value = data [key];
            CfgSkillSummon cfg   = new CfgSkillSummon();
            cfg.id        = int.Parse(key);
            cfg.name      = (string)value["name"];
            cfg.prefab    = (string)value["prefab"];
            cfg.speed     = (int)value["speed"];
            cfg.life      = (int)value["life"] / 1000f;
            cfg.hitmax    = (int)value["hitmax"];
            cfg.hiteffect = (string)value["hiteffect"];
            JsonData effects = value["skilleffect"];
            cfg.skilleffects = new int[effects.Count];
            for (int i = 0; i < effects.Count; i++)
            {
                cfg.skilleffects[i] = (int)effects[i];
            }
            m_SkillSummons.Add(cfg.id, cfg);
        }

        // buff
        asset = ResourceManager.Instance.LoadAsset("cfg/buff") as TextAsset;
        data  = JsonMapper.ToObject(asset.text);
        foreach (string key in data.Keys)
        {
            JsonData value = data [key];
            CfgBuff  cfg   = new CfgBuff();
            cfg.id        = int.Parse(key);
            cfg.name      = (string)value["name"];
            cfg.prefab    = (string)value["prefab"];
            cfg.life      = (int)value["life"] / 1000f;
            cfg.operation = (BuffOperation)(int)value["operation"];
            JsonData args = value["args"];
            cfg.args = new int[args.Count];
            for (int i = 0; i < args.Count; i++)
            {
                cfg.args[i] = (int)args[i];
            }
            m_Buffs.Add(cfg.id, cfg);
        }
    }