Beispiel #1
0
        void OnTriggerStay(Collider other)
        {
            if (ItemPivot == null)
            {
                return;
            }
            if (ItemPivot.transform.childCount == 0)
            {
                return;
            }

            if (other.name == "empty(itemx)")
            {
                if (isBeercase(other))
                {
                    if (BottleRecycling.isBoozeBottle(ItemPivot.transform.GetChild(0)))
                    {
                        return;
                    }

                    // show gui stuff
                    PlayMakerGlobals.Instance.Variables.GetFsmBool("GUIuse").Value           = true;
                    PlayMakerGlobals.Instance.Variables.GetFsmString("GUIinteraction").Value = "Put bottle to beer case";
                    if (Input.GetMouseButtonDown(0))
                    {
                        PutBottleToBeercase(ItemPivot.transform.GetChild(0).gameObject, other.gameObject);
                    }
                }
            }
        }
Beispiel #2
0
        void PlaySound(AudioSource audio)
        {
            if (audio == null)
            {
                BottleRecycling.DebugPrint("Error; Tried to play null AudioSource.");
                return;
            }

            try
            {
                if (audio == bottle_empty_3)
                {
                    audio.transform.position = new Vector3(-1550.986f, 4.370f, 1183.482f);
                }
                else if (audio == cash_register_2)
                {
                    audio.transform.position = new Vector3(-1551.547f, 4.962f, 1182.302f);
                }
                audio.Play();
            }
            catch
            {
                BottleRecycling.DebugPrint("Error when playing AudioSource.");
            }
        }
Beispiel #3
0
        void PutBottleToBeercase(GameObject bottle, GameObject beercase)
        {
            if (bottle == null || beercase == null)
            {
                BottleRecycling.DebugPrint("BeercaseManager: Error when trying to put empty bottle to empty beercase.");
                return;
            }

            // Add BeercaseFilled -component
            if (beercase.GetComponent <BeercaseFilled>() == null)
            {
                beercase.AddComponent <BeercaseFilled>();
            }
            try
            {
                Destroy(beercase.GetComponent <PlayMakerFSM>()); // Remove PlayMakerFSM from Beercase
            }
            catch { }

            BeercaseFilled beercaseFilled = beercase.GetComponent <BeercaseFilled>();

            // Only 24 bottles fits to beercase (duh)
            if (beercaseFilled.totalBottles >= 24)
            {
                return;
            }

            beercaseFilled.AddBottleToBeerCase(bottle);             // Add Empty Bottle to Beercase
            PlaySound(bottle_empty_2, beercase.transform.position); // Play Sound
        }
Beispiel #4
0
        // Succesful Bottle Returning Sequence Logic
        IEnumerator TeimoTakesBottle(Transform bottleTransform)
        {
            isTeimoTakingBottle = true;
            bottleTransform.tag = "Untagged"; // prevent player from grabbing the given bottle back

            try
            {
                // play Teimo's "give drink" animation backwards
                Animation teimoAnimation = GameObject.Find(teimoPath).GetComponent <Animation>();
                teimoAnimation[teimoMoneyAnim].speed = -teimoAnimation[teimoMoneyAnim].speed;
                teimoAnimation[teimoMoneyAnim].time  = teimoAnimation[teimoMoneyAnim].length;
                teimoAnimation.CrossFade(teimoMoneyAnim, 0.25f);

                // disable given bottle collision and attach it to Teimo's hand
                Rigidbody rb = bottleTransform.GetComponent <Rigidbody>();
                if (rb)
                {
                    rb.isKinematic      = true;
                    rb.detectCollisions = false;
                }
                bottleTransform.parent        = GameObject.Find(teimoHandPath).transform;
                bottleTransform.localPosition = Vector3.zero;
                bottleTransform.localRotation = Quaternion.Euler(0, 0, 0);
            }
            catch
            {
                BottleRecycling.DebugPrint("Error on bottle returning sequence.");
            }

            yield return(new WaitForSeconds(2.5f)); // give time for Teimo to put bottle under desk

            AddMoneyToHold(GetBottleValue(bottleTransform));
            Destroy(bottleTransform.gameObject);    // destroy the bottle
            PlaySound(bottle_empty_3);
            yield return(new WaitForSeconds(3.5f)); // wait for animation to approximately complete

            try
            {
                // restore Teimo's animation speed
                Animation teimoAnimation = GameObject.Find(teimoPath).GetComponent <Animation>();
                teimoAnimation[teimoMoneyAnim].speed = Mathf.Abs(teimoAnimation[teimoMoneyAnim].speed);

                try
                {
                    // restore Teimo's idle animation
                    teimoAnimation.Play(teimoIdleAnim);
                    teimoAnimation[teimoIdleAnim].time = teimoAnimation[teimoIdleAnim].length;
                } catch { }
            }
            catch
            {
                BottleRecycling.DebugPrint("Error when restoring Teimo's animation speed.");
            }
            isTeimoTakingBottle = false; // bottle returning sequence is over
        }
