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

C# TilePosition类代码示例

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

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



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


示例16: Execute

        public override void Execute(TileManager tileManager, Tile tile, TilePosition pos)
        {
            TileDefinition tileDefinition = tileManager.GetTileDefinition(tile.tileType);

            ItemDefinition itemDefinition = tileManager.world.itemManager.GetItemDefinitionById(tileDefinition.id);

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


示例17: RoguelikeWorldGenerator

 public RoguelikeWorldGenerator(CubeWorld world)
 {
     playerStartPosition =
         new TilePosition(
             LEVEL_HEIGHT / 2,
             world.sizeY - LEVEL_HEIGHT + 3,
             LEVEL_HEIGHT / 2);
 }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:8,代码来源:RoguelikeWorldGenerator.cs


示例18: ReadTilePosition

 public static TilePosition ReadTilePosition(BinaryReader br)
 {
     TilePosition v = new TilePosition();
     v.x = br.ReadInt32();
     v.y = br.ReadInt32();
     v.z = br.ReadInt32();
     return v;
 }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:8,代码来源:Serialization.cs


示例19: GetSectorTile

        public Sector GetSectorTile(TilePosition pos)
        {
            pos.x >>= SECTOR_SIZE_BITS;
            pos.y >>= SECTOR_SIZE_BITS;
            pos.z >>= SECTOR_SIZE_BITS;

            return sectors[pos.x | (pos.y << xSectorsBits) | (pos.z << xySectorsBits)];
        }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:8,代码来源:SectorManager.cs


示例20: TileRuleSetDynamic

 public TileRuleSetDynamic(TilePosition delta, bool value, bool gravity, int timeout, TileRuleCondition condition)
     : base(condition)
 {
     this.delta = delta;
     this.value = value;
     this.gravity = gravity;
     this.timeout = timeout;
 }
开发者ID:carriercomm,项目名称:CubeWorld,代码行数:8,代码来源:TileRuleSetDynamic.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TileSet类代码示例发布时间:2022-05-24
下一篇:
C# TileMap类代码示例发布时间: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