예제 #1
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            ToyController toyController = controller.target == null ? null : controller.target.GetComponent <ToyController>();

            if (toyController == null || !toyController.AnyLeft() || stateTime > controller.PlayTime)
            {
                if (stateTime > controller.PlayTime)
                {
                    controller.AddMood(controller.PlayMoodInc);
                }
                PlacementManager.Instance.GetPlayArea().MarkAsDirty();
                PlayerManager.Instance.MarkAsDirty();
                controller.SetState <SitState>();
            }
            else
            {
                toyController.Play();
            }
        }
예제 #2
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            ToyController toyController = controller.chaseTarget == null ? null : controller.chaseTarget.Controller;

            if (toyController == null || controller.chaseTarget.ChasePosition == Vector3.zero || !toyController.AnyLeft() || stateTime > controller.PlayTime)
            {
                if (stateTime > controller.PlayTime)
                {
                    controller.AddMood(controller.PlayMoodInc);
                }
                PlacementManager.Instance.GetPlayArea().MarkAsDirty();
                PlayerManager.Instance.MarkAsDirty();
                controller.chaseTarget = null;
                controller.SetState <SitState>();
            }
            else
            {
                Vector3 targetWorldPos = PlacementManager.Instance.GetNavPos(controller.chaseTarget.ChasePosition);
                controller.transform.LookAt(targetWorldPos, PlacementManager.Instance.GetPlayArea().transform.up);
                float distToTarget  = Vector3.Distance(controller.transform.position, targetWorldPos);
                float worldStopDist = controller.StopDistance * controller.transform.lossyScale.x;
                if (distToTarget > 2f * worldStopDist)
                {
                    controller.SetState <ChaseState>();
                }
                else
                {
                    //controller.transform.LookAt(targetWorldPos, PlacementManager.Instance.GetPlayArea().transform.up);
                    toyController.Play();
                }
            }
        }