本文整理汇总了C#中MazeDirection类的典型用法代码示例。如果您正苦于以下问题:C# MazeDirection类的具体用法?C# MazeDirection怎么用?C# MazeDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MazeDirection类属于命名空间,在下文中一共展示了MazeDirection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
MazeCell cell = hit.gameObject.GetComponentInParent<MazeCell>();
if (cell == null)
return;
if(cell != currentCell)
{
if(currentCell != null)
currentCell.OnPlayerExit();
cell.OnPlayerEnter();
}
currentCell = cell;
Vector3 transformDirection = new Vector3(Mathf.Round(transform.forward.x), 0f, Mathf.Round(transform.forward.z));
IntVector2 direction = new IntVector2((int) transformDirection.x, (int) transformDirection.z);
if(direction.x != 0 && direction.z != 0)
{
if (Random.Range(0, 1) == 1)
direction.x = 0;
else
direction.z = 0;
}
MazeDirection mazeDirection = MazeDirections.FromIntVector2(direction);
faceDirection = mazeDirection;
}
示例2: Move
private void Move(MazeDirection direction){
//Debug.Log (currentCell.coordinates.x + ", " + currentCell.coordinates.z);
MazeCellEdge edge = currentCell.GetEdge (direction);
if (edge is MazePassage) {
SetLocation (edge.otherCell);
}
}
示例3: Initialize
public override void Initialize (MazeCell primary, MazeCell other, MazeDirection direction)
{
float localX = hinge.localScale.x;
float localY = hinge.localScale.y;
float localZ = hinge.localScale.z;
base.Initialize(primary, other, direction);
if (OtherSideOfDoor != null)
{
isMirrored = true;
hinge.localScale = new Vector3(-localX, localY, localZ);
Vector3 p = hinge.localPosition;
p.x *= -1;
hinge.localPosition = p;
}
for (int i = 0; i < transform.childCount; i++)
{
Transform child = transform.GetChild(i);
if (child != hinge)
{
child.GetComponent<Renderer>().material = cell.room.settings.wallMaterial;
}
}
}
示例4: CreatePassage
// creates a passage between the specified cells
private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
{
MazePassage passage = Instantiate(passagePrefab) as MazePassage;
passage.Initialize(cell, otherCell, direction);
passage = Instantiate(passagePrefab) as MazePassage;
passage.Initialize(otherCell, cell, direction.GetOpposite());
}
示例5: Initialize
public virtual void Initialize (MazeCell cell, MazeDirection direction = MazeDirection.North) {
this.cell = cell;
this.direction = direction;
transform.parent = cell.transform;
transform.localPosition = Vector3.zero;
transform.localRotation = direction.ToRotation();
}
示例6: ToString
public override string ToString()
{
MazeDirection[] directions = new MazeDirection[5] { MazeDirection.None, MazeDirection.Up, MazeDirection.Right, MazeDirection.Down, MazeDirection.Left };
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("X: {0}", this.X));
sb.AppendLine(string.Format("Y: {0}", this.Y));
sb.AppendLine(string.Format("CanContinueBuild: {0}", this.CanContinueBuild));
sb.AppendLine(string.Format("Built: {0}", this.HasPath));
sb.AppendLine(string.Format("BuildDirections: "));
foreach (MazeDirection direction in directions)
{
if (this.BuildDirections.Contains(direction))
{
sb.Append(string.Format(" {0} ", direction));
}
}
sb.AppendLine(string.Format("ExploreDirections: "));
foreach (MazeDirection direction in directions)
{
if (this.ExploreDirections.Contains(direction))
{
sb.Append(string.Format(" {0} ", direction));
}
}
return sb.ToString();
}
示例7: Move
private void Move(MazeDirection direction)
{
MazeCellEdge edge = currentCell.GetEdge(direction);
if (edge is MazePassage) {
SetLocation(edge.otherCell);
}
}
示例8: CreateWall
private void CreateWall(MazeCell cell, MazeCell otherCell, MazeDirection direction){
MazeWall wall = Instantiate (wallFab) as MazeWall;
wall.Initialize (cell, otherCell, direction);
if(otherCell != null){
wall = Instantiate (wallFab) as MazeWall;
wall.Initialize (otherCell, cell, direction.GetOpposite ());
}
}
示例9: Initialize
public void Initialize (MazeCell cell, MazeCell 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();
}
示例10: CreateWall
public void CreateWall(MazeCell cell, MazeCell otherCell, MazeDirection direction)
{
MazeWall wall = Instantiate(wallprefabs[Random.Range(0, wallprefabs.Length)]) as MazeWall;
wall.Initialize(cell, otherCell, direction);
if(otherCell != null)
{
wall = Instantiate(wallprefabs[Random.Range(0, wallprefabs.Length)]) as MazeWall;
wall.Initialize(otherCell, cell, direction.GetOpposite());
}
}
示例11: CreatePassage
private void CreatePassage(MazeCell cell, MazeCell otherCell, MazeDirection direction)
{
MazePassage prefab = Random.value < doorProbability ? doorPrefab : passagePrefab;
MazePassage passage = Instantiate(prefab) as MazePassage;
passage.Initialize(cell, otherCell, direction);
passage = Instantiate(prefab) as MazePassage;
if (passage is MazeDoor) {
otherCell.Initialize(CreateRoom(cell.room.settingsIndex));
}
else {
otherCell.Initialize(cell.room);
}
passage.Initialize(otherCell, cell, direction.GetOpposite());
}
示例12: CreateAllCellsAndHallwaysBasedOnGraph
private void CreateAllCellsAndHallwaysBasedOnGraph() {
if (transform.localScale != new Vector3(1f, 1f, 1f)) {
transform.localScale = new Vector3(1f, 1f, 1f);
}
MazeDirection[] dirs = new MazeDirection[] { MazeDirection.North, MazeDirection.South, MazeDirection.East, MazeDirection.West };
//a cell will exist at each node
for (int i = 0; i < MazeGrid.x; i++) {
for (int j = 0; j < MazeGrid.y; j++) {
CreateCell(new IntVector2(i, j));
}
}
//decide whether to place walls or doors in each of the 4 directions around a cell
for (int i = 0; i < MazeGrid.x; i++) {
for (int j = 0; j < MazeGrid.y; j++) {
foreach (var dir in dirs) {
IntVector2 move = dir.ToIntVector2();
IntVector2 newCoord = move + new IntVector2(i, j);
if (ValidCoordinate(newCoord)) {
GraphNode node1 = MazeGrid.grid[i, j];
GraphNode node2 = MazeGrid.grid[newCoord.x, newCoord.z];
//check if edge exists if the new coordinate was valid:
if (MazeGrid.GetEdge(node1, node2) == null) {
CreateWall(cells[i, j], GetCell(newCoord), dir);
}
else {
CreatePassage(cells[i, j], GetCell(newCoord), dir);
}
}
else {
CreateWall(cells[i, j], null, dir);
}
}
}
}
//loop through edges and create hallways
foreach (var e in MazeGrid.edgeList) {
CreateHallway(e);
}
//make the maze bigger or smaller as desired
transform.localScale = new Vector3(MazeScale, MazeScale, MazeScale);
}
示例13: Move
private void Move (MazeDirection direction)
{
MazeCellEdge edge = currentCell.GetEdge(direction);
if (edge is MazePassage)
{
SetLocation(edge.otherCell);
audio.Stop();
audio.PlayOneShot(_Footsteps, 0.5f);
}
else
{
audio.Stop();
audio.PlayOneShot(_cantMove[Random.Range(0, _cantMove.Length)], 1f);
}
}
示例14: Initialize
public override void Initialize(MazeCell primary, MazeCell other, MazeDirection direction)
{
base.Initialize(primary, other, direction);
if (OtherSideOfDoor != null) {
hinge.localScale = new Vector3(-1f, 1f, 1f);
Vector3 p = hinge.localPosition;
p.x = -p.x;
hinge.localPosition = p;
}
for (int i = 0; i < transform.childCount; i++) {
Transform child = transform.GetChild(i);
if (child != hinge) {
child.GetComponent<Renderer>().material = cell.room.settings.wallMaterial;
}
}
}
示例15: Move1
private void Move1(MazeDirection direction,bool playsound)
{
MazeCell nextcell = Maze.instance.getLongNextMazeCell(currentCell, direction);
directionKeyWating = MazeDirection.None;// khong
setRotation(direction);
currentDirection = direction;
if (nextcell != null)
{
SetLocation(nextcell);
targetCell = nextcell;
}
if(playsound)
{
SoundEngine.playLoop(SoundEngine.instance.move);
}
}