Exemplo n.º 1
0
    // Damages enemy and handles death shit
    public void Damage(float damageTaken)
    {
        if (!isTeleporting)
        {
            currentHealth -= damageTaken;
            if (currentHealth <= phaseHealth[currentPhase + 1])
            {
                isTeleporting = true;
                currentHealth = phaseHealth[currentPhase + 1];

                Instantiate(teleportEffect, transform.position, Quaternion.identity);
                EnemySpawnController spawnController = gameManager.GetComponent <EnemySpawnController>();
                transform.position = spawnController.PickSpawnPointFurthestFromPlayer();
                Instantiate(teleportEffect, transform.position, Quaternion.identity);

                currentPhase++;
                isTeleporting = false;
            }
        }
        if (currentHealth <= 0f && !isDead)
        {
            isDead = true;
            GameObject explosionEffect = Instantiate(explosion, transform.position, Quaternion.identity);
            explosionEffect.transform.localScale = new Vector3(explosionEffect.transform.localScale.x * 2, explosionEffect.transform.localScale.y * 2, explosionEffect.transform.localScale.z * 2);
            garbageScript.SpawnAtLocation(1, transform.position.x, transform.position.y, false);
            gameManager.DecreaseBossCount();
            Destroy(leftSpikeBall);
            Destroy(rightSpikeBall);
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
 // Damages enemy and handles death shit
 public void Damage(float damageTaken)
 {
     currentHealth -= damageTaken;
     if (currentHealth <= 0f && !isDead)
     {
         isDead = true;
         Instantiate(explosion, transform.position, Quaternion.identity);
         garbageScript.SpawnAtLocation(GarbageSpawnController.CIRCLE_GARBAGE_INDEX, transform.position.x, transform.position.y, false);
         gameManager.DecreaseEnemyCount();
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
 // Damages enemy and handles death shit
 public void Damage(float damageTaken)
 {
     // Damages enemy and handles death shit
     currentHealth -= damageTaken;
     if (currentHealth <= 0f && !isDead)
     {
         isDead = true;
         Instantiate(explosion, transform.position, Quaternion.identity);
         garbageScript.SpawnAtLocation(1, transform.position.x, transform.position.y, false);
         gameManager.DecreaseEnemyCount();
         Destroy(gameObject);
     }
 }
Exemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         other.gameObject.GetComponent <PlayerController>().Damage(damage);
         Destroy(gameObject);
     }
     else if (other.gameObject.tag == "Wall")
     {
         garbageController.SpawnAtLocation(GarbageSpawnController.CIRCLE_GARBAGE_INDEX, transform.position.x, transform.position.y, false);
         Destroy(gameObject);
     }
 }
Exemplo n.º 5
0
    void FixedUpdate()
    {
        if (firstphase)
        {
            if (castTimer < 0)
            {
                CastSpell();
                castTimer  -= TimerReset;
                TimerReset -= 0.5f;
            }

            if (transform.position.x > 12)
            {
                MoveRight = -1f;
            }
            else if (transform.position.x < -12)
            {
                MoveRight = 1f;
            }

            if (transform.position.y > 20)
            {
                MoveUp = -1f;
            }
            else if (transform.position.y < 14)
            {
                MoveUp = 1f;
            }

            if (!DuringCast)
            {
                castTimer -= Time.fixedDeltaTime;
                Move();
            }
            if (DuringCast)
            {
                if (SpellStage == 0)
                {
                    if (transform.position.y < -2)
                    {
                        transform.position   = new Vector2(0, -2);
                        wizardBody.velocity  = new Vector2(0, 8);
                        wizardHands.velocity = new Vector2(0, 8);
                        NormalFace.SetActive(false);
                        AngerFace.SetActive(true);
                        SpellStage = 1;
                        Debug.Log("SpellStage 1");
                    }
                }
                else if (SpellStage == 1)
                {
                    if (transform.position.y > 20)
                    {
                        wizardBody.velocity = new Vector2(0, 0);
                    }
                    if (wizardHandsHolder.transform.position.y > 22)
                    {
                        wizardHands.velocity       = new Vector2(0, 0);
                        LeftHandHalf.sortingOrder  = 3;
                        RightHandHalf.sortingOrder = 3;
                    }
                    if (wizardHandsHolder.transform.position.y > 22 && transform.position.y > 20)
                    {
                        SpellStage           = 2;
                        wizardHands.velocity = new Vector2(0, -7);
                        wizardBody.velocity  = new Vector2(0, 7);
                        Debug.Log("SpellStage 2");
                    }
                }
                else if (SpellStage == 2)
                {
                    if (transform.position.y > 32)
                    {
                        wizardBody.velocity = new Vector2(0, 0);
                    }

                    if (wizardHandsHolder.transform.position.y < 16)
                    {
                        wizardHands.velocity = new Vector2(0, 0);
                    }
                    if (wizardHandsHolder.transform.position.y <= 16 && transform.position.y >= 32)
                    {
                        SpellStage           = 3;
                        wizardHands.velocity = new Vector2(0, 5);
                        //wizardBody.velocity = new Vector2(0,7);
                        Debug.Log("SpellStage 3");
                    }
                }
                else if (SpellStage == 3)
                {
                    if (transform.position.y > 32)
                    {
                        wizardBody.velocity = new Vector2(0, 0);
                    }

                    if (wizardHandsHolder.transform.position.y > 23)
                    {
                        wizardHands.velocity = new Vector2(0, 0);
                    }
                    if (wizardHandsHolder.transform.position.y >= 23 && transform.position.y >= 32)
                    {
                        SpellStage           = 4;
                        wizardHands.velocity = new Vector2(0, 5);
                        //wizardBody.velocity = new Vector2(0,7);
                        Debug.Log("SpellStage 4");
                        audiosource.Play();
                    }
                }
                else if (SpellStage == 4)
                {
                    if (wizardHandsHolder.transform.position.y > 30)
                    {
                        wizardHands.velocity       = new Vector2(0, -20);
                        RightHandFist.enabled      = true;
                        RightHandFull.enabled      = false;
                        RightHandHalf.enabled      = false;
                        LeftHandFist.enabled       = true;
                        LeftHandFull.enabled       = false;
                        LeftHandHalf.enabled       = false;
                        RightHandFist.sortingOrder = 3;
                        LeftHandFist.sortingOrder  = 3;
                        Debug.Log("SpellStage 5");
                        SpellStage = 5;
                    }
                }
                else if (SpellStage == 5)
                {
                    if (wizardHandsHolder.transform.position.y < 20)
                    {
                        Camera.main.GetComponent <Camera_controller>().CameraShake();
                        SpawnPowerup();

                        float playerX = PlayerTransform.position.x;
                        float playerY = PlayerTransform.position.y;
                        garbageSpawner.SpawnRandomGarbageAtLocation(playerX, playerY, true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                        garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);

                        wizardHands.velocity = new Vector2(0, 3);
                        SpellStage           = 6;

                        Debug.Log("SpellStage 6");
                    }
                }
                else if (SpellStage == 6)
                {
                    if (wizardHandsHolder.transform.position.y > 23)
                    {
                        wizardHands.velocity       = new Vector2(0, -8);
                        wizardBody.velocity        = new Vector2(0, -8);
                        SpellStage                 = 7;
                        RightHandFist.sortingOrder = 0;
                        LeftHandFist.sortingOrder  = 0;
                        RightHandFull.sortingOrder = 0;
                        RightHandHalf.sortingOrder = 0;
                        LeftHandFull.sortingOrder  = 0;
                        LeftHandHalf.sortingOrder  = 0;

                        Debug.Log("SpellStage 7");
                    }
                }
                else if (SpellStage == 7)
                {
                    if (wizardHandsHolder.transform.position.y < 8)
                    {
                        wizardHands.velocity = new Vector2(0, 0);
                        //SpellStage =7;
                        RightHandFist.enabled = false;
                        RightHandFull.enabled = true;
                        RightHandHalf.enabled = true;
                        LeftHandFist.enabled  = false;
                        LeftHandFull.enabled  = true;
                        LeftHandHalf.enabled  = true;
                        DuringCast            = false;
                        NormalFace.SetActive(true);
                        AngerFace.SetActive(false);
                        Debug.Log("Spell done");
                    }
                }
            }
        }
        //FINAL PHASE
        else
        {
            if (castTimer < 0)
            {
                CastBossSpell();
                castTimer  -= TimerReset;
                TimerReset -= 0.5f;
            }


            if (NumSpellsCast == 2)
            {
                if (SpellStage == 0)
                {
                    Debug.Log("into SpellStage 0");
                    transform.position = Vector3.Lerp(transform.position, new Vector3(0, 14.4f, 0), 2 * Time.deltaTime);
                    wizardHandsHolder.transform.position = Vector3.Lerp(wizardHandsHolder.transform.position, new Vector3(0.25f, 14.45f, 0.2109375f), 4 * Time.deltaTime);

                    movementCooldown -= Time.fixedDeltaTime;
                    if (movementCooldown < 0)
                    {
                        SpellStage         = 1;
                        VulnerableCooldown = 8f;
                        healthLoseLimit    = wizardHealth - 35;
                        Debug.Log("Moved into vuln area");
                        isVulnerable = true;
                        leftHandHalfGameObject.GetComponent <WizardHandDamageable>().SwitchCollider(true);
                        rightHandHalfGameObject.GetComponent <WizardHandDamageable>().SwitchCollider(true);
                        NormalFace.GetComponent <WizardFaceDamageable>().SwitchCollider(true);
                        //Make wizard and hands able to be hurt
                    }
                }
                else if (SpellStage == 1)
                {
                    VulnerableCooldown -= Time.fixedDeltaTime;
                    if (VulnerableCooldown < 0 || wizardHealth < healthLoseLimit)
                    {
                        wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                        Debug.Log("vulnerability complete");
                        isVulnerable  = false;
                        SpellStage    = 2;
                        NumSpellsCast = 0;

                        RightHandFist.enabled      = true;
                        RightHandFull.enabled      = false;
                        RightHandHalf.enabled      = false;
                        LeftHandFist.enabled       = true;
                        LeftHandFull.enabled       = false;
                        LeftHandHalf.enabled       = false;
                        LeftHandHalf.sortingOrder  = 0;
                        RightHandHalf.sortingOrder = 0;
                        vulnMode = false;
                        leftHandHalfGameObject.GetComponent <WizardHandDamageable>().SwitchCollider(false);
                        rightHandHalfGameObject.GetComponent <WizardHandDamageable>().SwitchCollider(false);
                        NormalFace.GetComponent <WizardFaceDamageable>().SwitchCollider(false);
                    }
                }
            }



            if (!DuringCast && !vulnMode)
            {
                if (transform.position.x > 12)
                {
                    MoveRight = -1f;
                }
                else if (transform.position.x < -12)
                {
                    MoveRight = 1f;
                }

                if (transform.position.y > 34)
                {
                    MoveUp = -1f;
                }
                else if (transform.position.y < 29)
                {
                    MoveUp = 1f;
                }

                castTimer -= Time.fixedDeltaTime;
                Move();
            }

            if (DuringCast)
            {
                //garbage ball
                if (ChosenSpell < 7)
                {
                    if (SpellStage == 0)
                    {
                        wizardHands.velocity       = new Vector2(0, -8);
                        LeftHandFist.sortingOrder  = 0;
                        RightHandFist.sortingOrder = 0;
                        SpellStage = 1;
                    }
                    else if (SpellStage == 1)
                    {
                        if (wizardHandsHolder.transform.position.y < -6)
                        {
                            garbageBall.SetActive(true);
                            wizardHands.velocity = new Vector2(0, 25);
                            Debug.Log("SpellStage 2");
                            SpellStage       = 2;
                            audiosource.clip = CastGarbageBall;
                            audiosource.Play();
                        }
                    }
                    else if (SpellStage == 2)
                    {
                        if (wizardHandsHolder.transform.position.y > 50)
                        {
                            SpawnPowerup();
                            garbageBall.SetActive(false);
                            wizardHands.velocity = new Vector2(0, 0);
                            SpellStage           = 3;
                            Debug.Log("SpellStage 3, garbage ball cast complete");

                            float playerX = PlayerTransform.position.x;
                            float playerY = PlayerTransform.position.y;
                            garbageSpawner.SpawnAtLocation(1, playerX, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 10, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 5f, playerY + 5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX, playerY + 10f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 5f, playerY + 5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 10f, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 5f, playerY - 5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX, playerY - 10f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 7.5f, playerY - 7.5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 15, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 7.5f, playerY + 7.5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX, playerY + 15f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 7.5f, playerY + 7.5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 15f, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX - 7.5f, playerY - 7.5f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX, playerY - 15f, true);
                            garbageSpawner.SpawnRandomGarbageAtLocation(playerX + 7.5f, playerY - 7.5f, true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);

                            DuringCast = false;
                            NormalFace.SetActive(true);
                            AngerFace.SetActive(false);
                            NumSpellsCast++;
                            if (NumSpellsCast == 2)
                            {
                                RightHandFist.enabled      = false;
                                RightHandFull.enabled      = true;
                                RightHandHalf.enabled      = true;
                                LeftHandFist.enabled       = false;
                                LeftHandFull.enabled       = true;
                                LeftHandHalf.enabled       = true;
                                LeftHandHalf.sortingOrder  = 3;
                                RightHandHalf.sortingOrder = 3;
                                vulnMode         = true;
                                SpellStage       = 0;
                                movementCooldown = 3;
                            }
                            else
                            {
                                wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                            }
                        }
                    }
                }

                //Hail of trash
                else if (ChosenSpell < 14)
                {
                    if (SpellStage == 0)
                    {
                        wizardHands.velocity = new Vector2(0, 5);
                        SpellStage           = 1;
                    }
                    else if (SpellStage == 1)
                    {
                        if (wizardHandsHolder.transform.position.y > 30)
                        {
                            wizardHands.velocity = new Vector2(0, -20);
                            Debug.Log("SpellStage 2");
                            SpellStage       = 2;
                            audiosource.clip = CastHailOfTrash;
                            audiosource.Play();
                        }
                    }
                    else if (SpellStage == 2)
                    {
                        if (wizardHandsHolder.transform.position.y < 20)
                        {
                            SpawnPowerup();
                            Camera.main.GetComponent <Camera_controller>().CameraShake();
                            float playerX = PlayerTransform.position.x;
                            float playerY = PlayerTransform.position.y;
                            garbageSpawner.SpawnAtLocation(1, playerX, playerY, true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);
                            garbageSpawner.SpawnRandomGarbageAtRandomLocation(true);

                            wizardHands.velocity = new Vector2(0, 0);
                            SpellStage           = 3;
                            //wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                            Debug.Log("SpellStage 3, hail of trash complete");

                            DuringCast = false;
                            NormalFace.SetActive(true);
                            AngerFace.SetActive(false);
                            NumSpellsCast++;
                            if (NumSpellsCast == 2)
                            {
                                RightHandFist.enabled      = false;
                                RightHandFull.enabled      = true;
                                RightHandHalf.enabled      = true;
                                LeftHandFist.enabled       = false;
                                LeftHandFull.enabled       = true;
                                LeftHandHalf.enabled       = true;
                                LeftHandHalf.sortingOrder  = 3;
                                RightHandHalf.sortingOrder = 3;
                                vulnMode         = true;
                                SpellStage       = 0;
                                movementCooldown = 5;
                            }
                            else
                            {
                                wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                            }
                        }
                    }
                }                        //Hail of trash end

                //Fist
                else if (ChosenSpell < 20)
                {
                    if (SpellStage == 0)
                    {
                        wizardHands.velocity = new Vector2(0, 10);
                        SpellStage           = 1;
                    }
                    else if (SpellStage == 1)
                    {
                        if (wizardHandsHolder.transform.position.y > 40)
                        {
                            SpawnPowerup();
                            audiosource.clip = CastFist;
                            audiosource.Play();
                            Debug.Log("SpellStage 2");
                            SpellStage  = 2;
                            fistCounter = 0;
                            StartCoroutine("Fist", 1);
                            StartCoroutine("Fist", 3);
                            StartCoroutine("Fist", 5);
                            wizardHands.velocity = new Vector2(0, 0);
                        }
                    }
                    else if (SpellStage == 2)
                    {
                        if (fistCounter == 3)
                        {
                            SpellStage = 3;
                            //wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                            Debug.Log("SpellStage 3, fist spell complete");

                            DuringCast = false;
                            NormalFace.SetActive(true);
                            AngerFace.SetActive(false);
                            NumSpellsCast++;
                            if (NumSpellsCast == 2)
                            {
                                RightHandFist.enabled      = false;
                                RightHandFull.enabled      = true;
                                RightHandHalf.enabled      = true;
                                LeftHandFist.enabled       = false;
                                LeftHandFull.enabled       = true;
                                LeftHandHalf.enabled       = true;
                                LeftHandHalf.sortingOrder  = 3;
                                RightHandHalf.sortingOrder = 3;
                                vulnMode         = true;
                                SpellStage       = 0;
                                movementCooldown = 3;
                            }
                            else
                            {
                                wizardHandsHolder.transform.localPosition = new Vector3(0.25f, -6.4f, 0.2109375f);
                            }
                        }
                    }
                }
            }

            if (SpellStage == 0)
            {
                if (transform.position.y < -2)
                {
                    transform.position   = new Vector2(0, -2);
                    wizardBody.velocity  = new Vector2(0, 8);
                    wizardHands.velocity = new Vector2(0, 8);
                    NormalFace.SetActive(false);
                    AngerFace.SetActive(true);
                    SpellStage = 1;
                    Debug.Log("SpellStage 1");
                }
            }
        }
    }            //Else for final phase