Beispiel #1
0
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            GameController controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

            if (!controller.playerStats.MaxRateOfFireReached)
            {
                AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
                audioSource.clip   = soundEffect;
                audioSource.volume = 1.0f * GameController.sfxVolume;

                PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
                player.firingSpeed = player.firingSpeed / 1.25f;

                controller.playerStats.TotalRateOfFire           = player.firingSpeed;
                controller.playerStats.TotalRateOfFireIncreases += 1;
                if (controller.playerStats.TotalRateOfFireIncreases >= 4)
                {
                    controller.playerStats.MaxRateOfFireReached = true;
                }

                controller.UpdatePlayerStats();

                audioSource.Play();
                hasPickedup = true;

                // Flash message
                string messageToSend = "Rate of Fire Increased!";
                DisplayMessage.MessageToQueue(messageToSend);
            }
        }
    }
Beispiel #2
0
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            GameController gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

            if (!gameController.playerStats.MaxRunSpeedReached)
            {
                AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
                audioSource.clip   = soundEffect;
                audioSource.volume = 1.0f * GameController.sfxVolume;


                PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

                gameController.playerStats.TotalRunSpeed          += 2;
                gameController.playerStats.TotalRunSpeedIncreases += 1;
                player.moveSpeed += 5;

                if (gameController.playerStats.TotalRunSpeedIncreases >= 4)
                {
                    gameController.playerStats.MaxRunSpeedReached = true;
                }

                gameController.UpdatePlayerStats();

                audioSource.Play();
                hasPickedup = true;

                // Flash message
                string messageToSend = "Run speed increased!";
                DisplayMessage.MessageToQueue(messageToSend);
            }
        }
    }
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
            audioSource.clip   = soundEffect;
            audioSource.volume = 1.0f * GameController.sfxVolume;

            GameController gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

            GameController.maxHealth += 25;
            gameController.playerStats.TotalHealth += 25;
            gameController.UpdatePlayerStats();
            //gameController.healthBar.maxValue = GameController.maxHealth;
            gameController.currentHealth += 25;
            gameController.UpdateHealingBar();

            audioSource.Play();
            hasPickedup = true;

            // Flash message
            string messageToSend = "Max health increased by 25!";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
Beispiel #4
0
    // Check the timers, either perform an attack or, if the total timer has run up, destroy the object
    void Update()
    {
        if (timer <= 0)
        {
            // time's up

            string messageToSend = "Attack Totem Expired.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject.transform.parent.gameObject, 2.0f);
            Destroy(gameObject);
        }
        else
        {
            timer -= Time.deltaTime;
        }

        if (AOETimer <= 0)
        {
            Fire();
            AOETimer = timeBetweenAOE;
        }
        else
        {
            AOETimer -= Time.deltaTime;
        }
    }
Beispiel #5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            // this ensures that the player has completed the room event prior to heading off
            if (!RoomEvent.roomEventActive)
            {
                // increases the current level that the player is on
                gameController.playerStats.CurrentLevel++;
                gameController.playerStats.RoomsClearedCounter = 0;
                gameController.SavePlayerProgress();

                SceneManager.LoadScene(gameController.playerStats.CurrentLevel);
                if (Time.timeScale == 0)
                {
                    Time.timeScale = 1;
                }
            }
            else
            {
                // inform the player that they need to complete the room prior to progressing
                string messageToSend = "You must clear the room before continuing.";
                DisplayMessage.MessageToQueue(messageToSend);
            }
        }
    }
