示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }

        if (m_isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (myPlayer.transform.childCount <= 2 && m_PlatesTaken < 3) // doesn't hold a thing
            {
                FindObjectOfType <AudioManager>().Play("PlatePickUp");

                Instantiate(m_Plates[m_PlatesTaken]).transform.SetParent(myPlayer.transform);
                m_Plates[m_PlatesTaken].SetActive(false);
                m_PlatesTaken++;
            }
        }

        if (m_PlatesTaken == 3)
        {
            Debug.Log("out of plates");
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }


        if (isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (myPlayer.transform.childCount > 2) //
            {
                FindObjectOfType <AudioManager>().Play("ThrowTrash");
                Transform myChild = myPlayer.transform.GetChild(2);
                if (myChild.tag != "Plate")
                {
                    Destroy(myChild.gameObject);
                }
                else
                {
                    for (int i = 0; i < myChild.childCount; i++)
                    {
                        Destroy(myChild.GetChild(i).gameObject);
                    }
                }
            }
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }


        if (m_isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (myPlayer.transform.childCount > 2 && myPlayer.transform.GetChild(2).tag == "Plate") //player wants to put down a plate
            {
                Transform dish = myPlayer.transform.GetChild(2);
                if (dish.transform.childCount > 0) // the plate contains something
                {
                    dish.transform.SetParent(this.transform);
                    dish.transform.localPosition = new Vector3(0.5f, 0.5f, 0f);
                    myFood = dish;


                    setAnimators(true);
                }
            }
        }
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (myFood == null)
        {
            TimeUpAnimator.SetBool("TimeIsUp", false);
        }
        else
        {
            if (!FindObjectOfType <AudioManager>().IsPlaying("BurgerOnGrill"))
            {
                Debug.Log("complete firsti audio");
                if (!FindObjectOfType <AudioManager>().IsPlaying("OnGrill"))
                {
                    //FindObjectOfType<AudioManager>().PlayS("OnGrill");
                    FindObjectOfType <AudioManager>().Play("OnGrill");
                }
            }
        }

        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }
        if (isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (m_onGrill)
            {
                if (myPlayer.transform.childCount <= 2)
                {
                    //יש מירוץ בין לקחת את האובייקט מהקופסא ולהחזיר אותו לקופסא
                    //רק בכאלו שהם בלי אוכל, לא בקופסאות שמביאות אוכל
                    //לחשוב על משהו יפה
                    myFood.transform.SetParent(myPlayer.transform);
                    FindObjectOfType <AudioManager>().Stop("OnGrill");
                    this.myFood = null;
                    m_onGrill   = false;
                }
                return;
            }

            Transform myChild = myPlayer.transform.Find("Burger(Clone)").transform;
            if (myChild != null) // grill accepts only Burgers!!!
            {
                FindObjectOfType <AudioManager>().Play("BurgerOnGrill");

                myChild.transform.SetParent(this.transform); //parent is grill
                this.myFood = myChild;

                m_onGrill = true;
                myFood.transform.localPosition = new Vector3(0f, 0.44f, 0.9f);
                myBurger = this.myFood.GetComponent <burgerStates>();
                TimeUpAnimator.SetBool("TimeIsUp", true);
            }
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }

        if (m_isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (myPlayer.transform.childCount <= 2) // doesn't hold a thing
            {
                Instantiate(myFood).transform.SetParent(myPlayer.transform);
            }
        }
    }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        if (!youCanClick)
        {
            if (m_getInfo.ReturnIfPressed())
            {
                return;
            }
            youCanClick = true;
        }

        if (isCollideWithPlayer && m_getInfo.ReturnIfPressed()) // if theres a collision and the pickup button is pressed
        {
            youCanClick = false;
            if (m_takeFrom)
            {
                if (myPlayer.transform.childCount <= 2)
                {
                    myFood.transform.SetParent(myPlayer.transform);
                    m_takeFrom  = false;
                    this.myFood = null;
                }

                //צריכים לחשב יותר טוב איפה שמים כל אובייקט מבחינת המרכיבים בהמבורגר
                else if (myPlayer.transform.childCount == 3 && myFood.tag == "Plate") // object on plate
                {
                    Transform child = myPlayer.transform.GetChild(2);
                    if (child.tag == "Food") // כי אני לא רוצה לשים צלחת על צלחת, אין היגיון
                    {
                        Transform myBread = myFood.transform.Find("Bread(Clone)");
                        Transform myTopBun = null, myBottomBun = null;
                        //אם יש לחמניה בצלחת, והאובייקט שהשחקן רוצה להניח הוא לא לחמניה(אין היגיון בלשים לחמניה על לחמניה)
                        if (myBread != null && child.name != "Bread(Clone)")
                        {
                            myTopBun    = myBread.transform.Find("TopBun");
                            myBottomBun = myBread.transform.Find("BottomBun");

                            myTopBun.transform.localPosition = new Vector3(
                                myTopBun.transform.localPosition.x,
                                myTopBun.transform.localPosition.y + 0.2f,     // move up a little
                                myTopBun.transform.localPosition.z);
                        }
                        child.transform.SetParent(myFood.transform);
                        if (child.name == "Burger(Clone)")
                        {
                            if (myTopBun != null)
                            {
                                child.transform.localPosition = new Vector3(
                                    0f,
                                    myTopBun.transform.localPosition.y -
                                    myBottomBun.transform.localPosition.y - 0.6f, // move down a little
                                    0f);
                            }
                            else
                            {
                                child.transform.localPosition = new Vector3(0f, 0.161f, 0f);
                            }
                        }
                        else // if it's a plate(need to think about something better ofcourse
                        {
                            child.transform.localPosition = new Vector3(0f, 0f, 0f);
                        }
                        //   m_timeBetweenTrades = Time.realtimeSinceStartup;
                    }
                }
            }
            else
            {
                for (int i = 0; i < myPlayer.transform.childCount; i++)// שחקן מניח אובייקט
                {
                    Transform child = myPlayer.transform.GetChild(i);
                    if (child.tag == "Food" || child.tag == "Plate") // if theres a Food/plate child
                    {
                        if (child.tag == "Plate")
                        {
                            FindObjectOfType <AudioManager>().Play("PlacePlate");
                        }
                        child.transform.SetParent(this.transform);
                        this.myFood = child;
                        // myFood.transform.localPosition = Vector3.zero;
                        if (child.tag == "Food")
                        {
                            myFood.transform.localPosition = new Vector3(0f, 0f, 1.1f);
                        }
                        else // זו צלחת
                        {
                            myFood.transform.localPosition = new Vector3(0f, 0f, 1.2f);
                        }
                        m_takeFrom = true;

                        //   m_timeBetweenTrades = Time.realtimeSinceStartup; // object moved from player to container
                        break;
                    }
                }
            }
        }
        else
        {
            //maybe need maybe not. probabely need to put back the item
            // forDebug = true;
        }
    }
