void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Fireball")
        {
            //Debug.Log ("Hit Player");

            playerDead  = true;
            rb.velocity = new Vector2(0, rb.velocity.y);

            flashColor.StartSwicthing();
            deathShaker.StartShaking(deathAnimationDuration);

            Destroy(other.gameObject);
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < stageColliders.Length; i++)
        {
            if (stageColliders [i].IsTouching(playerCollider))
            {
                if (i == 0)
                {
                    playerStage = Stages.UpperLeft;
                }
                if (i == 1)
                {
                    playerStage = Stages.LowerLeft;
                }
                if (i == 2)
                {
                    playerStage = Stages.LowerMiddle;
                }
                if (i == 3)
                {
                    playerStage = Stages.UpperMiddle;
                }
                if (i == 4)
                {
                    playerStage = Stages.UpperRight;
                }
                if (i == 5)
                {
                    playerStage = Stages.LowerRight;
                }
            }
        }

        if (!attacking)
        {
            pauseTimer += Time.deltaTime;
            if (pauseTimer > pauseTimeLength)             //ATTACK STARTING
            {
                animator.Play("PickleFireball");
                //animator.Play ("NewFireballAnimation");
                attacking  = true;
                pauseTimer = 0.0f;

                //What attack are we doing?
                fireballShooter.StartFireball(amountOfAttacks % 3);
            }
        }
        else
        {
            attackTimer += Time.deltaTime;
            if (attackTimer > attackTimeLength)             //ATTACK ENDING
            {
                animator.Play("PickleIdleAnimation");
                attacking   = false;
                attackTimer = 0.0f;

                //What attack are we stopping?
                fireballShooter.StopFireball(amountOfAttacks % 3);

                amountOfAttacks++;
            }
        }

        if (bossHealth == 0)
        {
            bossDead = true;
            flashColor.StartSwicthing();
            deathShaker.StartShaking(deathAnimationLength);
            animator.Play("PickleDead");
        }

        if (bossDead)
        {
            deathAnimationTimer += Time.deltaTime;

            if (deathAnimationTimer > deathAnimationLength)
            {
                SceneManager.LoadScene("Victory");
                Debug.Log("Death Animation Over");
            }
        }
    }