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


C# TilePosition类代码示例

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


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

示例1: Init

 public void Init()
 {
     // We create the first three base tiles positions
     suburbs_pos = new TilePosition(0, 0);
     park_pos = new TilePosition(0, 2);
     heavy_factory_pos = new TilePosition(0, 4);
 }
开发者ID:dpekar,项目名称:suburbia,代码行数:7,代码来源:TestTilePosition.cs

示例2: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition pos)
        {
            pos += delta;

            if (tileManager.IsValidTile(pos))
                tileManager.DamageTile(pos, damage);
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:TileRuleDamage.cs

示例3: TestEquality

    public void TestEquality()
    {
        TilePosition suburbs_pos_idem = new TilePosition(0, 0);
        Assert.AreEqual(suburbs_pos, suburbs_pos_idem);

        Assert.AreNotEqual(suburbs_pos, park_pos);
    }
开发者ID:dpekar,项目名称:suburbia,代码行数:7,代码来源:TestTilePosition.cs

示例4: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition pos)
        {
            pos += delta;

            if (tileManager.IsValidTile(pos))
                tileManager.world.gameplay.CreateItem(itemDefinition, Graphics.TilePositionToVector3(pos));
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:TileRuleCreateItem.cs

示例5: InstantiateWithParent

    public static FreePositionView InstantiateWithParent(TilePosition p_position, Transform p_parent, Player p_owner)
    {
        try {
            // Creation of the new instance.
            GameObject _new_instance = UnityEngine.Object.Instantiate (RESOURCE) as GameObject;
            _new_instance.transform.parent = p_parent;

            // Get the script associated with the new tile.
            FreePositionView _this = _new_instance.AddComponent<FreePositionView> ();

            // Set the common properties
            _this.m_position = p_position;
            _this.m_player = p_owner;
            if(_this.m_position != null)
            {
                // TODO Rework this Duplicate from TileView.
                Vector3 position = new Vector3(_this.m_position.x * 1.5f * TileView.OffsetX, 0, (_this.m_position.y + 1 ) * TileView.OffsetY);
                _this.transform.position = p_parent.TransformPoint(position);
            }
            else
            {
                Debug.LogError("Position for FreePositionView null !");
            }

            return _this;

        } catch (Exception) {
            Debug.LogError ("Error while instantiating FreePosition! Prefab not found !");
            return null;
        }
    }
开发者ID:dpekar,项目名称:suburbia,代码行数:31,代码来源:FreePositionView.cs

示例6: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition pos)
        {
            pos += delta;

            if (tileManager.IsValidTile(pos))
                tileManager.SetTileType(pos, tileType);
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:TileRuleSetTileType.cs

示例7: Load

        public override void Load(System.IO.BinaryReader br)
        {
            base.Load(br);

            resetPosition = SerializationUtils.ReadTilePosition(br);
            inventory.Load(br);
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:Player.cs

示例8: Generate

        public override bool Generate(CubeWorld world)
        {
            int fromY = fromYRV.EvaluateInt(world);
            int toY = toYRV.EvaluateInt(world);

			TileManager tileManager = world.tileManager;
			
            Random rnd = new Random();

            for (int x = 0; x < tileManager.sizeX; x++)
                for (int z = 0; z < tileManager.sizeZ; z++)
                    for (int y = fromY; y < toY; y++)
                    {
                        TilePosition pos = new TilePosition(x, y, z);
                        if (tileManager.GetTileType(pos) == TileDefinition.EMPTY_TILE_TYPE)
                        {
                            int n = rnd.Next(0, probabilityRange);
                            foreach (TileTypeProbability s in probabilities)
                            {
                                if (n < s.probability)
                                {
                                    tileManager.SetTileType(pos, s.tileType);
                                    break;
                                }
                            }
                        }
                    }

            return true;
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:30,代码来源:PlainRandomWorldGenerator.cs

示例9: removeTile

 public void removeTile(TilePosition tilePosition)
 {
     GameTile tile = tiles[tilePosition];
     levelData.tiles.Remove (tile.myData);
     tiles.Remove (tilePosition);
     Destroy (tile.gameObject);
 }
开发者ID:ShadowVision,项目名称:FOX,代码行数:7,代码来源:Level.cs

示例10: TestAssignOwner

    public void TestAssignOwner()
    {
        TileInstance instance = new TileInstance();
        TilePosition position = new TilePosition(0, 0);
        Player player = new Player();

        Assert.AreEqual(0, player.tiles.Count);

        instance.owner = player;
        instance.position = position;
        Assert.AreEqual(player, instance.owner);
        Assert.AreEqual(1, player.tiles.Count);
        Assert.AreEqual(true, player.tiles.Contains(instance));

        // And now the other way around
        instance = new TileInstance();
        player = new Player();
        instance.position = position;

        Assert.AreEqual(0, player.tiles.Count);

        player.AddTileInstance(instance);
        Assert.AreEqual(player, instance.owner);
        Assert.AreEqual(1, player.tiles.Count);
        Assert.AreEqual(true, player.tiles.Contains(instance));
    }
开发者ID:dpekar,项目名称:suburbia,代码行数:26,代码来源:TestTileInstance.cs

示例11: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition center)
        {
            for (int d = 1; d <= radius; d++)
            {
	            int rDamage = damage * (radius - d + 1) / radius;
				
				TilePosition[] tiles = Manhattan.GetTilesAtDistance(d);
				
				for(int i = 0; i < tiles.Length; i++)
				{
					TilePosition p = center + tiles[i];
					
	                if (tileManager.IsValidTile(p))
						if (tileManager.DamageTile(p, rDamage) == false)
							if (setOnFire && tileManager.GetTileDefinition(tileManager.GetTileType(p)).burns)
		                        tileManager.SetTileOnFire(p, true);
				}
            }
			
			if (setOnFire)
			{
				TilePosition[] tiles = Manhattan.GetTilesAtDistance(radius + 1);
				
				for(int i = 0; i < tiles.Length; i++)
				{
					TilePosition p = center + tiles[i];
					
	                if (tileManager.IsValidTile(p))
						if (setOnFire && tileManager.GetTileDefinition(tileManager.GetTileType(p)).burns)
	                        tileManager.SetTileOnFire(p, true);
				}
			}
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:33,代码来源:TileRuleExplode.cs

示例12: CheckConditions

        public bool CheckConditions(TileManager tileManager, Tile tile, TilePosition pos)
        {
            if (condition != null)
                return condition.Validate(tileManager, tile, pos);

            return true;
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:TileRule.cs

示例13: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition pos)
        {
            pos += delta;

            if (tileManager.IsValidTile(pos))
                tileManager.EnqueueInvalidatedTile(pos);
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:7,代码来源:TileRuleInvalidate.cs

示例14:

 public Tile this[TilePosition p]
 {
     get
     {
         return this[p.Column, p.Row];
     }
 }
开发者ID:rzubek,项目名称:MKULTRA,代码行数:7,代码来源:TileMap.cs

示例15: Plan

    /// <summary>
    /// Find the shortest path using the A* algorithm and a Euclidean distance heuristic
    /// </summary>
    public TilePath Plan(TilePosition start, TileRect end)
    {
        heap.Clear();
        searchedTilesOverlay.Clear();
        var startNode = heap.NodeAt(start);
        startNode.Predecessor = null;
        heap.DecreaseKey(startNode, 0, 0);
        var currentNode = startNode;
        while (!heap.IsEmpty && !end.Contains((currentNode = heap.ExtractMin()).Position))
        {
            searchedTilesOverlay.Add(currentNode.Position);
            foreach (var n in currentNode.Neighbors)
            {
                float newDistanceFromStart = currentNode.DistanceFromStart                           // Cost so far
                                 + TilePosition.EuclideanDistance(currentNode.Position, n.Position)  // Edge cost
                                 + TilePosition.EuclideanDistance(n.Position, end);                  // Estimated cost to end

                if (n.DistanceFromStart > newDistanceFromStart)
                {
                    n.Predecessor = currentNode;
                    heap.DecreaseKey(n, newDistanceFromStart, newDistanceFromStart);
                }
            }
        }
        heap.SetOverlayToComputedPath(this.computedPathOverlay, currentNode);

        searchedTilesOverlay.Clear();
        searchedTilesOverlay.SetRect(end);

        if (!end.Contains(currentNode.Position))
            return null;

        return this.MakePath(currentNode);
    }
开发者ID:jcc333,项目名称:MKULTRA,代码行数:37,代码来源:PathPlanner.cs


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