Ejemplo n.º 1
0
    public override void ReleaseSpell()
    {
        GameObject target = thunderAbility.GetClosestTargetInList(thunderAbility.GetTargetInThunderCircle());

        if (target != null)
        {
            Vector2 targetPosition = target.transform.position;
            targetPosition.x += target.transform.localScale.x < 0 ? 2 : -2;
            movementPlayer.RequestMoveByFrame(targetPosition, MovementPlayer.MovementMode.Ability, Space.World);
            canFight.Attack(target.GetComponent <CanBeFighted>(), 1, AttackInterruptType.WEAK, ElementAbilityManager.Element.Ice);
        }
        //播放攻击动画
    }
Ejemplo n.º 2
0
    public void ThunderLinkClock()
    {
        if (isThunderLink)
        {
            if (thunderLinkAttackedTimes >= thunderLinkAttackTotalTimes)
            {
                isThunderLink = false;
                //关闭spell
                thunderLinkCurTime       = 0f;
                thunderLinkAttackedTimes = 0;
                thunderLinkHasAttackedList.Clear();
                thunderLinkScript.gameObject.SetActive(false);
                Debug.Log("闪电链攻击达到上限次数,结束");
            }

            thunderLinkCurTime += Time.deltaTime;
            if (thunderLinkCurTime >= thunderLinkIntervalTime)
            {
                //执行spell
                thunderLinkCurTime = 0f;
                thunderLinkAttackedTimes++;

                Except(thunderAbility.GetTargetInThunderCircle(), thunderLinkHasAttackedList, out tempTargetsInThunderCircle);
                GameObject target = thunderAbility.GetClosestTargetInList(tempTargetsInThunderCircle);
                if (target != null)
                {
                    thunderLinkHasAttackedList.Add(target);
                }
                tempTargetsInThunderCircle = null;


                //如果当前找不到敌人,则终止闪电链技能
                if (target == null)
                {
                    isThunderLink            = false;
                    thunderLinkCurTime       = 0f;
                    thunderLinkAttackedTimes = 0;
                    thunderLinkHasAttackedList.Clear();
                    thunderLinkScript.gameObject.SetActive(false);
                    Debug.Log("闪电链攻击找不到敌人,结束");
                }
                else
                {
                    //通知函数
                    Debug.Log("闪电链攻击敌人:" + target.gameObject.name);
                    thunderLinkScript.SetTarget(target);
                }
            }
        }
    }
Ejemplo n.º 3
0
    //雷主长按施法动画调用帧事件 SkillEvent()再调用 ThunderLongMainCheckEvent() 用于找到可以击中的目标
    public override void ReleaseSpell()
    {
        GameObject target = thunderAbility.GetClosestTargetInList(
            thunderAbility.GetTargetInThunderCircle());

        if (target != null)
        {
            //雷击启动
            thunderLongMain.transform.position = target.transform.position;
            thunderLongMain.SetActive(true);
            Debug.Log("雷主长按打到的怪物: " + target.name);
        }
        else
        {
            Debug.Log("雷圈范围内没有敌人");
        }
    }
Ejemplo n.º 4
0
    public void AutoAttack()
    {
        if (isChasingTarget)
        {
            if (nextTarget.GetInstanceID() == player.GetInstanceID())
            {
                //追踪敌人
                temp = thunderAbility.GetClosestTargetInList(thunderAbility.GetTargetInThunderCircle());
                if (temp != null)
                {
                    nextTarget = temp;
                }
            }
            transform.position =
                Vector2.MoveTowards(transform.position, nextTarget.transform.position, ElfChasinSpeed * Time.deltaTime);
            if (Vector2.Distance(transform.position, nextTarget.transform.position) < 0.02f)
            {
                isChasingTarget = false;
            }
        }
        else
        {
            transform.position = nextTarget.transform.position;

            if (nextTarget.GetInstanceID() == player.GetInstanceID())
            {
                //追踪敌人
                temp = thunderAbility.GetClosestTargetInList(thunderAbility.GetTargetInThunderCircle());
                if (temp != null)
                {
                    nextTarget      = temp;
                    isChasingTarget = true;
                }
            }
            //如果当前依附的单位已经死亡,则寻找下一个单位,如果没有,则追踪主角
            else if (nextTarget == null || nextTarget.activeSelf == false || attackCurNumber >= attackTotalNumber)
            {
                temp = thunderAbility.GetClosestTargetInList(thunderAbility.GetTargetInThunderCircle());
                if (temp != null)
                {
                    nextTarget = temp;
                }
                else
                {
                    nextTarget = player;
                }
                //清空攻击数据并进入追踪态
                isChasingTarget = true;
                attackCurNumber = 0;
                attackTimeCur   = 0f;
            }
            else
            {
                attackTimeCur += Time.deltaTime;
                if (attackTimeCur >= attackTimeDelta)
                {
                    playerHand.Attack(nextTarget.GetComponent <CanBeFighted>(), 1, AttackInterruptType.WEAK);
                    attackTimeCur = 0f;
                    attackCurNumber++;
                }
            }
        }
    }