Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, ActiveLayer))
            {
                _currentObj = hit.collider.gameObject;
                _system.Store(_currentObj, steps);
                steps = _system._spot;
            }
        }
        if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(0)) && _currentObj != null)
        {
            _system.Store(_currentObj, steps);
            steps = _system._spot;
        }

        if (!UseControl)
        {
            if (Input.GetKeyDown(ClearKey))
            {
                steps = _system._spot = 0;
                _system.StoredObj.Clear();
            }

            if (Input.GetKeyDown(UndoKey))
            {
                if (_system._spot > 1)
                {
                    steps--;
                    _system._spot--;
                    _system.Call(_system._spot - 1);
                }
            }

            if (Input.GetKeyDown(RedoKey))
            {
                if (_system._spot < _system.StoredObj.Count)
                {
                    steps++;
                    _system._spot++;
                    _system.Call(_system._spot - 1);
                }
            }
        }

        else
        {
            if (Input.GetKey(KeyCode.LeftControl))
            {
                if (Input.GetKeyDown(ClearKey))
                {
                    steps = _system._spot = 0;
                    _system.StoredObj.Clear();
                }

                if (Input.GetKeyDown(UndoKey))
                {
                    if (_system._spot > 1)
                    {
                        steps--;
                        _system._spot--;
                        _system.Call(_system._spot - 1);
                    }
                }

                if (Input.GetKeyDown(RedoKey))
                {
                    if (_system._spot < _system.StoredObj.Count)
                    {
                        steps++;
                        _system._spot++;
                        _system.Call(_system._spot - 1);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, ActiveLayer))
            {
                _currentObj = hit.collider.gameObject;
                _system.Store(_currentObj, steps);
                steps = _system._spot;
            }
        }
        if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(0) ||
             Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.LeftArrow) ||
             Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow)) && _currentObj != null)
        {
            _system.Store(_currentObj, steps);
            steps = _system._spot;
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            steps = _system._spot = 0;
            _system.StoredObj.Clear();
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (_system._spot > 1)
            {
                steps--;
                _system._spot--;
                _system.Call(_system._spot - 1);
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            if (_system._spot < _system.StoredObj.Count)
            {
                steps++;
                _system._spot++;
                _system.Call(_system._spot - 1);
            }
        }


        if (Input.GetKey(KeyCode.Z))
        {
            CurTime = CurTime - Time.deltaTime;
            if (_system._spot > 1 && CurTime < 0)
            {
                setTimer = setTimer - Time.deltaTime;
                if (setTimer < 0)
                {
                    steps--;
                    _system._spot--;
                    _system.Call(_system._spot - 1);
                    setTimer = DelayTime / 4;
                }
            }
        }

        if (Input.GetKey(KeyCode.R))
        {
            CurTime = CurTime - Time.deltaTime;
            if (_system._spot < _system.StoredObj.Count && CurTime < 0)
            {
                setTimer = setTimer - Time.deltaTime;
                if (setTimer < 0)
                {
                    steps++;
                    _system._spot++;
                    _system.Call(_system._spot - 1);
                    setTimer = DelayTime / 4;
                }
            }
        }

        if (!Input.GetKey(KeyCode.R) && !Input.GetKey(KeyCode.Z))
        {
            CurTime = DelayTime;
        }
    }