• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MazeDirection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MazeDirection的典型用法代码示例。如果您正苦于以下问题:C# MazeDirection类的具体用法?C# MazeDirection怎么用?C# MazeDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MazeDirection类属于命名空间,在下文中一共展示了MazeDirection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AddSignPost

    //initialize a directional signpost pointing in direction dir and in a quadrant of the cell not
    //containing the player located at playerPosition.
    public void AddSignPost(MazeDirection dir, Vector3 playerPosition) {

        if (signpostInstance != null) {
            return;
        }

        signpostInstance = Instantiate(signpostPrefab) as DirectionalSignPost;
        signpostInstance.transform.parent = transform;

        Vector3 relativePos = playerPosition - transform.localPosition;

        signpostInstance.transform.localPosition = new Vector3(
            (relativePos.x <= 0 ? 0.25f : -0.25f), 
            -1.5f,
            (relativePos.z <= 0 ? 0.25f : -0.25f)
        );

        signpostInstance.transform.localRotation *= dir.ToRotation();
    }
开发者ID:iangonzalez,项目名称:mouse-in-a-maze-game,代码行数:21,代码来源:MazeCell.cs


示例17: moveContinue

 private void moveContinue(MazeDirection _direction)// khi dang di chuyen ma co nut nhan
 {
     if((currentDirection == MazeDirection.North && _direction == MazeDirection.South ) ||
         (currentDirection == MazeDirection.South && _direction == MazeDirection.North ) ||
         (currentDirection == MazeDirection.East && _direction == MazeDirection.West ) ||
         (currentDirection == MazeDirection.West && _direction == MazeDirection.East ) )
     {
         
         MazeCell tempCurrentcell = Maze.instance.findCell(transform.position);
         MazeCell nextcell = currentCell;//.instance.getLongNextMazeCell(currentCell, _direction);
         // directionKeyWating = MazeDirection.None;// khong 
         setRotation(_direction);
         if (nextcell != null)
         {
             currentCell = tempCurrentcell;
             SetLocation(nextcell);
             targetCell = nextcell;               
         }
         // dung la
     }
     
    
 }
开发者ID:hoangwin,项目名称:raci-ngc-ar_Du-o-iHin-hBa-tC-Hu,代码行数:23,代码来源:Player.cs


示例18: AdvanceBuild

        public MazeCell AdvanceBuild(MazeCell mazeCell, MazeDirection mazeDirection)
        {
            MazeCell newHead = null;

            if (mazeCell != null)
            {
                switch (mazeDirection)
                {
                    case MazeDirection.Up:
                        newHead = this.MazeCells[mazeCell.Y - 1][mazeCell.X];
                        break;
                    case MazeDirection.Right:
                        newHead = this.MazeCells[mazeCell.Y][mazeCell.X + 1];
                        break;
                    case MazeDirection.Down:
                        newHead = this.MazeCells[mazeCell.Y + 1][mazeCell.X];
                        break;
                    case MazeDirection.Left:
                        newHead = this.MazeCells[mazeCell.Y][mazeCell.X - 1];
                        break;
                }

                ((List<MazeDirection>)mazeCell.BuildDirections).Remove(mazeDirection);
                ((List<MazeDirection>)mazeCell.ExploreDirections).Add(mazeDirection);

                newHead.PreviousBuildCell = mazeCell;
                newHead.PreviousBuildDirection = this.oppositeDirection(mazeDirection);
                newHead.HasPath = true;
                ((List<MazeDirection>)newHead.BuildDirections).Remove(this.oppositeDirection(mazeDirection));
                ((List<MazeDirection>)newHead.ExploreDirections).Add(this.oppositeDirection(mazeDirection));

                if (newHead.Y > 0)
                {
                    MazeCell upCell = this.MazeCells[newHead.Y - 1][newHead.X];
                    if (upCell.HasPath)
                    {
                        ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Up);
                        ((List<MazeDirection>)upCell.BuildDirections).Remove(MazeDirection.Down);
                    }
                }

                if (newHead.X < this.Width - 1)
                {
                    MazeCell rightCell = this.MazeCells[newHead.Y][newHead.X + 1];
                    if (rightCell.HasPath)
                    {
                        ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Right);
                        ((List<MazeDirection>)rightCell.BuildDirections).Remove(MazeDirection.Left);
                    }
                }

                if (newHead.Y < this.Height - 1)
                {
                    MazeCell downCell = this.MazeCells[newHead.Y + 1][newHead.X];
                    if (downCell.HasPath)
                    {
                        ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Down);
                        ((List<MazeDirection>)downCell.BuildDirections).Remove(MazeDirection.Up);
                    }

                }

                if (newHead.X > 0)
                {
                    MazeCell leftCell = this.MazeCells[newHead.Y][newHead.X - 1];
                    if (leftCell.HasPath)
                    {
                        ((List<MazeDirection>)newHead.BuildDirections).Remove(MazeDirection.Left);
                        ((List<MazeDirection>)leftCell.BuildDirections).Remove(MazeDirection.Right);
                    }
                }
            }

            return newHead;
        }
开发者ID:giustizieri25,项目名称:MazeScreenSaver,代码行数:75,代码来源:Maze.cs


示例19: GetEdge

 public MazeCellEdge GetEdge(MazeDirection dir) {
     return this.edges[(int)dir];
 }
开发者ID:iangonzalez,项目名称:mouse-in-a-maze-game,代码行数:3,代码来源:MazeCell.cs


示例20: SetEdge

 public void SetEdge(MazeDirection dir, MazeCellEdge edge) {
     this.edges[(int)dir] = edge;
     this.initedEdgeCount += 1;
 }
开发者ID:iangonzalez,项目名称:mouse-in-a-maze-game,代码行数:4,代码来源:MazeCell.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Measurement类代码示例发布时间:2022-05-24
下一篇:
C# MazeCell类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap