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


C# Tile.Equals方法代码示例

本文整理汇总了C#中Tile.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.Equals方法的具体用法?C# Tile.Equals怎么用?C# Tile.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tile的用法示例。


在下文中一共展示了Tile.Equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test

 public void Test()
 {
     Tile tile1 = new Tile
     {
         TileSetId = 1,
         TileId = 2,
     };
     Tile tile2 = new Tile
     {
         TileSetId = 1,
         TileId = 2,
     };
     Tile tile3 = new Tile
     {
         TileSetId = 1,
         TileId = 3,
     };
     Assert.IsTrue(Tile.Equals(tile1, tile2));
     Assert.IsFalse(Tile.Equals(tile1, tile3));
     Assert.IsFalse(Tile.Equals(tile1, null));
     Assert.IsTrue(tile1.Equals(tile2));
     Assert.IsFalse(tile1.Equals(tile3));
     Assert.IsFalse(tile1.Equals(null));
     Assert.IsTrue(tile1 == tile2);
     Assert.IsFalse(tile1 != tile2);
     Assert.IsFalse(tile1 == tile3);
     Assert.IsTrue(tile1 != tile3);
     Assert.IsFalse(tile1 == null);
     Assert.IsTrue(tile1 != null);
 }
开发者ID:hajimehoshi,项目名称:shrimp,代码行数:30,代码来源:TileTest.cs

