当前位置: 首页>>代码示例>>C#>>正文


C# MazeDirection类代码示例

本文整理汇总了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;
    }
开发者ID:thmundal,项目名称:Blendertest,代码行数:31,代码来源:Player.cs

示例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);
		}
	}
开发者ID:kleptodorf,项目名称:CS3013,代码行数:7,代码来源:Player2.cs

示例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;
            }
        }
    }
开发者ID:designerzim,项目名称:unity-Maze,代码行数:25,代码来源:MazeDoor.cs

示例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());
 }
开发者ID:RireMakar,项目名称:Unity-Backtracking,代码行数:8,代码来源:Maze.cs

示例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();
	}
开发者ID:papakaliati,项目名称:simplePrototypeOfPrototype,代码行数:7,代码来源:MazeObject.cs

示例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();
 }
开发者ID:giustizieri25,项目名称:MazeScreenSaver,代码行数:26,代码来源:MazeCell.cs

示例7: Move

 private void Move(MazeDirection direction)
 {
     MazeCellEdge edge = currentCell.GetEdge(direction);
     if (edge is MazePassage) {
         SetLocation(edge.otherCell);
     }
 }
开发者ID:futamiyuuki,项目名称:Unity-Chan,代码行数:7,代码来源:Player.cs

示例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 ());
		}
	}
开发者ID:kleptodorf,项目名称:CS3013,代码行数:8,代码来源:Maze.cs

示例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();
	}
开发者ID:Zoltaris,项目名称:MinotaurMaze,代码行数:9,代码来源:MazeCellEdge.cs

示例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());
     }
 }
开发者ID:thmundal,项目名称:Blendertest,代码行数:10,代码来源:Maze.cs

示例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());
 }
开发者ID:sabrinagreenlee,项目名称:JaneBound,代码行数:14,代码来源:Maze.cs

示例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);

    }
开发者ID:iangonzalez,项目名称:mouse-in-a-maze-game,代码行数:48,代码来源:Maze.cs

示例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);
        }    
        }
开发者ID:Zoltaris,项目名称:MinotaurMaze,代码行数:16,代码来源:Player.cs

示例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;
            }
        }
    }
开发者ID:northtwilight,项目名称:UnityMazeDemo,代码行数:17,代码来源:MazeDoor.cs

示例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);
        }
          
    }
开发者ID:hoangwin,项目名称:raci-ngc-ar_Du-o-iHin-hBa-tC-Hu,代码行数:17,代码来源:Player.cs


注:本文中的MazeDirection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。