void PickNewDirection(out Vector3Int move, out bool skip) { skip = false; move = Vector3Int.zero; List <Vector3Int> moves = new List <Vector3Int>(directions); moves.Shuffle(); for (int i = 0; i < moves.Count; i++) { if (moveAction.IsValidMovePosition(Position + moves[i])) { move = moves[i]; return; } } skip = true; }
bool HandleInput(out Vector3Int move, out bool skip) { int x = 0; int y = 0; skip = false; if (Input.GetKey(KeyCode.Space)) { skip = true; move = Vector3Int.zero; return(true); } else if (Input.GetKey(KeyCode.RightArrow)) { x = 1; } else if (Input.GetKey(KeyCode.LeftArrow)) { x = -1; } else if (Input.GetKey(KeyCode.UpArrow)) { y = 1; } else if (Input.GetKey(KeyCode.DownArrow)) { y = -1; } if (x != 0 || y != 0) { move = new Vector3Int(x, y, 0); if (moveAction.IsValidMovePosition(Position + move)) { return(true); } } move = Vector3Int.zero; return(false); }