Exemplo n.º 1
0
    public override void Tick()
    {
        for (int i = _skillAttackList.Count - 1; i >= 0; i--)
        {
            UnitSkillAttackBase attackEffect = _skillAttackList[i];

            if (attackEffect.Tick())
            {
                // delete
                _skillAttackList.RemoveAt(i);
            }
        }

        // 少一个距离的判断,如果打的过程中,目标走了
        if (!_checkTargetAlive())
        {
            UnitAIIdleState state = new UnitAIIdleState();

            unit.State = state;

            return;
        }

        if (attackFrameCounter > 0)
        {
            --attackFrameCounter;
        }

        if (attackFrameCounter == 0)
        {
            _doAttack();

            attackFrameCounter = unit.AttackSpeed;
        }
    }
Exemplo n.º 2
0
    private void _doAttack()
    {
        UnitSkillAttackBase attackEffect = null;

        // 获得att配置信息
        SkillAttackFlyAttributeConfig.SkillAttackFlyAttribute data = SkillAttackFlyAttributeConfig.GetSkillAttackFlyAttribute(unit.AttackSkillAttackID);


        switch (data.FlyType)
        {
        case 0:
        {
            // no fly
            attackEffect = new UnitSkillAttackBase();

            attackEffect.ForwardFrame = data.ForwardFrame;
            attackEffect.Caster       = unit;
            attackEffect.Target       = unit.Target;
            attackEffect.IsFly        = data.IsFly;
            attackEffect.Speed        = data.Speed;
        }
        break;

        case 1:
        {
            // straight line
            attackEffect = new UnitSkillAttackStraightLine();

            attackEffect.ForwardFrame = data.ForwardFrame;
            attackEffect.Caster       = unit;
            attackEffect.Target       = unit.Target;
            attackEffect.IsFly        = data.IsFly;
            attackEffect.Speed        = data.Speed;
        }
        break;

        default:
        {
            Debug.LogError(" 攻击没有飞行类型: " + unit.AttackSkillAttackID);
        }
        break;
        }

        if (attackEffect != null)
        {
            _skillAttackList.Add(attackEffect);
            // 表现层接口
            Launch.battleplayer.Attack(battle.Frame, unit, unit.Target);
        }
    }