コード例 #1
0
    public override void Release()
    {
        if (!active)
        {
            return;
        }
        active = false;
        if (chargeCoroutine != null)
        {
            StopCoroutine(chargeCoroutine);
        }
        animator.SetBool("Charge", false);
        chargeEffect.Stop();
        chargeAudio.Stop();
        shootAudio.Play();
        releaseEffect.Play();

        Vector2 pushback = Vector2.down * charge * 4;

        rb.velocity = RaposUtil.RotateVector(pushback, transform.rotation.eulerAngles.z) + Vector2.up;

        Bullet b = currentBullet.GetComponent <Bullet>();

        if (b)
        {
            Vector3 velocity = Vector3.up * 10;
            velocity = RaposUtil.RotateVector(velocity, transform.rotation.eulerAngles.z);
            b.ShootSetup(playerID, 1, velocity / 10, (1 - (.7f * charge)) * velocity);
            b.ReturnToLegalCustody();
        }
        currentBullet = null;
        StartCoroutine(RotationLock());
    }
コード例 #2
0
    private IEnumerator Shake()
    {
        transform.position += RaposUtil.RotateVector(Vector3.up, Random.Range(0, 360)) * .05f;
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        transform.position = originalPosition;
    }
コード例 #3
0
 private void FixedUpdate()
 {
     if (target != null)
     {
         Vector3 posDiff = target.position - transform.position;
         transform.DORotate(new Vector3(0, 0, (Mathf.Atan2(posDiff.y, posDiff.x) * Mathf.Rad2Deg) + 180), rotationTime);
     }
     m_rigidbody.velocity = RaposUtil.RotateVector(Vector3.left * speed, transform.rotation.eulerAngles.z);
 }
コード例 #4
0
    public Vector2 GetPush()
    {
        bumpEffect.Play();
        bumpAudio.Play();
        StartCoroutine(Bump());
        Vector2 pushDirection = RaposUtil.RotateVector(Vector3.up, transform.rotation.eulerAngles.z);

        return(pushDirection * force);
    }
コード例 #5
0
 IEnumerator LookAround()
 {
     while (true)
     {
         currentRotation += Random.Range(0, 6) * 45;
         Vector2 direction = RaposUtil.RotateVector(Vector2.up, currentRotation);
         SpinComponents(direction);
         yield return(new WaitForSeconds(Random.Range(.5f, 1.5f)));
     }
 }
コード例 #6
0
    private IEnumerator HoverEvent()
    {
        while (true)
        {
            yield return(new WaitForFixedUpdate());

            Vector3 movementIntensity = Vector3.up * 15;
            rb.AddForce(RaposUtil.RotateVector(movementIntensity, transform.rotation.eulerAngles.z));
        }
    }
コード例 #7
0
    IEnumerator LineMovement(float speed)
    {
        Vector3 movementIntensity = Vector3.up * speed;

        rb.gravityScale = 0;
        rb.velocity     = RaposUtil.RotateVector(movementIntensity, transform.rotation.eulerAngles.z);
        yield return(new WaitForSeconds(.1f));

        rb.gravityScale = gravityScale;
        rb.velocity     = Vector2.zero;
    }
コード例 #8
0
    private void OnEnable()
    {
        m_renderer = GetComponent <SpriteRenderer>();
        m_collider = GetComponent <BoxCollider2D>();

        m_collider.size = m_renderer.size;

        targetPosition  = RaposUtil.RotateVector(Vector3.right * (m_renderer.size / 2), transform.rotation.eulerAngles.z);
        startPosition   = transform.position - targetPosition;
        targetPosition += transform.position;
        moveDirection   = (targetPosition - startPosition).normalized;

        tag = "Zipline";
    }
コード例 #9
0
    private void Shoot()
    {
        m_animator.SetTrigger("Shoot");
        shotFX.Play();

        GameObject bulletObject = pool.Get();

        bulletObject.transform.position = transform.position;
        bulletObject.SetActive(true);

        CannonBall bulletScript = bulletObject.GetComponent <CannonBall>();

        bulletScript.Launch(RaposUtil.RotateVector(Vector2.up, transform.rotation.eulerAngles.z) * bulletSpeed);
    }
コード例 #10
0
    public override void Call()
    {
        if (detached || buttonHeld)
        {
            return;
        }
        buttonHeld = true;
        //attackAudio.Play();

        Vector2 velocity = Vector3.up * 10;

        velocity = RaposUtil.RotateVector(velocity, transform.rotation.eulerAngles.z);
        blade.Launch(this, velocity + rb.velocity);
        detached = true;
    }
