Example #1
0
    private void DoRandomEffect()
    {
        int tmp = Random.Range(0, 4);

        switch (tmp)
        {
        case 0:
        {
            goddessText.text        = "The next item you purchase in the\nshop will be half off...";
            refPlayerCollision.sale = 2;
            break;
        }

        case 1:
        {
            goddessText.text = "Health restoration for 10 seconds...";
            refPlayerCollision.SetConstantHealthRegen(true, 10);
            break;
        }

        case 2:
        {
            goddessText.text = "I've sent the Orne down " + wardMeters + "m\nfor you, Pit...";
            EnemyOrne tmpOrne = GameObject.FindObjectOfType <EnemyOrne>();
            tmpOrne.SendBack(wardMeters);
            break;
        }

        case 3:
        {
            goddessText.text = "Komaytos are attacking!\nOnly your hammer can defeat them!";
            Instantiate(komaytoPrefab, Vector2.zero, transform.rotation);
            refAudioManager.PlaySound(komaytoSound.clip, komaytoSound.volume);
            break;
        }

        default:
        {
            goddessText.text = "Sorry Pit, the goddess screwed up her switch statement somehow.";
            break;
        }
        }

        Invoke("FadeOut", destroyAfterTime - 1.5f);
        Invoke("Dest", destroyAfterTime);
    }
Example #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("InstantDeath"))
        {
            Death();
        }

        if (other.CompareTag("Eggplant") && !cursed)
        {
            cursed = true;
            refPlayerAudio.PlayCursed(0.9f);
        }

        if (other.CompareTag("Pickup"))
        {
            // normal items
            if (other.name == "Heart1(Clone)")
            {
                refPlayerAudio.PlayHeart();
                hearts          += 1;
                heartsCollected += 1;
                Destroy(other.gameObject);
            }
            else if (other.name == "Heart5(Clone)")
            {
                refPlayerAudio.PlayHeart();
                hearts          += 5;
                heartsCollected += 5;
                Destroy(other.gameObject);
            }
            else if (other.name == "Heart10(Clone)" || other.name == "FlyingHeart(Clone)")
            {
                refPlayerAudio.PlayHeart();
                hearts          += 10;
                heartsCollected += 10;
                Destroy(other.gameObject);
            }
            else if (other.name == "DrinkSmall(Clone)")
            {
                healthToRestore += smallDrinkAmount;
                StartCoroutine("RestoreHealth");
                Destroy(other.gameObject);
            }
            else if (other.name == "DrinkLarge(Clone)")
            {
                healthToRestore += largeDrinkAmount;
                StartCoroutine("RestoreHealth");
                Destroy(other.gameObject);
            }
            else if (other.name == "DrinkKiddie(Clone)")
            {
                healthToRestore += kiddieDrinkAmount;
                StartCoroutine("RestoreHealth");
                Destroy(other.gameObject);
            }
            else if (other.name == "RocFeather(Clone)" && refPlayerMovement.extraJumps != refPlayerMovement.extraJumpsMax)
            {
                refPlayerMovement.extraJumps++;
                Destroy(other.gameObject);
            }
            else if (other.name == "CenturionAssist(Clone)")
            {
                refPlayerShoot.centurionsStored++;
                Destroy(other.gameObject);
            }
            else if (other.name == "DivineWard(Clone)")
            {
                EnemyOrne tmpOrne = GameObject.FindObjectOfType <EnemyOrne>();
                tmpOrne.SendBack(wardMeters);
                Destroy(other.gameObject);
            }
            else if (other.name == "FirstAidKit(Clone)")
            {
                hasFirstAidKit = true;
                Destroy(other.gameObject);
            }
            else if (other.name == "IconOfLight(Clone)")
            {
                GameObject tmpIcon = Instantiate(iconOfLightPrefab, transform.position, transform.rotation);
                tmpIcon.transform.parent = gameObject.transform;
                Destroy(other.gameObject);
            }
            else if (other.name == "ChargeReticle(Clone)")
            {
                refPlayerShoot.IncreaseCharge();
                Destroy(other.gameObject);
            }
            else if (other.name == "Longbow(Clone)")
            {
                refPlayerShoot.IncreaseRange();
                Destroy(other.gameObject);
            }
            else if (other.name == "HomingBooster(Clone)")
            {
                refPlayerShoot.IncreaseHoming();
                Destroy(other.gameObject);
            }
            else
            {
                // shop items
                ShopItem tmp = refShopInfo.getItem(other.name);

                if (tmp.cost / sale <= hearts)
                {
                    if (tmp.name == "Small Drink")
                    {
                        if (currentHealth != maxHealth)
                        {
                            healthToRestore += smallDrinkAmount;
                            StartCoroutine("RestoreHealth");
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (tmp.name == "Large Drink")
                    {
                        if (currentHealth != maxHealth)
                        {
                            healthToRestore += largeDrinkAmount;
                            StartCoroutine("RestoreHealth");
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (tmp.name == "Kiddie Size Drink")
                    {
                        if (currentHealth != maxHealth)
                        {
                            healthToRestore += kiddieDrinkAmount;
                            StartCoroutine("RestoreHealth");
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (tmp.name == "Roc's Feather")
                    {
                        if (refPlayerMovement.extraJumps != refPlayerMovement.extraJumpsMax)
                        {
                            refPlayerMovement.extraJumps++;
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (tmp.name == "Centurion Assist")
                    {
                        refPlayerShoot.centurionsStored++;
                    }

                    if (tmp.name == "Divine Ward")
                    {
                        EnemyOrne tmpOrne = GameObject.FindObjectOfType <EnemyOrne>();
                        tmpOrne.SendBack(wardMeters);
                    }

                    if (tmp.name == "First Aid Kit")
                    {
                        if (!hasFirstAidKit)
                        {
                            hasFirstAidKit = true;
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (tmp.name == "Icon of Light")
                    {
                        GameObject tmpIcon = Instantiate(iconOfLightPrefab, transform.position, transform.rotation);
                        tmpIcon.transform.parent = gameObject.transform;
                    }

                    if (tmp.name == "Icon of Nature")
                    {
                    }

                    if (tmp.name == "Charge Reticle")
                    {
                        refPlayerShoot.IncreaseCharge();
                    }

                    if (tmp.name == "Longbow")
                    {
                        refPlayerShoot.IncreaseRange();
                    }

                    if (tmp.name == "Homing Booster")
                    {
                        refPlayerShoot.IncreaseHoming();
                    }

                    hearts      -= tmp.cost / sale;
                    sale         = 1;
                    heartsSpent += tmp.cost;
                    Destroy(other.gameObject);

                    // play money particles
                    ParticleSystem tmpParts = Instantiate(moneyParts, transform.position, Quaternion.identity);
                    tmpParts.emission.SetBurst(0, new ParticleSystem.Burst(0.0f, tmp.cost / 2));
                    tmpParts.Play();
                    refPlayerAudio.PlayKaching();
                }
            }
        }
    }