예제 #1
0
    void Update()
    {
        for (int i = lstStates.Count - 1; i >= 0; i--)
        {
            SkillState state = lstStates[i];
            if (state.actor.IsAlive() == false)
            {
                lstStates.RemoveAt(i);
                continue;
            }

            Skill             skill = state.skill;
            AnimatorStateInfo cur   = state.actor.Animator.GetCurrentAnimatorStateInfo(0);
            if (cur.IsName(skill.AnimationName))                // 播放中
            {
                float time = cur.normalizedTime;

                // check all effects
                for (int j = 0; j < skill.HitPoints.Length; j++)
                {
                    float t = skill.HitPoints[j] * 0.01f;
                    if (t <= time && t > state.time)
                    {
                        for (int k = 0; k < skill.skilleffects.Length; k++)
                        {
                            SkillEffect effect = skill.skilleffects[k];
                            if (effect.CheckTrigger(SkillEffectTrigger.SKILL_EFFECT_TRIGGER_HITPOINT))
                            {
                                effect.DoEffect(state.actor);
                            }
                        }
                    }
                }
                state.time = time;
            }
            else                 // 播放结束
            {
                if (state.time > 0.5f)
                {
                    for (int j = 0; j < skill.skilleffects.Length; j++)
                    {
                        SkillEffect effect = skill.skilleffects[j];
                        if (effect.CheckTrigger(SkillEffectTrigger.SKILL_EFFECT_TRIGGER_END))
                        {
                            effect.DoEffect(state.actor);
                        }
                    }
                    lstStates.RemoveAt(i);
                }
            }
        }
    }
예제 #2
0
    public void AddSkillState(Character actor, Skill skill)
    {
        SkillState state = new SkillState();

        state.actor = actor;
        state.skill = skill;

        // check start
        for (int i = 0; i < skill.skilleffects.Length; i++)
        {
            SkillEffect effect = skill.skilleffects[i];
            if (effect.CheckTrigger(SkillEffectTrigger.SKILL_EFFECT_TRIGGER_START))
            {
                effect.DoEffect(actor);
            }
        }

        lstStates.Add(state);
    }
예제 #3
0
    // 攻击
    void OnAttack(Character actor)
    {
        if (actor.LastSummonID == ID)
        {
            return;
        }

        actor.LastSummonID = ID;
        actor.ActHit();
        if (actor is Enemy)
        {
            BattleManager.GetInstance().EnemyHit(actor.ID, owner.ID);
        }
        else
        {
            BattleManager.GetInstance().PlayerHit(actor.ID, owner.ID);
        }
        actor.AttackEffect(cfg.hiteffect, 1, new Vector3(0, 0.5f, 0));

        for (int i = 0; i < skilleffects.Length; i++)
        {
            SkillEffect effect = skilleffects[i];
            if (effect.CheckTrigger(SkillEffectTrigger.SKILL_EFFECT_TRIGGER_HIT))
            {
                effect.DoEffect(owner, actor);
            }
        }

        hitcount++;

        // limit attack count
        if (cfg.hitmax != 0 && hitcount >= cfg.hitmax)
        {
            End();
        }
    }