// Update is called once per frame
    public void GuestUpdate()
    {
        if (Status == Action.RIDING)
        {
            _currentConveyance.ConveyanceUpdate(this);
        }
        if (Status == Action.BATHING)
        {
            _bathTime += Time.deltaTime; //_bathTime = _bathTime + Time.deltaTime
            if (_bathTime > BathTime)
            {
                Status    = Action.WALKING;
                _bathTime = 0;
                Destination.RemoveGuest(this);
                _destinations.RemoveAt(0);

                GameObject entrance = GameObject.Find("Entrance");
                Destination = entrance.GetComponent <Destination>();
                UpdateDestination();
                FindPath();
            }
            //++++
            return; //so it doesn't run any code below
        }

        //guard statement
        if (Destination == null)
        {
            return;            //return stops the update here until next frame
        }
        DestinationDistance(); //++++
    }
Example #2
0
    // Update is called once per frame
    public void GuestUpdate()
    {
        if (Status == Action.RIDING)
        {
            _currentConveyance.ConveyanceUpdate(this);
        }
        if (Status == Action.BATHING)
        {
            _bathTime += Time.deltaTime; //_bathTime = _bathTime + Time.deltaTime
            if (_bathTime > BathTime)
            {
                _tempDestination = Destination;
                Destination      = null;

                if (Baths == 0) //if guest is done with baths
                {
                    GameObject entrance = GameObject.Find("Entrance");
                    Destination = entrance.GetComponent <Destination>();
                }
                else //if guest needs new bath assigned
                {
                    GuestManager.Instance.AssignOpenBath(this, Destination); //Destination is assigned inside metho
                }
                if (Destination == null)
                {
                    return;
                }

                //_tempDestination.RemoveGuest(this); //remove guest from current bath
                _destinations[0].RemoveGuest(this); //remove guest from current bath
                _destinations.RemoveAt(0);          //remove current bath from destination list
                _bathTime = 0;                      //reseting bath time
                Status    = Action.WALKING;         //start walking
                //*UpdateDestination();  <--- this line is not needed, since in the end of 'FindPath()', we will update destination anyway.
                FindPath();                         //finding best path
            }

            return; //so it doesn't run any code below
        }

        //guard statement
        if (Destination == null)
        {
            return;                      //return stops the update here until next frame
        }
        //orient gameobject direction
        if (_agent.enabled)
        {
            Vector3 forward = _agent.velocity;
            forward.y         = 0;
            transform.forward = forward;
        }
        DestinationDistance(); //++++
    }
Example #3
0
    // Update is called once per frame
    public void GuestUpdate()
    {
        if (Status == Action.RIDING)
        {
            _currentConveyance.ConveyanceUpdate(this);
        }
        if (Status == Action.BATHING)
        {
            _bathTime += Time.deltaTime; //_bathTime = _bathTime + Time.deltaTime
            if (_bathTime > BathTime)
            {
                _tempDestination = Destination;
                Destination      = null;

                if (Baths == 0) //if guest is done with baths
                {
                    GameObject entrance = GameObject.Find("Entrance");
                    Destination = entrance.GetComponent <Destination>();
                }
                else //if guest needs new bath assigned
                {
                    GuestManager.Instance.AssignOpenBath(this); //Destination is assigned inside metho
                }
                if (Destination == null)
                {
                    return;
                }

                //_tempDestination.RemoveGuest(this); //remove guest from current bath
                _destinations[0].RemoveGuest(this); //remove guest from current bath
                _destinations.RemoveAt(0);          //remove current bath from destination list
                _bathTime = 0;                      //reseting bath time
                Status    = Action.WALKING;         //start walking
                UpdateDestination();                //update new destination
                FindPath();                         //finding best path
            }

            return; //so it doesn't run any code below
        }

        //guard statement
        if (Destination == null)
        {
            return;            //return stops the update here until next frame
        }
        DestinationDistance(); //++++
    }
