public void Initialize(MazeCell cell, MazeCell otherCell, MazeDirection direction) { this.direction = direction; this.gameObject.name = "Wall of " + cell.ToString() + " " + direction.ToString(); transform.parent = cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); }
public void Move(MazeDirection direction) { if (this.Solved) { return; } int dx, dy; switch (direction) { case MazeDirection.Up: dx = 0; dy = -1; break; case MazeDirection.Down: dx = 0; dy = 1; break; case MazeDirection.Left: dx = -1; dy = 0; break; case MazeDirection.Right: dx = 1; dy = 0; break; default: throw new ArgumentOutOfRangeException("direction"); } var correctMazeDirection = this.GetCorrectDirection(); if (direction == correctMazeDirection) { this.resetTime = 10; ++this.SolveProgress; if (this.SolveProgress >= defaultSolutionTable.GetLength(2)) { this.Log("The correct sequence was entered ({0}).", Enumerable.Range(0, this.SolveProgress).Select(i => this.GetCorrectDirection(i).ToString()[0]).Join("")); this.Disarm(); this.resetTime = 0; } else { var position = this.Position + new Vector2Int(dx, dy); if (position.x < 0 || position.x >= 6 || position.y < 0 || position.y >= 6) { return; } this.Connector.SetPosition(this.Position = position); } } else { this.Log("An incorrect sequence was entered ({0}{1}); the correct button was {2}.", Enumerable.Range(0, this.SolveProgress).Select(i => this.GetCorrectDirection(i).ToString()[0]).Join(""), direction.ToString()[0], correctMazeDirection); this.Connector.KMBombModule.HandleStrike(); this.Connector.ShowWall(this.Position, direction); this.SolveProgress = 0; this.resetTime = 0; this.Connector.SetPosition(this.Position = this.startPosition); } }
public void Initialize(MazeCellv2 cell, MazeCellv2 otherCell, MazeDirection direction) { this.cell = cell; this.otherCell = otherCell; this.direction = direction; cell.SetEdge(direction, this); transform.parent = cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); transform.name = direction.ToString(); }
public void Initialize(MazeCell _cell, MazeCell _otherCell, MazeDirection _direction, EdgeType _type) { cell = _cell; otherCell = _otherCell; direction = _direction; edgeType = _type; cell.SetEdge(direction, this); transform.name += direction.ToString(); transform.parent = _cell.transform; transform.localPosition = Vector3.zero; transform.localRotation = direction.ToRotation(); }
private void CreateWall(MazeCellv2 cell, MazeCellv2 otherCell, MazeDirection direction) { MazeWall wall = Instantiate(wallPrefabs[Random.Range(0, wallPrefabs.Length)]) as MazeWall; wall.Initialize(cell, otherCell, direction); if (direction == MazeDirection.North || direction == MazeDirection.South) { } if (otherCell != null) { wall = Instantiate(wallPrefabs[1]) as MazeWall; wall.Initialize(otherCell, cell, direction.GetOpposite()); wall.transform.name = direction.ToString() + " its opposite"; wall.gameObject.SetActive(false);// TODO change if (direction == MazeDirection.North || direction == MazeDirection.South) { } } }
public static string ToString(this MazeDirection direction) { return(direction.ToString()); }