public void Initialize(Color groundColor, ViewModel.Grid transition) { Transition = transition; HiddenDoor = Instantiate(Manager.Game.Graphics.DoorBlock, transform); HiddenDoor.GetComponent <SpriteRenderer>().color = groundColor; }
void Update() { if (_canMove) { float translation = Input.GetAxis("Vertical") * _speed; float straffe = Input.GetAxis("Horizontal") * _speed; translation *= Time.deltaTime; straffe *= Time.deltaTime; transform.Translate(straffe, 0, translation); } if (Input.GetKeyDown(KeyCode.Escape)) { if (_cursorLocked) { Cursor.lockState = CursorLockMode.None; _cursorLocked = false; } else { Cursor.lockState = CursorLockMode.Locked; _cursorLocked = true; } } //Mouse Operations if (Input.GetMouseButtonDown(0) && !_cursorLocked && !GameManager.Instance._battleActive) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { //Operating Doors Door door = hit.transform.GetComponent <Door>(); if (door) { door.OperateDoor(); } //Operating Boxes Box box = hit.transform.GetComponent <Box>(); if (box) { box.OperateBox(); } //Operating Chests Chest chest = hit.transform.GetComponent <Chest>(); if (chest) { chest.OperateChest(); } //Revealing Hidden Doorways HiddenDoor hiddenDoor = hit.transform.GetComponent <HiddenDoor>(); if (hiddenDoor) { hiddenDoor.RevealDoorway(); } } } }
void Update() { if (_canMove && !_rotationInProgress && !_pathBlocked && (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))) { _canMove = false; _origPos = transform.position; StartCoroutine(MoveRoutine()); //if (!GameManager.Instance.CheckForPlayerOutOfSyncWithGrid()) //{ // Debug.LogError("PLAYER OUT OF POSITION! " + transform.position); // transform.position = _origPos; //} } //do an about-face... if (!_rotationInProgress && Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) { _rotationInProgress = true; _origPos = transform.position; StartCoroutine(RotatePlayer(Vector3.up * 180)); } //turn 90 deg to the right... if (!_rotationInProgress && Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { _rotationInProgress = true; StartCoroutine(RotatePlayer(Vector3.up * 90)); } //turn 90 deg to the left... if (!_rotationInProgress && Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { _rotationInProgress = true; StartCoroutine(RotatePlayer(Vector3.up * -90)); } //Mouse Operations if (Input.GetMouseButtonDown(0) && !GameManager.Instance._battleActive && !GameManager.Instance._bootyPanelOpen) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity)) { //Operating Doors Door door = hit.transform.GetComponent <Door>(); if (door) { door.OperateDoor(); } //Operating Boxes Box box = hit.transform.GetComponent <Box>(); if (box) { box.OperateBox(); } //Operating Chests Chest chest = hit.transform.GetComponent <Chest>(); if (chest) { chest.OperateChest(); } //Revealing Hidden Doorways HiddenDoor hiddenDoor = hit.transform.GetComponent <HiddenDoor>(); if (hiddenDoor) { hiddenDoor.RevealDoorway(); } } } //Light if (_haveLight && _lightOn) { _lightLifetime -= Time.deltaTime; } }