Example #1
0
        //攻击动画帧事件
        public void Attack()
        {
            Vector3 direction = targetTF.position - transform.position;

            shootingBehavior.Shoot(direction);
            parEffet.Play();
        }
Example #2
0
    void Shoot()
    {
        if (Input.GetAxis(mInput.x) != 0 && b_PlayerBehavior.GetIsTargeting() == true && mIsRangedAttackOnCooldown == false)
        {
            Vector2 direction;

            /*
             * if (Input.GetAxis(mInput.joystickHorizontal) == 0 && Input.GetAxis(mInput.joystickVertical) == 0)
             * {
             *  direction = new Vector2(b_PlayerBehavior.IsFacingDirectionRight() == true ? 1 : -1, 0);
             * }
             * else
             * {
             *  direction = new Vector2(Input.GetAxis(mInput.joystickHorizontal), -Input.GetAxis(mInput.joystickVertical));
             * }
             */
            b_ShootingBehavior.Shoot(transform.position, b_PlayerBehavior.GetTargetingVector(), 25f, 5f);

            //mIsRangedAttackOnCooldown = true;
            StartCoroutine(RangedAttackOnCooldown());
        }

        if (b_PlayerBehavior.GetIsTargeting() == true)
        {
            b_PlayerBehavior.SetCanMeleAttack(false);
        }
        else
        {
            b_PlayerBehavior.SetCanMeleAttack(true);
        }
    }
Example #3
0
    private void Shoot()
    {
        float distanceToTarget = Mathf.Abs(mTargetTransform.position.x - transform.position.x);

        if (distanceToTarget <= mRangedDistance && mIsShootingOnCooldown == false)
        {
            //Debug.Log()
            b_ShootingBehavior.Shoot(transform.position, (mTargetTransform.position - transform.position).normalized, 25f, 5f);

            StartCoroutine(ShootingOnCooldown());
        }
    }
 void Update()
 {
     if (fanTarget.canAttack)
     {
         //攻击
         shootingBehavior.Shoot(Vector2.down);
         fanSprite.transform.Rotate(0, 0, rotateSpeed * 4);
     }
     else
     {
         LoopPatrolling();
     }
 }
 private void Attack()
 {
     if (!isAttacking)
     {
         targetPosition   = GameObject.FindGameObjectWithTag("Player").transform.position;
         isAttacking      = true;
         hasStartShooting = true;
     }
     else if (hasStartShooting && isAttacking)
     {
         shootingDirection = targetPosition - shootingPoint.position;
         hasStartShooting  = !shootingBehavior.Shoot(shootingDirection);
     }
 }
Example #6
0
        private void Update()
        {
            if (movingJoystick.enabled)
            {
                if (movingJoystick.Direction.magnitude > 0.25f)
                {
                    movingBehavior.MoveInDirection(movingJoystick.Direction.x);
                }


                if (Input.GetKey(KeyCode.A))
                {
                    movingBehavior.MoveInDirection(-1);
                }
                else if (Input.GetKey(KeyCode.D))
                {
                    movingBehavior.MoveInDirection(1);
                }

                if (Input.GetKeyDown(KeyCode.Space))
                {
                    movingBehavior.Jump();
                }
            }

            if (shootingJoystick.enabled)
            {
                Vector2 shootingDirection = shootingJoystick.Direction;
                if (shootingDirection.magnitude > 0.5f)
                {
                    shootingBehavior.Shoot(shootingDirection);
                }

                if (movingJoystick.Direction.y > 0.55f && movingJoystick.Direction.magnitude > 0.5f)
                {
                    movingBehavior.Jump();
                }
            }
        }