Ejemplo n.º 1
0
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            if (UIManager.ins.uistate == UIManager.UIState.PAUSE)
            {
                Resume();
            }
            else if (UIManager.ins.uistate == UIManager.UIState.PLAY_GAME)
            {
                Pause();
            }
        }

        if (UIManager.ins.uistate != UIManager.UIState.PLAY_GAME)
        {
            return;
        }

        unitsManager.SpawnUnits();
        TimerCountdown();

        if (Input.touchCount > 0 || Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider != null && hit.collider.tag == "unit")
                {
                    hit.collider.GetComponent <BaseUnit>().PushOnUnit();
                }
            }
        }
    }