// Update is called once per frame
    void Update()
    {
        if (!GamePaused && _moving)
        {
            Vector3 position = this.transform.position;

            if (_position == EDoorPosition.high)
            {
                position.y -= _speed * Time.deltaTime;

                if (position.y <= Constants.DOOR_LOW_Y_POS)
                {
                    position.y = Constants.DOOR_LOW_Y_POS;
                    _moving    = false;
                    _position  = EDoorPosition.low;
                }
            }
            else if (_position == EDoorPosition.low)
            {
                position.y += _speed * Time.deltaTime;

                if (position.y >= Constants.DOOR_HIGH_Y_POS)
                {
                    position.y = Constants.DOOR_HIGH_Y_POS;
                    _moving    = false;
                    _position  = EDoorPosition.high;
                }
            }

            this.transform.position = position;
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!GamePaused && _moving)
        {
            Vector3 position = this.transform.position;

            if (_position == EDoorPosition.high)
            {
                position.y -= _speed * Time.deltaTime;

                if (position.y <= _lowPosition)
                {
                    position.y = _lowPosition;
                    _moving    = false;
                    _position  = EDoorPosition.low;
                }
            }
            else if (_position == EDoorPosition.low)
            {
                position.y += _speed * Time.deltaTime;

                if (position.y >= _highPosition)
                {
                    position.y = _highPosition;
                    _moving    = false;
                    _position  = EDoorPosition.high;
                }
            }

            this.transform.position = position;
        }
    }