예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (Game != null && Game.Active)
        {
            CurrentTimer += Time.deltaTime;

            if (CurrentTimer >= Interval)
            {
                Process();
            }


            TimeLeft -= Time.deltaTime;



            if (TimeLeft <= 0f)
            {
                TimeLeft    = 0f;
                Game.Active = false;
                LevelFail();
            }

            TimeBar.sizeDelta = new Vector2(WidthOfBar / (CurrentLevel.seconds - AdjustTimeBy)
                                            * TimeLeft, TimeBar.sizeDelta.y);


            if (Input.GetMouseButton(0))
            {
                RaycastHit [] hits;
                Ray           ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                hits = Physics.RaycastAll(ray);

                SelectedDesk = null;

                foreach (RaycastHit hit in hits)
                {
                    if (hit.transform.gameObject.tag == "Monitor")
                    {
                        SelectedDesk = hit.transform.GetComponentInParent <Desk> ();
                        break;
                    }
                }

                if (SelectedDesk != null)
                {
                    SelectedDesk.Fix();

                    if (SelectedDesk.ComputerStatus != ComputerStatus.Normal)
                    {
                        FixBar.parent.parent.gameObject.SetActive(true);
                        FixBar.sizeDelta = new Vector2(WidthOfBar / GameController.Instance.MaximumFixTime * SelectedDesk.TimeToFix, FixBar.sizeDelta.y);
                    }
                    else
                    {
                        FixBar.parent.parent.gameObject.SetActive(false);
                    }
                }
                else
                {
                    FixBar.parent.parent.gameObject.SetActive(false);
                }
            }
            else
            {
                FixBar.parent.parent.gameObject.SetActive(false);
            }
        }
        else
        {
            Delay -= Time.deltaTime;

            if (Delay <= 0f && Input.GetMouseButtonDown(0))
            {
                if (Game == null)
                {
                    ResetGame();
                }
                else
                {
                    NewLevel();
                }
            }
        }
    }