コード例 #11
0
    protected override IEnumerator AttackCicle()
    {
        yield return(new WaitForSeconds(.5f));

        offsetCicle = false;

        while (true)
        {
            spawnedBullets = new List <Bullet>();

            m_animator.SetInteger("State", 1);

            for (int i = 0; i < bulletsPerCicle; i++)
            {
                GameObject bulletObject = pool.Get();
                BulletLine bullet       = bulletObject.GetComponent <BulletLine>();
                if (bullet)
                {
                    bulletObject.SetActive(true);
                    Vector2 direction = RaposUtil.RotateVector(Vector3.up, i * (360 / bulletsPerCicle) + (offsetCicle ? (180 / bulletsPerCicle) : 0));

                    bulletObject.transform.rotation = Quaternion.Euler(Vector3.forward * (Vector2.SignedAngle(Vector2.up, direction) + 90));
                    bulletObject.transform.position = transform.position;
                    InheritAnchorMovement inheritAnchorMovement = bullet.GetComponent <InheritAnchorMovement>();
                    if (inheritAnchorMovement != null)
                    {
                        inheritAnchorMovement.enabled = true;
                        inheritAnchorMovement.Set(transform);
                    }
                    bullet.StartCoroutine(PositionBullet(bulletObject.transform, (Vector3)(direction * 1f)));

                    spawnedBullets.Add(bullet);
                    yield return(new WaitForSeconds(.03f));
                }
            }

            yield return(new WaitForSeconds(.5f));

            ReleaseBullets();
            m_animator.SetInteger("State", 2);

            yield return(new WaitForSeconds(1));

            offsetCicle = !offsetCicle;
        }
    }
コード例 #12
0
    private void ReleaseBullets()
    {
        for (int i = 0; i < spawnedBullets.Count; i++)
        {
            Bullet bullet = spawnedBullets[i];
            if (bullet != null && bullet.isActiveAndEnabled)
            {
                InheritAnchorMovement inheritAnchorMovement = bullet.GetComponent <InheritAnchorMovement>();
                if (inheritAnchorMovement != null)
                {
                    inheritAnchorMovement.enabled = false;
                }

                Vector2 direction = RaposUtil.RotateVector(Vector3.up, i * (360 / bulletsPerCicle) + (offsetCicle ? (180 / bulletsPerCicle) : 0));
                bullet.Launch(direction * bulletSpeed);
            }
        }
    }
コード例 #13
0
    private void SuicideShots()
    {
        int max = 8;

        for (int i = 0; i < max; i++)
        {
            GameObject bulletObject = pool.Get();
            BulletLine bullet       = bulletObject.GetComponent <BulletLine>();
            if (bullet)
            {
                bulletObject.SetActive(true);
                Vector2 direction = RaposUtil.RotateVector(Vector2.up, (360 / max) * i);

                bullet.Launch(direction * bulletSpeed);
                bulletObject.transform.position = transform.position;
            }
        }
    }
コード例 #14
0
    private void FixedUpdate()
    {
        float directionModifier = facingLeft ? 1 : -1;

        switch (state)
        {
        case State.Idle:
            if (!stunned && diveAttack)
            {
                if (Physics2D.BoxCast(transform.position + new Vector3(raycastOffset.x * directionModifier, raycastOffset.y),
                                      raycastSize,
                                      0, Vector2.one, 0,
                                      1 << LayerMask.NameToLayer("Player")))
                {
                    windUpCoroutine = StartCoroutine(WindUpAnimation());
                }
            }
            break;

        case State.Diving:
            m_rigidbody.velocity = direction * diveSpeed;
            float diff = Mathf.Abs(transform.rotation.eulerAngles.z - targetRotation);
            if (diff > Mathf.Abs(rotationSpeed))
            {
                transform.Rotate(Vector3.forward * rotationSpeed * -directionModifier);
                direction = RaposUtil.RotateVector(direction, rotationSpeed * -directionModifier);
            }
            else
            {
                state = State.Attacking;
            }
            break;

        case State.Attacking:
            m_rigidbody.velocity = direction * diveSpeed;
            break;
        }
    }
コード例 #15
0
    public override void Release()
    {
        if (!active)
        {
            return;
        }
        active = false;

        UpdateChargeArrow(0);
        chargePS.Stop();
        launchPS.Play();
        chargeAudio.Stop();
        launchAudio.Play();
        animator.SetBool("Charge", false);
        if (chargeCoroutine != null)
        {
            StopCoroutine(chargeCoroutine);
        }
        Vector3 movementIntensity = Vector3.up * charge;

        rb.velocity  = RaposUtil.RotateVector(movementIntensity, transform.rotation.eulerAngles.z);
        rotationLock = false;
        StartCoroutine(CooldownTimer());
    }