Beispiel #1
0
    void Update()
    {
        if (m_actionHappening == false)  //no action in use
        {
            if (Input.GetMouseButton(0)) //Left Click
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit)) //Check for ray collision
                {
                    if (hit.collider.name == "Food")
                    {
                        m_actionHappening = true;
                        m_food            = true;
                        m_notFood         = m_water = m_notWater = m_clean = m_notClean = false;
                    }
                    else if (hit.collider.name == "Water")
                    {
                        m_actionHappening = true;
                        m_water           = true;
                        m_food            = m_notFood = m_notWater = m_clean = m_notClean = false;
                    }
                    else if (hit.collider.name == "Clean")
                    {
                        m_actionHappening = true;
                        m_clean           = true;
                        m_food            = m_notFood = m_water = m_notWater = m_notClean = false;
                    }
                    else if (hit.collider.name == this.name)
                    {
                        m_actionHappening = true;
                        m_food            = m_notFood = m_water = m_notWater = m_clean = m_notClean = false;
                        StartCoroutine(InteractionBool());
                    }
                }
            }
        }

        if (m_deCounter >= m_deTimer)
        {
            m_deCounter = 0.0f;
            m_pad.NoInteractions("No Interaction");
        }

        m_deCounter += Time.deltaTime;

        if (m_food)
        {
            MoveToFood();
        }
        else if (m_notFood)
        {
            MoveFromFood();
        }
        else if (m_water)
        {
            MoveToWater();
        }
        else if (m_notWater)
        {
            MoveFromWater();
        }
        else if (m_clean)
        {
            MoveToClean();
        }
        else if (m_notClean)
        {
            MoveFromClean();
        }

        //#if UNITY_ANDROID

        //if (Input.touchCount > 0)
        //{
        //    Debug.Log("TOUCH");
        //}

        //if (m_actionHappening == false) //no action in use
        //{
        //    if (Input.touchCount > 0)
        //    {
        //        Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
        //        RaycastHit hit;
        //        if (Physics.Raycast(ray, out hit)) //Check for ray collision
        //        {
        //            if (hit.collider.name == "Food")
        //            {
        //                m_actionHappening = true;
        //                m_food = true;
        //                m_notFood = m_water = m_notWater = m_clean = m_notClean = false;
        //            }
        //            else if (hit.collider.name == "Water")
        //            {
        //                m_actionHappening = true;
        //                m_water = true;
        //                m_food = m_notFood = m_notWater = m_clean = m_notClean = false;
        //            }
        //            else if (hit.collider.name == "Clean")
        //            {
        //                m_actionHappening = true;
        //                m_clean = true;
        //                m_food = m_notFood = m_water = m_notWater = m_notClean = false;
        //            }
        //            else if (hit.collider.name == this.name)
        //            {
        //                m_actionHappening = true;
        //                m_food = m_notFood = m_water = m_notWater = m_clean = m_notClean = false;
        //            }
        //        }
        //    }
        //}

        //if (m_deCounter >= m_deTimer)
        //{
        //    m_deCounter = 0.0f;
        //    m_pad.NoInteractions("No Interaction");
        //}

        //m_deCounter += Time.deltaTime;

        //if (m_food) MoveToFood();
        //else if (m_notFood) MoveFromFood();
        //else if (m_water) MoveToWater();
        //else if (m_notWater) MoveFromWater();
        //else if (m_clean) MoveToClean();
        //else if (m_notClean) MoveFromClean();

        ////#endif
    }
Beispiel #2
0
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.name == "Food")
                {
                    m_food    = true;
                    m_notFood = m_water = m_notWater = m_clean = m_notClean = false;

                    for (int i = 0; i < m_nodebool.Length; i++)
                    {
                        m_nodebool[i] = false;
                    }
                }
                else if (hit.collider.name == "Water")
                {
                    m_water   = true;
                    m_notFood = m_food = m_notWater = m_clean = m_notClean = false;

                    for (int i = 0; i < m_nodebool.Length; i++)
                    {
                        m_nodebool[i] = false;
                    }
                }
                else if (hit.collider.name == "Clean")
                {
                    m_clean   = true;
                    m_notFood = m_water = m_notWater = m_food = m_notClean = false;

                    for (int i = 0; i < m_nodebool.Length; i++)
                    {
                        m_nodebool[i] = false;
                    }
                }
                else if (hit.collider.name == this.name)
                {
                    if (m_inter == false)
                    {
                        m_inter = true;
                        m_pad.Interactions("Interaction");
                        Debug.Log("INTER");
                        m_deCounter = 0.0f;
                        StartCoroutine(InteractionBool());
                    }
                }
            }
        }

        if (m_deCounter >= m_deTimer)
        {
            m_deCounter = 0.0f;
            Debug.Log("NO INTER");
            m_pad.NoInteractions("No Interaction");
        }

        m_deCounter += Time.deltaTime;

        if (m_food)
        {
            MoveToFood();
        }
        else if (m_notFood)
        {
            MoveFromFood();
        }
        else if (m_water)
        {
            MoveToWater();
        }
        else if (m_notWater)
        {
            MoveFromWater();
        }
        else if (m_clean)
        {
            MoveToClean();
        }
        else if (m_notClean)
        {
            MoveFromClean();
        }
    }