コード例 #1
0
    // Elixir of Speed - increase speed for 10 seconds
    IEnumerator ElixirOfSpeed()
    {
        ScoreManager.AddExploration(1);
        soundManager.PlaySound(soundManager.powerup);
        uiManager.Powerup("Elixir of Speed: +5 Speed", new Color(0, 0.4f, 1));
        GetComponent <SpriteRenderer>().color = new Color(0, 0.4f, 1);
        speed = 0.15f;
        yield return(new WaitForSeconds(15));

        uiManager.Powerup("", Color.white);
        GetComponent <SpriteRenderer>().color = Color.white;
        speed = 0.1f;
    }
コード例 #2
0
 public bool Open()
 {
     if (!opened)
     {
         opened = true;
         doorRenderer.sprite = openDoor;
         boxCollider.enabled = false;
         soundManager.PlaySound(soundManager.open);
         ScoreManager.AddExploration(1);
         if (boss)
         {
             StartCoroutine(uiManager.Scores(ScoreManager.GetScores()));
         }
         return(true);
     }
     return(false);
 }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Item") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            if (!other.gameObject.name.Equals("Coin"))
            {
                ScoreManager.AddCollection(1);
                if ((inventory.Count == 6 && !playerDisciplines.Contains("Collection")) ||
                    (inventory.Count == 8 && playerDisciplines.Contains("Collection")))
                {
                    uiManager.InvFull(other.transform.position);
                }
            }
            // Check item
            switch (other.name)
            {
            // Coin
            case "Coin":
                soundManager.PlaySound(soundManager.coin);
                Destroy(other.gameObject);
                playerCoins++;
                uiManager.SetCoins(playerCoins);
                questManager.Event("coin", "Collect", true);
                break;

            // Scroll
            case "Scroll":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Scroll", inventory.Count);
                    AddItem("Scroll");
                    if (questManager.Event("Find the scroll", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            // Key
            case "Key":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Key", inventory.Count);
                    AddItem("Key");
                }
                break;

            // Boss Key
            case "Boss Key":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.win);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Boss Key", inventory.Count);
                    AddItem("Boss Key");
                }
                else
                {
                    uiManager.RemoveItem(inventory.Count - 1);
                    inventory.RemoveAt(inventory.Count - 1);
                    soundManager.PlaySound(soundManager.win);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Boss Key", inventory.Count);
                    AddItem("Boss Key");
                }
                break;

            // Potion
            case "Wigg's Brew":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Wigg's Brew", inventory.Count);
                    AddItem("Wigg's Brew");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Liquid Luck":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Liquid Luck", inventory.Count);
                    AddItem("Liquid Luck");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Ogre's Strength":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Ogre's Strength", inventory.Count);
                    AddItem("Ogre's Strength");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Bring all four potions to Wigg", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;

            case "Elixir of Speed":
                if (inventory.Count < 6 || (inventory.Count < 8 && playerDisciplines.Contains("Collection")))
                {
                    soundManager.PlaySound(soundManager.item);
                    Destroy(other.gameObject);
                    uiManager.AddItem("Elixir of Speed", inventory.Count);
                    AddItem("Elixir of Speed");
                    if (inventory.Contains("Wigg's Brew") && inventory.Contains("Liquid Luck") &&
                        inventory.Contains("Ogre's Strength") && inventory.Contains("Elixir of Speed") &&
                        questManager.Event("Collect all four potions", 0, false))
                    {
                        questManager.AddMainQuest("Return to Wigg");
                    }
                }
                break;
            }
        }
        else if (other.gameObject.CompareTag("Enemy") && other is CircleCollider2D && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            // Take damage
            EnemyController enemyController = other.gameObject.GetComponent <EnemyController>();
            if (enemyController != null && enemyController.health > 0)
            {
                int enemyAttack = other.gameObject.GetComponent <EnemyController>().GetAttack();
                StartCoroutine(TakeDamage(enemyAttack));
            }
        }
        else if (other.gameObject.CompareTag("King") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            // Take damage
            KingController kingController = other.gameObject.GetComponent <KingController>();
            if (kingController != null && kingController.isActiveAndEnabled && kingController.health > 0)
            {
                int kingAttack = other.gameObject.GetComponent <KingController>().GetAttack();
                StartCoroutine(TakeDamage(kingAttack));
            }
        }
        else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && other.gameObject.GetComponent <Animator>() != null && other.gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime < 0.17f)
        {
            // Take damage
            if (!IsBouncing())
            {
                StartCoroutine(TakeDamage(1));
            }
            // Bounce off the spikes
            body.AddForce(Vector2.up * 100);
            isBouncing = true;
            Invoke("StopBounce", 0.2f);
        }
        else if (other.gameObject.name.Equals("Spikes") && GetComponent <BoxCollider2D>().IsTouching(other) && !other.gameObject.GetComponent <SpriteRenderer>().sprite.name.Equals("floor_spikes_anim_f0"))
        {
            // Take damage
            if (!IsBouncing())
            {
                StartCoroutine(TakeDamage(1));
            }
            // Bounce off the spikes
            body.AddForce(Vector2.up * 100);
            isBouncing = true;
            Invoke("StopBounce", 0.2f);
        }
        else if (other.gameObject.CompareTag("Projectile") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            Destroy(other);
            // Take damage
            StartCoroutine(TakeDamage(1));
        }
        else if (other.gameObject.CompareTag("Collider") && GetComponent <BoxCollider2D>().IsTouching(other))
        {
            ScoreManager.AddExploration(1);
            questManager.Event("room", "Explore", true);
            Destroy(other.gameObject);
        }
    }