コード例 #1
0
    public override void ControlledUpdate()
    {
        if (Running)
        {
            //TIMER
            GameTime += Time.deltaTime;
            if (GameTime >= Timer)
            {
                Complete();
            }

            if (timerobj == null)
            {
                timerobj = MUI["kitchen"];
            }

            float timer_ui = (Timer - GameTime);
            int   secs     = (int)timer_ui % 60;

            timerobj.Txt[1].text  = "SERVING IN";
            timerobj.Txt[1].color = Color.white;
            timerobj.Txt[0].text  = (int)timer_ui + "";
            timerobj.Txt[0].color = (GameTime > Timer * 0.75F) ? Color.red : Color.white;

            if (secs != last_sec)
            {
                last_sec = secs;
                if (GameTime > Timer * 0.75F)
                {
                    Tweens.Bounce(timerobj.Txt[0].transform,
                                  Vector3.one + (Vector3.one * GameTime / Timer / 2));
                }
            }

            //TARGET GRAND

            if (Input.GetMouseButtonUp(0))
            {
                GameManager.instance.SetTargetGrand(null);
                ReleaseTarget();
            }

            if (Target != null)
            {
                if (isDragging)
                {
                    if (drag_targ == null)
                    {
                        drag_targ = Target.Seat;
                    }
                    _Seat n = _TableManager.NearestSeat(GameManager.InputPos);
                    if (n != drag_targ)
                    {
                        drag_targ.Reset();
                        drag_targ = n;
                        drag_targ.Highlight(true);
                    }

                    Vector3 dpos = GameManager.InputPos;
                    dpos.z = Target.TargetFace.T.position.z;

                    Vector3 npos = Vector3.Lerp(Target.TargetFace.pos, dpos, Time.deltaTime * 15);
                    Target.TargetFace.T.position = npos;

                    Target.TargetFace.T.rotation = Quaternion.Slerp(
                        Target.TargetFace.T.rotation,
                        Quaternion.LookRotation(GameManager.InputPos - Target.TargetFace.T.position, Vector3.up),
                        Time.deltaTime * 10);
                    Target.GrumpLines(0.8F, true);
                }
                else
                {
                    Vector3 dpos = GameManager.InputPos;
                    dpos.z = Target.TargetFace.transform.position.z;
                    Vector3 vel = dpos - Target.Seat.Position;
                    Target.TargetFace.transform.position = Target.Seat.Position + vel / 5;
                    Target.TargetFace.T.rotation         = Quaternion.Slerp(
                        Target.TargetFace.T.rotation,
                        Quaternion.LookRotation(GameManager.InputPos - Target.TargetFace.T.position, Vector3.up),
                        Time.deltaTime * 10);
                    Target.GrumpLines(0.8F, true);
                    if (Vector3.Distance(dpos, Target.TargetFace.transform.position) > drag_distance)
                    {
                        isDragging = true;
                    }
                }
            }
        }
    }