Ejemplo n.º 1
0
    void OnCollisionEnter(Collision collision)
    {
        //until drink given
        //If the object that hit the customer is not a mug
        var mugData = collision.gameObject.GetComponent <MugData>();

        if (mugData != null)
        {
            //Check based off of what drink type the mug is, ask question, then attach the mug to the customer.
            if (drinkAsked && mugData.DrinkType == preferredDrink)
            {
                drinkGiven = true;
                // speech.DestroyText();
                LostAndFoundQuestion();
                // mid = true;
                mugData.transform.SetParent(transform, true);
                Destroy(mugData.GetComponent <Rigidbody>());

                int money = Random.Range(5, 10);
                //Add up money
                MoneyManager.changeMoneyAmount(money);
                GetComponent <SFXPlayer>().PlaySFX("give customer right drink");
            }
            else if (mugData.DrinkType == "Poison" && !poisioned)
            {
                if (!drinkGiven)
                {
                    if (!(type.IsLiar()))
                    {
                        speech.SpawnText("AAH WHYD U DO THAT I DIDNT EVEN ASK FOR AN ITEM YET");
                    }
                    else
                    {
                        speech.SpawnText("HOW DID YOU KNOW WHO TALKED AHHHHHHHHHHHH");
                    }
                }
                else
                {
                    if (type.IsLiar())
                    {
                        speech.SpawnText("AGH U CAUGHT ME OWOWOW");
                    }
                    else
                    {
                        speech.SpawnText("WTF I WASNT EVEN LYING");
                    }
                }

                Destroy(mugData.gameObject);

                drinkGiven = true; // lol
                mid        = true;
                poisioned  = true;
                GetComponent <SFXPlayer>().PlaySFX("give poison");
            }
        }
        var wepData = collision.gameObject.GetComponent <WeaponStats>();

        if (drinkGiven && wepData != null)
        {
            bool correctWep = (wepData == preferredWeapon);
            if (correctWep)
            {
                if (type.IsLiar())
                {
                    GetComponent <SFXPlayer>().PlaySFX("give liar item");
                    speech.SpawnText("hehe I was a liar");
                }
                else
                {
                    GetComponent <SFXPlayer>().PlaySFX("give customer right item");
                    speech.SpawnText("yay ty");
                    MoneyManager.changeMoneyAmount(30);
                }
            }
            else
            {
                speech.SpawnText(type.IsLiar() ? "thats not what i asked for but i was lying so thx anyway" : "thats not my item");
                if (type.IsLiar())
                {
                    GetComponent <SFXPlayer>().PlaySFX("give liar item");
                }
                else
                {
                    GetComponent <SFXPlayer>().PlaySFX("give customer wrong item");
                }
            }

            if (correctWep || type.IsLiar())
            {
                wepData.transform.SetParent(transform);
                Destroy(wepData.GetComponent <Rigidbody>());
            }
            mid = true;
        }
    }