Beispiel #6
0
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            GameController controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

            if (controller.currentHealth < GameController.maxHealth)
            {
                AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
                audioSource.clip   = pickupSound;
                audioSource.volume = 1.0f * GameController.sfxVolume;

                int healAmount          = 30;
                PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
                player.TakeHealing(healAmount);

                audioSource.Play();
                hasPickedup = true;

                // Flash message
                string messageToSend = "Healed by " + Mathf.Abs(healAmount) + "!";
                DisplayMessage.MessageToQueue(messageToSend);
            }
            else
            {
                string messageToSend = "No healing needed.";
                DisplayMessage.MessageToQueue(messageToSend);
            }
        }
    }
    // set all of the remaining reflection booleans in the remaining enemies to false
    // alert the player that the damage reflection is no longer active and destroy the object
    private void StopDamageReflection()
    {
        if (RoomEvent.roomEventActive)
        {
            meleeEnemies  = GameObject.FindGameObjectsWithTag("meleeEnemy");
            rangedEnemies = GameObject.FindGameObjectsWithTag("rangedEnemy");

            foreach (GameObject meleeEnemy in meleeEnemies)
            {
                meleeEnemy.GetComponent <EnemyController>().damageRelflection = false;
            }

            foreach (GameObject rangedEnemy in rangedEnemies)
            {
                rangedEnemy.GetComponent <RangedEnemy>().damageReflection = false;
            }

            string messageToSend = "Damage no longer reflected.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
        else if (StartBossFight.bossRoomEventActive)
        {
            if (boss.name == "Flame Knight(Clone)")
            {
                boss.GetComponent <FlameKnightController>().damageReflectionActive = false;
            }

            string messageToSend = "Damage no longer reflected.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
    }
    // Check the timers
    // if the time is up, display a message to the player and destroy the object
    // if the ROF timer hits, shoot a bullet at the enemy
    void Update()
    {
        if (timer <= 0)
        {
            // time's up

            string messageToSend = "Attack Totem Expired.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject.transform.parent.gameObject, 0.5f);
            Destroy(gameObject, 0.5f);
        }
        else
        {
            timer -= Time.deltaTime;
        }

        if (bulletTimer <= 0)
        {
            // shoot
            Shoot();
            bulletTimer = timeBetweenShots;
        }
        else
        {
            bulletTimer -= Time.deltaTime;
        }
    }
    // checks to make sure that there is a room event active
    // gets references to all of the enemies in the scene and then kills them
    public void DestroyAllEnemies()
    {
        if (RoomEvent.roomEventActive)
        {
            RoomEvent      roomEvent      = GameObject.FindGameObjectWithTag("RoomEvent").GetComponent <RoomEvent>();
            GameController gameController = GameObject.Find("GameController").GetComponent <GameController>();

            GameObject[] meleeEnemies  = GameObject.FindGameObjectsWithTag("meleeEnemy");
            GameObject[] rangedEnemies = GameObject.FindGameObjectsWithTag("rangedEnemy");
            Instantiate(flashHolder);

            foreach (GameObject meleeEnemy in meleeEnemies)
            {
                EnemyController.meleeEnemyCount -= 1;
                Destroy(meleeEnemy.transform.parent.gameObject);
                Destroy(meleeEnemy);

                gameController.UpdateScore(5);
            }

            foreach (GameObject rangedEnemy in rangedEnemies)
            {
                RangedEnemy.rangedEnemyCount -= 1;
                Destroy(rangedEnemy.transform.parent.gameObject);
                Destroy(rangedEnemy);

                gameController.UpdateScore(5);
            }

            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

            Instantiate(soundEffect, player.position, Quaternion.identity);

            Destroy(gameObject);
        }
        else if (StartBossFight.bossRoomEventActive)
        {
            GameObject boss = GameObject.FindGameObjectWithTag("Boss");

            if (boss.name == "Flame Knight(Clone)")
            {
                FlameKnightController controller =
                    boss.GetComponent <FlameKnightController>();
                int maxHealth = controller.GetMaxHealth();
                controller.TakeDamage(maxHealth / 2);

                Destroy(gameObject);
            }
        }
        else
        {
            // Display error message
            string message = "No enemies in the area.";
            DisplayMessage.MessageToQueue(message);
        }
    }
Beispiel #10
0
    // Check the timer => notify the player and then set the enemy speeds back to normal
    void Update()
    {
        if (timer <= 0)
        {
            NormalTime();

            string messageToSend = "Time back to normal.";
            DisplayMessage.MessageToQueue(messageToSend);
        }
        else
        {
            timer -= Time.deltaTime;
        }
    }
Beispiel #11
0
    // Ensure that the room event is active
    // instantiate the totem into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void ActivateAbility()
    {
        Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

        // this is where the logic will go to drop the healing totem
        Instantiate(healingTotem, player.position, Quaternion.identity);
        Instantiate(soundEffect, player.position, Quaternion.identity);

        // flash message
        string messageToSend = "Healing Totem Dropped!";

        DisplayMessage.MessageToQueue(messageToSend);

        Destroy(gameObject);
    }
    // Once the timer has run up, turn off invincibility
    void Update()
    {
        if (timer <= 0)
        {
            // time's up!
            PlayerController.invincible = false;

            string messageToSend = "Invincibility has run out.";
            DisplayMessage.MessageToQueue(messageToSend);
            Destroy(gameObject);
        }
        else
        {
            timer -= Time.deltaTime;
        }
    }
Beispiel #13
0
    // this runs through the player inventory and checks to see if the player has an open slot, if the do
    // that inventory slot is filled
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            for (int i = 0; i < inventory.slots.Length; i++)
            {
                if (!inventory.isFull[i])
                {
                    inventory.isFull[i] = true;
                    if (i == 0)
                    {
                        gameController.inventorySlotOneFilled         = true;
                        gameController.inventorySlotOne               = itemButton;
                        gameController.playerStats.InventoryOneFilled = true;
                        gameController.playerStats.InventoryOneItem   = GetComponent <Identifier>().identity;
                    }
                    else
                    {
                        gameController.inventorySlotTwoFilled         = true;
                        gameController.inventorySlotTwo               = itemButton;
                        gameController.playerStats.InventoryTwoFilled = true;
                        gameController.playerStats.InventoryTwoItem   = GetComponent <Identifier>().identity;
                    }
                    Instantiate(itemButton, inventory.slots[i].transform, false);
                    audioSource.volume = 1f * GameController.sfxVolume;
                    audioSource.Play();
                    gameController.UpdatePlayerStats();
                    hasPickedup = true;



                    // Flash message
                    string messageToSend = GetComponent <Identifier>().flashMessage;
                    DisplayMessage.MessageToQueue(messageToSend);

                    break;
                }
            }

            if (inventory.isFull[0] && inventory.isFull[1] && !hasPickedup)
            {
                string messageToSend = GetComponent <Identifier>().flashMessageWhenInventoryFull;
                DisplayMessage.MessageToQueue(messageToSend);
            }
        }
    }