示例2: EqualsTest

 public void EqualsTest()
 {
     Tile target = new Tile(); // TODO: Initialize to an appropriate value
     object obj = null; // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     actual = target.Equals(obj);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
开发者ID:holtkampw,项目名称:UH-Sample-XNA-Project,代码行数:10,代码来源:TileTest.cs

示例3: FindPath

    /*
     * Finds the shortest path from the player's position to the goal tile.
     * Note that this returns the path as a link list and the front of the list
     * is the end of the path.
     *
     * Arguments
     * - Tile goal - The goal of the path
     * - bool allowBlockedGoal - Allow us to keep looking if the goal is blocked
     * - bool stealth - Stops finding a path if the distance is too far. Used by Stealth objects
     * as an performance improvement.
     */
    PathTile FindPath(Tile goal, bool allowBlockedGoal, bool stealth)
    {
        HashSet<Tile> explored = new HashSet<Tile>(); // The explored tiles
        Tile neighbour; // The neighbour to a currently looked at tile
        PathTile current; // The currently looked at tile
        Queue<PathTile> q; // Queue of path tiles

        /* Breadth first search */
        if (goal != null && (allowBlockedGoal || !blockedTiles.Contains(goal))) {
            q = new Queue<PathTile>();
            q.Enqueue(new PathTile(playerScript.PlayerPosition()));
            while (q.Count != 0) {
                current = q.Dequeue();
                if (current.Equals(goal)) // Found the goal
                    return current;
                for (int z = 1; z >= -1; z -= 2) {
                    neighbour = new Tile(current.X + 0, current.Z + z);
                    if (neighbour.Equals(goal)) // Goal is the neighbour
                        return new PathTile(current, neighbour);
                    if (stealth && new PathTile(current, neighbour).Depth > 10)
                        continue;
                    if (!blockedTiles.Contains(neighbour) && !explored.Contains(neighbour)) {
                        explored.Add(neighbour);
                        q.Enqueue(new PathTile(current, neighbour));
                    }
                }
                for (int x = 1; x >= -1; x -= 2) {
                    neighbour = new Tile(current.X + x, current.Z + 0);
                    if (neighbour.Equals(goal)) // Neighbour is the goal
                        return new PathTile(current, neighbour);
                    if (stealth && new PathTile(current, neighbour).Depth > 10)
                        continue;
                    if (!blockedTiles.Contains(neighbour) && !explored.Contains(neighbour)) {
                        explored.Add(neighbour);
                        q.Enqueue(new PathTile(current, neighbour));
                    }
                }
            }
        }
        return null;
    }
开发者ID:RandomTroll18,项目名称:deco3801-nodayoff,代码行数:52,代码来源:MovementController.cs

示例4: RequestMovement

    /**
     * This does one of two things: visualises the player's movement choice, or it confirms
     * and moves a player's movement choice. Which one is chosen depends on whether this is the
     * first time the player has clicked the goal tile or the second time.
     */
    public void RequestMovement(Tile goal)
    {
        PathTile dest; // The destination tile

        if (InteractiveTiles.Count >= 1) {
            InteractiveTiles[0].CloseEvent();
        }

        if (moving == Moving.YES) {
            return;
        }

        if (moving == Moving.POSSIBLY && goal.Equals(clickedTile)) {
            if (playerScript.GetStatValue(Stat.AP) < 0f || playerScript.GetStatValue(Stat.AP) > 0f)
                moving = Moving.YES;
            return;
        }

        if (moving == Moving.POSSIBLY) { /* Clears all visual elements of selected path */
            Destroy(GameObject.FindGameObjectWithTag("Highlighted Tile"));
            ClearPath();
        }

        if (UseInteractable(goal)) // We interacted with an object
            return;

        dest = FindPath(goal, false, false);

        if (dest != null) {
            cost = dest.Depth;
            SpawnHighlightedTile(goal);
            clickedTile = goal;
            moving = Moving.POSSIBLY;
            path = FlipPath(dest);
            dest = dest.Parent;
        }

        while (dest != null && dest.Parent != null) {
            if (dest.Depth > playerScript.GetStatValue(Stat.AP)) // Not enough AP to reach tile
                visualPath.AddLast(SpawnPathTile(dest, InvalidPathMarker) as GameObject);
            else // Enough AP to reach tile
                visualPath.AddLast(SpawnPathTile(dest, ValidPathMarker) as GameObject);
            dest = dest.Parent;
        }
    }
开发者ID:RandomTroll18,项目名称:deco3801-nodayoff,代码行数:50,代码来源:MovementController.cs

示例5: GetInteractable

 /*
  * Get Index of Interactable on a certain Tile.
  *
  * Arguments
  * - Tile tile - The tile to find
  */
 public int GetInteractable(Tile tile)
 {
     for (int i = 0; i < InteractiveTiles.Count; i++) {
         if (tile.Equals(InteractiveTiles[i].GetTile())) // We found the tile
             return i;
     }
     return -1;
 }
开发者ID:RandomTroll18,项目名称:deco3801-nodayoff,代码行数:14,代码来源:MovementController.cs

示例6: searchForTile

    //returns the distance to the tile
    public int searchForTile(int x,int y,Tile tile, int mov, TileCosts costs)
    {
        int max = 20;
        //print ("doing " + mov);
        //if (mov < gridDistance(x,tile.x,y,tile.y)) return -100; //failure
        if (mov >= max) return int.MaxValue; //stop looking after some point
        if (tile.Equals(map[x,y])) return mov; //success

        int left,right,up,down,final;
        final = left = right = up = down = int.MaxValue; //high value so it wont be chosen
        if (onMap (x+1,y)) right = gridDistance(x+1,tile.x,y,tile.y) + (int)costs.costs[map[x+1,y].type];
        if (onMap (x-1,y)) left = gridDistance(x-1,tile.x,y,tile.y) + (int)costs.costs[map[x-1,y].type];
        if (onMap (x,y+1)) up = gridDistance(x,tile.x,y+1,tile.y) + (int)costs.costs[map[x,y+1].type];
        if (onMap (x,y-1)) down = gridDistance(x,tile.x,y-1,tile.y) + (int)costs.costs[map[x,y-1].type];

        while(up < int.MaxValue || down < int.MaxValue || left < int.MaxValue || right < int.MaxValue){
            if(up < down && up < right && up < left){
                final = searchForTile(x,y+1,tile,mov + (int)costs.costs[map[x,y+1].type],costs);
                if (final >= max) up = int.MaxValue; //this condition is so it will check the other options if it deadends
                else return final;
            }
            if (down < left && down < right){
                final = searchForTile(x,y-1,tile,mov + (int) costs.costs[map[x,y-1].type],costs);
                if (final >= max) down = int.MaxValue;
                else return final;
            }
            if (left < right){
                final = searchForTile(x-1,y,tile,mov + (int) costs.costs[map[x-1,y].type],costs);
                if (final >= max) left = int.MaxValue;
                else return final;
            }
            if (right < int.MaxValue){
                final = searchForTile(x+1,y,tile,mov + (int) costs.costs[map[x+1,y].type],costs);
                if (final >= max) right = int.MaxValue;
                else return final;
            }
        }
        return final;
    }
开发者ID:urgamedev,项目名称:TurnBasedGame,代码行数:40,代码来源:Map.cs

示例7: checkPair

	/*
	 * Called once 2 tiles have been selected. Checks if a match has been made
	 */
	public bool checkPair(Tile other){
		return other.Equals (pair);
	}
开发者ID:kleptodorf,项目名称:CS3013,代码行数:6,代码来源:Tile.cs


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