示例#7
0
    void FixedUpdate()
    {
        if (m_sinkCollide)
        {
            handleSinkAction();
        }

        if (!m_Animator.GetBool("timeToWash"))
        {
            m_Animator.SetBool("isButtonClicked", m_btn.ReturnIfPressed());
        }
        float horizontal = joystick.Horizontal * 10f;
        float vertical   = joystick.Vertical * 10f;

        m_rigidbody.velocity = new Vector3(joystick.Vertical * -10,
                                           m_rigidbody.velocity.y,
                                           joystick.Horizontal * 10);


        bool hasHorizontalInput = !Mathf.Approximately(vertical, 0f);
        bool hasVerticalInput   = !Mathf.Approximately(horizontal, 0f);
        bool isWalking          = hasHorizontalInput || hasVerticalInput;


        for (int i = 0; i < this.transform.childCount; i++) // going threw all childs
        {
            Transform child = this.transform.GetChild(i);
            if (child.tag == "Food" || child.tag == "Plate") // if theres a Food child, then player isHoling, and break
            {
                m_Animator.SetBool("IsHolding", true);
                Vector3 playerLoc = this.transform.localPosition;



                if (m_Animator.GetCurrentAnimatorStateInfo(0).IsName("standingWith"))
                {
                    if (child.tag == "Food")
                    {
                        child.localPosition = new Vector3(playerLoc.x + 10, playerLoc.y + 45, playerLoc.z + 30);
                    }
                    else
                    {
                        child.localPosition = new Vector3(playerLoc.x + 20, playerLoc.y + 60, playerLoc.z + 40);
                    }
                }

                break;
                //10, 45, 30
            }
            m_Animator.SetBool("IsHolding", false); // if never break, then
        }

        m_Animator.SetBool("IsWalking", isWalking);



        if (isWalking)
        {
            if (!forWalking.IsPlaying("PlayerWalk"))
            {
                forWalking.Play("PlayerWalk");
            }
        }
        else
        {
            forWalking.Stop("PlayerWalk");
        }



        Vector3 desiredForward = Vector3.RotateTowards
                                     (transform.forward, m_rigidbody.velocity, turnSpeed * Time.deltaTime, 0f);

        m_Rotation = Quaternion.LookRotation(desiredForward);
    }