Example #4
0
    // Update is called once per frame
    public virtual void GuestUpdate()
    {
        if (Status == Action.RANDOM)
        {
            _timer += Time.deltaTime;
            if (_timer >= _wanderTimer)
            {
                //*/
                List <Destination> baths = GuestManager.Instance.DestinationList();
                foreach (Destination bath in baths)
                {
                    float distance = Vector3.Distance(bath.transform.position, transform.position);
                    Debug.Log(distance);
                    if (distance > 15)
                    {
                        continue;
                    }
                    GuestWalkDestination();
                    return;
                }
                //*/

                Vector3 newPos = RandomNavSphere(transform.position, 100, -1);
                UpdateDestination(newPos);
                _timer       = 0;
                _wanderTimer = Random.Range(WanderTimer.x, WanderTimer.y);
                //Debug.Log("Wander Timer: " + _wanderTimer);
            }
            return;
        }
        if (Status == Action.RIDING)
        {
            _currentConveyance.ConveyanceUpdate(this);
        }
        if (Status == Action.BATHING)
        {
            _bathTime += Time.deltaTime; //_bathTime = _bathTime + Time.deltaTime
            if (_bathTime > BathTime)
            {
                _tempDestination = Destination;
                Destination      = null;

                if (Baths == 0) //if guest is done with baths
                {
                    Destination = GuestManager.Instance.RandomEntrance(this);
                }
                else //if guest needs new bath assigned
                {
                    GuestManager.Instance.AssignOpenBath(this, _visitedBaths); //Destination is assigned inside metho
                }
                if (Destination == null)
                {
                    return;
                }

                SetText("Walking");
                //_tempDestination.RemoveGuest(this); //remove guest from current bath
                _destinations[0].RemoveGuest(this);                  //remove guest from current bath
                _destinations.RemoveAt(0);                           //remove current bath from destination list
                _bathTime = 0;                                       //reseting bath time
                Status    = Action.WALKING;                          //start walking
                UpdateDestination();                                 //update new destination
                FindPath(ref _currentConveyance, ref _destinations); //finding best path
            }

            return; //so it doesn't run any code below
        }
        if (Status == Action.BATHRIDING)
        {
            _agent.enabled = false;
            _bathTime     += Time.deltaTime; //_bathTime = _bathTime + Time.deltaTime
            if (_bathTime > BathTime + 3f)
            {
                _tempDestination = Destination;
                Destination      = null;

                if (Baths == 0) //if guest is done with baths
                {
                    Destination = GuestManager.Instance.RandomEntrance(this);
                }
                else //if guest needs new bath assigned
                {
                    GuestManager.Instance.AssignOpenBath(this, _visitedBaths); //Destination is assigned inside metho
                }
                if (Destination == null)
                {
                    return;
                }

                SetText("Walking");
                //_tempDestination.RemoveGuest(this); //remove guest from current bath
                _destinations[0].RemoveGuest(this);                  //remove guest from current bath
                _destinations.RemoveAt(0);                           //remove current bath from destination list
                _bathTime      = 0;                                  //reseting bath time
                Status         = Action.WALKING;                     //start walking
                _agent.enabled = true;
                UpdateDestination();                                 //update new destination
                FindPath(ref _currentConveyance, ref _destinations); //finding best path
            }

            return; //so it doesn't run any code below
        }

        //guard statement
        if (Destination == null)
        {
            return;                      //return stops the update here until next frame
        }
        //orient gameobject direction
        if (_agent.enabled && _agent.velocity != Vector3.zero)
        {
            Vector3 forward = _agent.velocity;
            forward.y         = 0;
            transform.forward = forward;
        }

        if (Status == Action.WALKING)
        {
            if (Vector3.Distance(transform.position, Destination.transform.position) > 2.1f)
            {
                if (!Destination.GetComponentInParent <Conveyance>())
                {
                    UpdateDestination();
                }
            }
        }
        DestinationDistance(); //++++
    }