예제 #1
0
    public override void Init()
    {
        self = GetComponent <HeroFightUnit>();
        /* 自动使用技能,当处于自动战斗或者混乱状态下 */
        self.OnNoramlAttackFinish += ThinkUseSkill;
        /*普通攻击初始化*/
        normalAttack        = NGUITools.AddChild <NormalAttack>(gameObject);
        normalAttack.attack = Util.GetDic <MsgAttackData, AttackData>()[normalAttackId];
        JsonData castEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.castEffect));

        for (int i = 0; i < castEffectDt.Count; i++)
        {
            normalAttack.castEffectIds.Add((int)castEffectDt[i]);
        }
        JsonData flyEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.flyEffect));

        for (int i = 0; i < flyEffectDt.Count; i++)
        {
            normalAttack.flyEffectIds.Add((int)flyEffectDt[i]);
        }
        JsonData hitEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.hitEffect));

        for (int i = 0; i < hitEffectDt.Count; i++)
        {
            normalAttack.hitEffectIds.Add((int)hitEffectDt[i]);
        }
        normalAttack.mineUnit = self;
        normalAttack.Init();
        /*主动技能初始化*/
        normalSkill             = NGUITools.AddChild <ActiveSkill>(gameObject);
        normalSkill.normalSkill = Util.GetDic <MsgNormalSkill, NormalSkill>()[normalSkillId];
        int LvUpId = normalSkillId * 100 + normalSkillLv;

        normalSkill.normalSkillLvUp = Util.GetDic <MsgNormalSkillLvUp, NormalSkillLvUp>()[LvUpId];
        normalSkill.dmgEffectId     = (int)normalSkill.normalSkill.dmgEffect;
        normalSkill.castEffectId    = (int)normalSkill.normalSkill.castEffect;
        normalSkill.flyEffectId     = (int)normalSkill.normalSkill.flyEffect;
        normalSkill.hitEffectId     = (int)normalSkill.normalSkill.hitEffect;
        normalSkill.mineUnit        = self;
        normalSkill.Init();
        /*绝技初始化*/
        specailSkill = NGUITools.AddChild <UniqueSkill>(gameObject);
        specailSkill.specialSkill = Util.GetDic <MsgSpecialSkill, SpecialSkill>()[specailSkillId];
        int specailLvId = specailSkillId * 100 + specailSkillLv;

        specailSkill.specialSkillLvUp = Util.GetDic <MsgSpecialSkillLvUp, SpecialSkillLvUp>()[specailLvId];
        specailSkill.castEffectId     = (int)specailSkill.specialSkill.castEffect;
        specailSkill.dmgEffectId      = (int)specailSkill.specialSkill.dmgEffect;
        specailSkill.flyEffectId      = (int)specailSkill.specialSkill.flyEffect;
        specailSkill.hitEffectId      = (int)specailSkill.specialSkill.hitEffect;
        specailSkill.mineUnit         = self;
        specailSkill.Init();
        /*队长技能初始化*/

        CEventDispatcher.GetInstance().AddEventListener(CEventType.MOVE_TO_NEXT, ResetAutoState);
    }
예제 #2
0
    public override void Init()
    {
        self = GetComponent <MonsterFightUnit>();
        self.OnNoramlAttackFinish += ThinkUseSkill;
        /*普通攻击初始化*/
        normalAttack        = NGUITools.AddChild <NormalAttack>(gameObject);
        normalAttack.attack = Util.GetDic <MsgAttackData, AttackData>()[normalAttackId];
        JsonData castEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.castEffect));

        for (int i = 0; i < castEffectDt.Count; i++)
        {
            normalAttack.castEffectIds.Add((int)castEffectDt[i]);
        }
        JsonData flyEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.flyEffect));

        for (int i = 0; i < flyEffectDt.Count; i++)
        {
            normalAttack.flyEffectIds.Add((int)flyEffectDt[i]);
        }
        JsonData hitEffectDt = JsonMapper.ToObject(Util.GetConfigString(normalAttack.attack.hitEffect));

        for (int i = 0; i < hitEffectDt.Count; i++)
        {
            normalAttack.hitEffectIds.Add((int)hitEffectDt[i]);
        }
        normalAttack.mineUnit = self;
        normalAttack.Init();
        /*主动技能初始化*/
        foreach (int normalSkillId in autoSkillsId)
        {
            ActiveSkill normalSkill = NGUITools.AddChild <ActiveSkill>(gameObject);
            normalSkill.normalSkill  = Util.GetDic <MsgNormalSkill, NormalSkill>()[normalSkillId];
            normalSkill.dmgEffectId  = (int)normalSkill.normalSkill.dmgEffect;
            normalSkill.castEffectId = (int)normalSkill.normalSkill.castEffect;
            normalSkill.flyEffectId  = (int)normalSkill.normalSkill.flyEffect;
            normalSkill.hitEffectId  = (int)normalSkill.normalSkill.hitEffect;
            normalSkill.mineUnit     = self;
            int LvUpId = normalSkillId * 100 + 1;
            normalSkill.normalSkillLvUp = Util.GetDic <MsgNormalSkillLvUp, NormalSkillLvUp>()[LvUpId];
            normalSkill.Init();
            MonsterSkill skillCondition = null;
            Util.GetDic <MsgMonsterSkill, MonsterSkill>().TryGetValue(normalSkillId, out skillCondition);
            SkillCondition condition    = SkillCondition.None;
            int            conditionVal = 0;
            float          minCd        = 0;
            float          maxCd        = 0;
            if (skillCondition != null)
            {
                JsonData dt = JsonMapper.ToObject(Util.GetConfigString(skillCondition.condition));
                if (dt.Count == 2)
                {
                    condition    = (SkillCondition)int.Parse(dt[0].ToString());
                    conditionVal = int.Parse(dt[1].ToString());
                }
                JsonData dt_1 = JsonMapper.ToObject(Util.GetConfigString(skillCondition.interval));
                minCd = float.Parse(dt_1[0].ToString());
                maxCd = float.Parse(dt_1[1].ToString());
            }
            ActiveSkillStruct activeSkillStruct = new ActiveSkillStruct();
            activeSkillStruct.autoSkill          = normalSkill;
            activeSkillStruct.autoSkillCondition = skillCondition;
            activeSkillStruct.condition          = condition;
            activeSkillStruct.conditionVal       = conditionVal;
            activeSkillStruct.minCd = minCd;
            activeSkillStruct.maxCd = maxCd;
            autoSkills.Add(activeSkillStruct);
        }
        enabled = false;
    }