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


C# ITile.GetType方法代码示例

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


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

示例1: AddTileToMap

        private static void AddTileToMap(ITile tile, int row, int column, SerializedMap serializedMap)
        {
            if (tile.GetType() == typeof (Conveyer) || tile.GetType() == typeof (ExpressConveyer))
            {
                var conveyor = new SerializedConveyor()
                {
                    Row = row,
                    Column = column,
                    In = (tile as Conveyer).Entrances.Select(o => o.ToString().ToLowerInvariant()).ToList(),
                    Out = (tile as Conveyer).Exit.ToString().ToLowerInvariant(),
                    Type = (tile.GetType() == typeof (ExpressConveyer) ? "express" : null)
                };
                serializedMap.Conveyors.Add(conveyor);
            }
            else if (tile.GetType() == typeof (Gear))
            {
                var gear = new SerializedGear()
                {
                    Row = row,
                    Column = column,
                    Type = (tile as Gear).Direction.ToString().ToLowerInvariant()
                };
                serializedMap.Gears.Add(gear);
            }
            else if (tile.GetType() == typeof (Wrench) || tile.GetType() == typeof (WrenchHammer))
            {
                var wrench = new SerializedWrench()
                {
                    Row = row,
                    Column = column,
                    Type = (tile.GetType() == typeof (WrenchHammer) ? "option" : null)
                };
                serializedMap.Wrenches.Add(wrench);
            }
            else if (tile.GetType() == typeof (Pit))
            {
                var pit = new SerializedPit()
                {
                    Row = row,
                    Column = column
                };
                serializedMap.Pits.Add(pit);
            }
            //else if (tile.GetType() == typeof(Flag))
            //{
            //	var flag = new SerializedFlag()
            //	{
            //		Row = row,
            //		Column = column,
            //		Order = (tile as Flag).Order
            //	};
            //	serializedMap.Flags.Add(flag);
            //}

            // Any flor type can have walls/lasers
            if (tile is Floor)
            {
                if ((tile as Floor).Edges.Any())
                {
                    var wall = new SerializedWall()
                    {
                        Row = row,
                        Column = column,
                        Edges = (tile as Floor).Edges.Select(p => p.Item1.ToString().ToLowerInvariant()).ToList()
                    };
                    serializedMap.Walls.Add(wall);
                }

                var laserWallEdge = (tile as Floor).Edges.FirstOrDefault(p => p.Item2 is WallLaserEdge);
                if (laserWallEdge != null)
                {
                    // Little bit of a hack around converting directions from "wall edge orientation" to "laser direction"
                    var laserDirection = (Orientation) (((int) laserWallEdge.Item1 + 2)%4);
                    var laser = new SerializedLaser()
                    {
                        Row = row,
                        Column = column,
                        Damage = (laserWallEdge.Item2 as WallLaserEdge).Lasers,
                        Direction = laserDirection
                    };
                    if (laserWallEdge.Item1 == Orientation.Left || laserWallEdge.Item1 == Orientation.Right)
                        laser.EndRow = laser.Row;
                    else
                        laser.EndColumn = laser.Column;
                    serializedMap.Lasers.Add(laser);
                }

                var pusherWallEdge = (tile as Floor).Edges.FirstOrDefault(p => p.Item2 is WallPusherEdge);
                if (pusherWallEdge != null)
                {
                    var pusher = new SerializedPusher()
                    {
                        Row = row,
                        Column = column,
                        Registers = (pusherWallEdge.Item2 as WallPusherEdge).Registers,
                        Wall = pusherWallEdge.Item1.ToString().ToLowerInvariant()
                    };
                    serializedMap.Pushers.Add(pusher);
                }
            }
//.........这里部分代码省略.........
开发者ID:wbish,项目名称:wirk,代码行数:101,代码来源:MapParser.cs

示例2: NetworkUpdateTile

 public void NetworkUpdateTile(ITile t)
 {
     if (t == null)
         return;
     NetOutgoingMessage message = IoCManager.Resolve<ISS13NetServer>().CreateMessage();
     message.Write((byte) NetMessage.MapMessage);
     message.Write((byte) MapMessage.TurfUpdate);
     message.Write(t.WorldPosition.X);
     message.Write(t.WorldPosition.Y);
     message.Write(GetTileIndex(t.GetType().Name));
     message.Write((byte) t.TileState);
     if (t.GetType().Name == "Wall") message.Write((byte)t.dir);
     IoCManager.Resolve<ISS13NetServer>().SendToAll(message);
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:14,代码来源:MapManager.cs

示例3: WeightPlayableTile

 protected double? WeightPlayableTile(ITile input)
 {
     PlayableTileSelector selector;
     double? weight = _playableTileRules.Value.TryGetValue(input.GetType(), out selector)
                          ? selector(input)
                          : GetDefaultPlayableTileWeight(input);
     return weight.HasValue ? weight+GetBasePlayableTileWeight(input) : null;
 }
开发者ID:llanes1990,项目名称:RecreatingInfiniteCity,代码行数:8,代码来源:RuleBasedAI.cs


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