Example #1
0
    public void NextPlayerAction()
    {
        if (!IsMoving())
        {
            if (target != null)
            {
                LookToTarget();

                if (attackController.CanAttack())
                {
                    attackController.Attack(target);
                }
            }
        }

        if (nextOrbSkill == null)
        {
            OrbSkill OrbSkill = GetNextReadyOrbSkill();
            if (OrbSkill != null)
            {
                Debug.Log("next ready orb skill " + OrbSkill.name);
                nextOrbSkill = OrbSkill;
                attackController.CreateOrb(nextOrbSkill);
            }
        }
    }
Example #2
0
 public void Attack(Transform target)
 {
     if (alive && target.gameObject.GetComponent <BasicAI>().isAlive())
     {
         attackController.Attack(target, equipmentHandler.getWeapon());
     }
 }
Example #3
0
    public void OnAttackButtonDown(Vector3 mousePos)
    {
        Vector3 attackDirection = mousePos - transform.position;

        attackController.Attack(ref velocity, attackDirection, controller.collisions.below, mousePos);
        audioSource.PlayOneShot(attackClip);
    }
Example #4
0
 public void Attack()
 {
     if (movementController.IsGrounded && !attackController.IsAttacking)
     {
         attackController.Attack();
         movementController.StopWalking();
         movementController.IsJumpingEnabled = false;
         movementController.IsWalkingEnabled = false;
         animationController.AnimateAttack(() =>
         {
             movementController.IsJumpingEnabled = true;
             movementController.IsWalkingEnabled = true;
             attackController.IsAttacking        = false;
         });
     }
 }
Example #5
0
 void Attacks()
 {
     if (attacksEnabled || queueEnabled)
     {
         //fast attacks
         if (GetInput.bumper_left && GetInput.button_Y_pressed || queueAttackFastUp == true)
         {
             if (!queueEnabled)
             {
                 inAttack = attackController.Attack("FastUp");
             }
             else
             {
                 queueAttackFastUp = true;
             }
         }
     }
 }
Example #6
0
    void CalculateVelocity()
    {
        if (target)
        {
            Vector2      distance       = (target.position - transform.position);
            RaycastHit2D lineOfSight    = Physics2D.Raycast(transform.position, distance.normalized, distance.magnitude, targetMask);
            Collider2D   colliderInView = null;

            Debug.DrawRay(transform.position, distance, Color.blue);

            if (lineOfSight)
            {
                colliderInView = lineOfSight.collider;
            }

            if (colliderInView && colliderInView.tag == target.gameObject.tag)
            {
                Debug.DrawRay(transform.position, distance, Color.green);
                // Chase target
                if (Mathf.Abs(distance.x) < 15 && Mathf.Abs(distance.y) < 15)
                {
                    float targetVelocityX = Mathf.Sign(distance.x) * moveSpeed;
                    velocity.x = Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below) ? accelerationTimeGrounded : accelerationTimeAirborne);

                    if (distance.y >= 0.01 && controller.collisions.below)
                    {
                        velocity.y = 15f;
                    }

                    // Check if the position of the cube and sphere are approximately equal.
                    if (distance.x < attackController.range && distance.y < attackController.range)
                    {
                        // Swap the position of the cylinder.
                        attackController.Attack(ref velocity, distance, controller.collisions.below, target.position);
                    }
                }
            }
        }

        velocity += Vector3.down * gravity * Time.deltaTime;
    }
    private void Charge()
    {
        Vector3 dirToPlayer = m_player.transform.position - transform.position;
        float   dist        = dirToPlayer.magnitude;

        if (dist > m_attackRange)
        {
            m_velocity  = dirToPlayer.normalized;
            m_velocity *= (m_speed * m_runSpeed) * Time.deltaTime;
        }
        else
        {
            if (m_attackController.Attack(false))
            {
                if (m_comboHandler.Attacks >= m_attackLimit)
                {
                    m_state = State.RETREAT;
                    Leap(-transform.forward);
                    m_stateTime            = RandomBetweenRange(m_retreatMinMax, false);
                    m_comboHandler.Attacks = 0;
                }
            }
        }
    }
Example #8
0
 public void MakeHit()
 {
     AttackCtrl.Attack(gameObject, Hero.gameObject, WeaponCtrl.GetCurrentWeapon());
 }