Пример #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Transform player = collision.transform;

        if (player.gameObject.name == "Player")
        {
            //Debug.Log("碰到了主角!");
            canFight.Attack(player.GetComponent <CanBeFighted>(), damage, AttackInterruptType.WEAK);
            attackComponent.isHitPlayer = true;
            player.GetComponent <CanBeFighted>().BeatBack(transform, interruptTime, interruptVector);
        }
    }
Пример #2
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);
        }
        //播放攻击动画
    }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //层级检测
     if (speed > 0 && layers.Contains(collision.gameObject.layer))
     {
         //检测是否可以被攻击
         CanBeFighted beFought;
         if (collision.TryGetComponent <CanBeFighted>(out beFought))
         {
             canFight.Attack(beFought, damage);
             Debug.Log(gameObject.name + "攻击到了" + beFought.gameObject.name);
         }
     }
 }
Пример #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //撞到人,造成伤害
        CanBeFighted beFought;

        if (collision.TryGetComponent <CanBeFighted>(out beFought))
        {
            //不可对同一目标造成2次伤害
            if (!fought.Contains(beFought))
            {
                throwerHand.Attack(beFought, damage);
                fought.Add(beFought);
                Debug.Log("Dart对" + beFought.name + "造成伤害");
            }
        }
    }
Пример #5
0
 private void MoveToTarget()
 {
     transform.Translate(Vector2.ClampMagnitude(nextTarget.transform.position - transform.position, speed * Time.deltaTime), Space.Self);
     if (Vector2.Distance(nextTarget.transform.position, transform.position) < 0.05f)
     {
         //transform.SetParent(nextTarget.transform);
         if (nextTarget.TryGetComponent(out targetFought))
         {
             canFight.Attack(targetFought, 2);
         }
         else
         {
             Debug.LogError("闪电链攻击到的" + nextTarget.name + "中,没有CanBeFighted组件!");
         }
         isReachedTarget = true;
     }
 }
Пример #6
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++;
                }
            }
        }
    }
Пример #7
0
 public override void ReleaseSpell()
 {
     canFight.Attack(canBeFighted, defencePlayer.getHp());
     //启动爆炸特效
 }