Ejemplo n.º 1
0
    void ScatterShot()
    {
        Debug.Log("Holey Shoot");
        int direction = 1;

        if (!spriteRenderer.flipX)
        {
            direction = 1;
        }

        else
        {
            direction = -1;
        }

        EB1 = Instantiate(bullet, this.gameObject.transform);
        EB1.GetComponent <EnemyBullet>().velX = -15.0f * direction;
        EB1.GetComponent <EnemyBullet>().velY = 0.0f;
        EB2 = Instantiate(bullet, this.gameObject.transform);
        EB2.GetComponent <EnemyBullet>().velX = -10.6f * direction;
        EB2.GetComponent <EnemyBullet>().velY = 10.6f;
    }
Ejemplo n.º 2
0
    public IEnumerator FlyingAttack()
    {
        int choseDirection = Random.Range(-1, 2);

        gameObject.GetComponent <Rigidbody2D>().gravityScale = 0.0f;

        switch (choseDirection)
        {
        case 1:
            targetPos = new Vector2(6, 4);
            gameObject.GetComponent <SpriteRenderer>().flipX = false;
            whip.gameObject.transform.localScale             = new Vector2(-1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(0.5f, 0);
            break;

        case -1:
            targetPos = new Vector2(-6, 4);
            gameObject.GetComponent <SpriteRenderer>().flipX = true;
            whip.gameObject.transform.localScale             = new Vector2(1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(-0.5f, 0);
            break;

        default:
            targetPos = new Vector2(6 * choseDirection, 4);
            gameObject.GetComponent <SpriteRenderer>().flipX = false;
            whip.gameObject.transform.localScale             = new Vector2(-1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(0.5f, 0);
            if (choseDirection < 0)
            {
                gameObject.GetComponent <SpriteRenderer>().flipX = true;
                whip.gameObject.transform.localScale             = new Vector2(1, 1);
                whip.gameObject.transform.localPosition          = new Vector2(-0.5f, 0);
            }
            break;
        }

        Vector3 startingPos = transform.position;
        float   t           = 0.0f;

        while (t < 1.0f)
        {
            t += Time.deltaTime;
            transform.position = Vector3.Lerp(startingPos, targetPos, t);
            yield return(0);
        }

        switch (choseDirection)
        {
        case 1:
            gameObject.GetComponent <SpriteRenderer>().flipX = true;
            whip.gameObject.transform.localScale             = new Vector2(1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(-0.5f, 0);
            break;

        case -1:
            gameObject.GetComponent <SpriteRenderer>().flipX = false;
            whip.gameObject.transform.localScale             = new Vector2(-1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(0.5f, 0);
            break;

        default:
            gameObject.GetComponent <SpriteRenderer>().flipX = true;
            whip.gameObject.transform.localScale             = new Vector2(1, 1);
            whip.gameObject.transform.localPosition          = new Vector2(-0.5f, 0);
            if (choseDirection < 0)
            {
                gameObject.GetComponent <SpriteRenderer>().flipX = false;
                whip.gameObject.transform.localScale             = new Vector2(-1, 1);
                whip.gameObject.transform.localPosition          = new Vector2(0.5f, 0);
            }
            else if (choseDirection == 0)
            {
                if (player.transform.position.x > gameObject.transform.position.x)
                {
                    gameObject.GetComponent <SpriteRenderer>().flipX = false;
                    whip.gameObject.transform.localScale             = new Vector2(-1, 1);
                    whip.gameObject.transform.localPosition          = new Vector2(0.5f, 0);
                }
                else
                {
                    gameObject.GetComponent <SpriteRenderer>().flipX = true;
                    whip.gameObject.transform.localScale             = new Vector2(1, 1);
                    whip.gameObject.transform.localPosition          = new Vector2(-0.5f, 0);
                }
            }
            break;
        }
        animator.SetBool("Attack", true);
        GameObject EB1, EB2, EB3;

        int direction = 1;

        if (!bossRenderer.flipX)
        {
            direction = -1;
        }

        else
        {
            direction = 1;
        }

        EB1 = Instantiate(shockBullet, this.gameObject.transform);
        EB1.GetComponent <EnemyBullet>().velX = -8.9f * direction;
        EB1.GetComponent <EnemyBullet>().velY = -18;

        yield return(new WaitForSeconds(0.6f));

        EB2 = Instantiate(shockBullet, this.gameObject.transform);
        EB2.GetComponent <EnemyBullet>().velX = -20f * direction;
        EB2.GetComponent <EnemyBullet>().velY = -20f;

        yield return(new WaitForSeconds(0.6f));

        EB3 = Instantiate(shockBullet, this.gameObject.transform);
        EB3.GetComponent <EnemyBullet>().velX = -18f * direction;
        EB3.GetComponent <EnemyBullet>().velY = -8.9f;

        yield return(new WaitForSeconds(0.6f));


        gameObject.GetComponent <Rigidbody2D>().gravityScale = 1.0f;
        animator.SetBool("Attack", false);
        yield return(new WaitForSeconds(2));

        StopCoroutine(pattern);
        PatternChange(2);
    }