Beispiel #14
0
    private void FinalRoomClosingRequirements()
    {
        // set the room event to inactive
        roomEventActive = false;

        // destroy the grid components
        Destroy(GameObject.FindGameObjectWithTag("Grid"));

        // update the DDA
        UpdateDDA();

        // Flash message
        string messageToSend = "Room Cleared!";

        DisplayMessage.MessageToQueue(messageToSend);

        finalClosingRequirementsMet = true;
        readyToResetRoomScript      = true;
    }
    // Ensure that the room event is active
    // instantiate the AOE totem into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void ActivateAbility()
    {
        if (RoomEvent.roomEventActive || StartBossFight.bossRoomEventActive)
        {
            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
            // this is where the area attack totem logic goes
            Instantiate(AOETotem, player.position, Quaternion.identity);
            Instantiate(soundObject, player.position, Quaternion.identity);

            // flash message
            string messageToSend = "Area Attack Totem Deployed!";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
        else
        {
            string messageToSend = "No enemies...";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
    // Ensure that the room event is active
    // instantiate the slow object into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void SlowAllEnemies()
    {
        if (RoomEvent.roomEventActive || StartBossFight.bossRoomEventActive)
        {
            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

            // Figure out how to slow everything enemy releated down
            Instantiate(timeSlowObject, player.position, Quaternion.identity);
            Instantiate(soundEffect, player.position, Quaternion.identity);

            // Flash message
            string messageToSend = "Enemies and their abilities slowed!";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
        else
        {
            string messageToSend = "No enemies in the area.";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
Beispiel #17
0
    // Ensure that the room event is active
    // instantiate the totem into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void ActivateAbility()
    {
        if (RoomEvent.roomEventActive || StartBossFight.bossRoomEventActive)
        {
            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

            // this is where the logic will go for the slowing totem
            Instantiate(slowingTotem, player.position, Quaternion.identity);
            Instantiate(soundEffect, player.position, Quaternion.identity);

            // flash message
            string messageToSend = "Slowing Totem Deployed!";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
        else
        {
            string messageToSend = "No enemies present.";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
    // Ensure that the room event is active
    // instantiate the reflection object into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void ActivateAbility()
    {
        if (RoomEvent.roomEventActive || StartBossFight.bossRoomEventActive)
        {
            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

            // this is where the logic goes to use damage reflection
            Instantiate(damageReflectionObject, player.position, Quaternion.identity);
            Instantiate(soundEffect, player.position, Quaternion.identity);

            // flash message
            string messageToSend = "Damage Reflection Active!";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject);
        }
        else
        {
            string messageToSend = "No active enemies...";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
    // Check the timers, heal the player if they are in the radius, and destroy the object when the time is up
    void Update()
    {
        if (abilityTimer <= 0)
        {
            // Time's up!

            string messageToSend = "Healing Totem Expired.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject.transform.parent.gameObject, 0.5f);
            Destroy(gameObject, 0.5f);
        }
        else
        {
            abilityTimer -= Time.deltaTime;
        }

        if (healingTimer <= 0)
        {
            if (canReceiveHeals)
            {
                GameController control = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

                if (control.currentHealth < GameController.maxHealth)
                {
                    PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
                    player.TakeHealing(10);
                    audioSource.volume = audioSource.volume * GameController.sfxVolume;
                    audioSource.Play();
                }
            }
            healingTimer = timeBetweenHeals;
        }
        else
        {
            healingTimer -= Time.deltaTime;
        }
    }
Beispiel #20
0
    // Ensure that the room event is active
    // instantiate the invincibility object into the scene at the player location
    // notify the player and then destroy the object in the inventory
    public void ActivateInvincibility()
    {
        if (RoomEvent.roomEventActive || StartBossFight.bossRoomEventActive)
        {
            Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

            // invincibility logic goes here
            Instantiate(invincibleBuff, player.position, Quaternion.identity, player);
            Instantiate(soundEffect, player.position, Quaternion.identity);

            // Flash message
            string messageToSend = "Invincibility Active!";
            DisplayMessage.MessageToQueue(messageToSend);


            Destroy(gameObject);
        }
        else
        {
            string messageToSend = "No enemies in the area.";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
            audioSource.clip   = soundEffect;
            audioSource.volume = 1.0f * GameController.sfxVolume;

            GameController   gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
            PlayerController player         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

            gameController.projectileSpeedIncrease           += 100;
            gameController.playerStats.ProjectileFlightSpeed += 100;
            gameController.UpdatePlayerStats();
            player.bulletSpeed += 100;

            audioSource.Play();
            hasPickedup = true;

            // Flash message
            string messageToSend = "The speed of your bullets has increased!";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }
Beispiel #22
0
    // check the timer
    // if the time is up, set the speeds back to normal for the enemies and destroy the object
    void Update()
    {
        if (timer <= 0)
        {
            // Time's up!

            // if enemies are still slowed, speed them back up
            GameObject[] meleeEnemies = GameObject.FindGameObjectsWithTag("meleeEnemy");
            foreach (GameObject meleeEnemy in meleeEnemies)
            {
                meleeEnemy.transform.parent.GetComponent <Unit>().speed = normalSpeed;
            }

            string messageToSend = "Slowing Totem Expired.";
            DisplayMessage.MessageToQueue(messageToSend);

            Destroy(gameObject.transform.parent.gameObject);
            Destroy(gameObject, 0.2f);
        }
        else
        {
            timer -= Time.deltaTime;
        }
    }
    // once the player runs over it
    // plays the pickup sound
    // updates the player stats and informs the player of what was increased
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !hasPickedup)
        {
            AudioSource audioSource = gameObject.transform.parent.gameObject.AddComponent <AudioSource>();
            audioSource.clip   = soundEffect;
            audioSource.volume = 1.0f * GameController.sfxVolume;

            GameController   gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
            PlayerController player         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();

            //set it up for storage... so that the GameController can handle scene changes
            gameController.playerStats.AttackDamageIncreaseAmount += 4;
            player.bulletDamage += 4;
            gameController.UpdatePlayerStats();

            audioSource.Play();
            hasPickedup = true;

            // Flash message
            string messageToSend = "Bullet damage increased!";
            DisplayMessage.MessageToQueue(messageToSend);
        }
    }