Beispiel #5
0
 private void Start()
 {
     ItemPivot = PlayMakerGlobals.Instance.Variables.GetFsmGameObject("ItemPivot").Value;
     try
     {
         bottle_empty_2 = GameObject.Find("MasterAudio/BottlesEmpty/bottle_empty2").GetComponent <AudioSource>();
     }
     catch
     {
         BottleRecycling.DebugPrint("Error when trying to get bottle_empty2 sound.");
     }
 }
Beispiel #6
0
 void GetMoney()
 {
     PlayMakerGlobals.Instance.Variables.FindFsmFloat("PlayerMoney").Value += totalMoneyAmountFromBottles;
     try
     {
         GameObject.Find(teimoPath).GetComponent <Animation>().Play("teimo_cash_register");
         PlaySound(cash_register_2);
     }
     catch
     {
         BottleRecycling.DebugPrint("Error when playing Teimo's animation.");
     }
     totalMoneyAmountFromBottles = 0;
 }
Beispiel #7
0
        private void Start()
        {
            // get player
            player = GameObject.Find("PLAYER").transform;
            // item pivot
            ItemPivot = PlayMakerGlobals.Instance.Variables.GetFsmGameObject("ItemPivot").Value;
            // get audio
            try
            {
                cash_register_2 = GameObject.Find("MasterAudio/Store/cash_register_2").GetComponent <AudioSource>();
                bottle_empty_3  = GameObject.Find("MasterAudio/BottlesEmpty/bottle_empty3").GetComponent <AudioSource>();
            }
            catch
            {
                BottleRecycling.DebugPrint("Error when getting AudioSources.");
            }

            GetStoreFsmVariables(); // OpenStore & BrokenWindow
            Subtitles = PlayMakerGlobals.Instance.Variables.GetFsmString("GUIsubtitle");
        }
Beispiel #8
0
        void GetStoreFsmVariables()
        {
            // Store Open Times FSM (OpenStore)
            try
            {
                GameObject STORE = GameObject.Find("STORE");
                foreach (PlayMakerFSM fsm in STORE.GetComponents <PlayMakerFSM>())
                {
                    if (fsm.FsmName == "OpeningHours")
                    {
                        OpenStore = fsm.FsmVariables.GetFsmBool("OpenStore");
                    }
                }
            }
            catch
            {
                BottleRecycling.DebugPrint("Error when trying to find FsmBool 'OpenStore'");
            }

            // Broken Window Debt FSM (BrokenWindow)
            try
            {
                GameObject Register = GameObject.Find("STORE/StoreCashRegister/Register");
                foreach (PlayMakerFSM fsm in Register.GetComponents <PlayMakerFSM>())
                {
                    if (fsm.FsmName == "Data")
                    {
                        BrokenWindow = fsm.FsmVariables.GetFsmFloat("BrokenWindow");
                    }
                }
            }
            catch
            {
                BottleRecycling.DebugPrint("Error when trying to find Register FsmFloat 'BrokenWindow'");
            }
        }
Beispiel #9
0
        private void OnTriggerStay(Collider other)
        {
            if (other.tag != "PART" || other.gameObject.layer == LayerMask.NameToLayer("Wheel") || isTeimoTakingBottle || !OpenStore.Value || BrokenWindow.Value > 0)
            {
                return;
            }

            Rigidbody rb = other.GetComponent <Rigidbody>();

            if (rb)
            {
                if (rb.velocity.magnitude > 0.25f)
                {
                    return;
                }
            }

            // empty beer bottle
            if (other.name == "empty bottle(Clone)")
            {
                if (!BottleRecycling.isBoozeBottle(other.transform))   // ignore booze bottles
                {
                    StartCoroutine(TeimoTakesBottle(other.transform)); // start teimo bottle returning sequence
                }
            }

            // empty beercase
            if (other.name == "empty(itemx)")
            {
                // identify gameobject as beercase from fsm id...
                PlayMakerFSM fsm = other.GetComponent <PlayMakerFSM>();
                if (fsm)
                {
                    if (fsm.FsmVariables.FindFsmString("ID").Value.Contains("beercase"))
                    {
                        StartCoroutine(TeimoTakesBottle(other.transform)); // start teimo bottle returning sequence
                        return;
                    }
                }

                // ... if it's not casual beercase, check if it has been filled with empty bottles.
                BeercaseFilled filled = other.GetComponent <BeercaseFilled>();
                if (filled)
                {
                    StartCoroutine(TeimoTakesBottle(other.transform)); // start teimo bottle returning sequence
                }
            }

            // last we check for possible custom bottles
            if (customBottles.Count > 0)
            {
                if (customBottles.Contains(other.name))
                {
                    int index = customBottles.IndexOf(other.name);
                    if (index != -1)
                    {
                        StartCoroutine(TeimoTakesBottle(other.transform));
                    }
                }
            }
        }