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


C# IEvent.GetLength方法代码示例

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


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

示例1: ParseFile

        private TileMap ParseFile(HashSet<string> input)
        {
            Tile[, ,] tiles;
            IEvent[,,] events;
            Building[] buildings;
            ScriptedEvent[, ,] se;
            string mapName, line;
            int mapL, mapW, mapH, numNonNull, numEvents, numBuildings, buildingNum = 0;

            line = input.ElementAt(0);
            line = line.Substring(line.IndexOf('(') + 1).Trim();
            mapName = line.Substring(0, line.IndexOf(','));
            line = line.Substring(line.IndexOf('[') + 1).Trim();
            mapL = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            mapW = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            mapH = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numNonNull = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numEvents = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')));
            line = line.Substring(line.IndexOf(',') + 1).Trim();
            numBuildings = System.Convert.ToInt32(line.Substring(0, line.IndexOf(')')));

            tiles = new Tile[mapL, mapW, mapH];
            events = new IEvent[mapL, mapW, mapH];
            buildings = new Building[numBuildings];
            se = ScriptInvoke.GetScriptedEvents(mapName, new int[3] { events.GetLength(0), events.GetLength(1), events.GetLength(2) });
            numEvents += ScriptInvoke.GetNumEvents(mapName);

            //Basic Data down!

            for (int i = 1; i < input.Count; i++){
                line = input.ElementAt(i).Trim();

                if (line[0] == 'T'){
                    int[] arrayPos = new int[3];
                    int[] mapPos = new int[3];
                    Tile.TileStyle style = Tile.TileStyle.FLAT;
                    Tile.Direction dir, secondDir;
                    line = line.Substring(line.IndexOf('[') + 1).Trim();

                    arrayPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    arrayPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    arrayPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(']')).Trim());
                    line = line.Substring(line.IndexOf('(') + 1).Trim();

                    style = (Tile.TileStyle)Enum.Parse(typeof(Tile.TileStyle),
                        line.Substring(0, line.IndexOf(',')).Trim(), true);
                    line = line.Substring(line.IndexOf('{') + 1).Trim();
                    mapPos[0] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[1] = System.Convert.ToInt32(line.Substring(0, line.IndexOf(',')).Trim());
                    line = line.Substring(line.IndexOf(',') + 1).Trim();
                    mapPos[2] = System.Convert.ToInt32(line.Substring(0, line.IndexOf('}')).Trim());

                    if (line.IndexOf(',') == -1){
                        tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                            style,
                            mapPos,
                            null,
                            null);
                    }else{
                        line = line.Substring(line.IndexOf(',') + 1).Trim();
                        if (line.IndexOf(',') == -1){
                            dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true);
                            tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                            style,
                            mapPos,
                            dir,
                            null);
                        }else{
                            dir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                            line = line.Substring(line.IndexOf(',') + 1).Trim();
                            if (line.IndexOf(',') == -1){
                                secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(')')).Trim(), true);
                                tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                                style,
                                mapPos,
                                dir,
                                secondDir);
                            }else{
                                secondDir = (Tile.Direction)Enum.Parse(typeof(Tile.Direction), line.Substring(0, line.IndexOf(',')).Trim(), true);
                                line = line.Substring(line.IndexOf('{') + 1).Trim();
                                bool[] passage = new bool[4];
                                passage[0] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[1] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[2] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf(',')).Trim());
                                line = line.Substring(line.IndexOf(',') + 1).Trim();
                                passage[3] = System.Convert.ToBoolean(line.Substring(0, line.IndexOf('}')).Trim());
                                if(line.IndexOf(',') == -1){
                                    tiles[arrayPos[0], arrayPos[1], arrayPos[2]] = new Tile(
                                        style,
                                        mapPos,
                                        dir,
//.........这里部分代码省略.........
开发者ID:nchavez324,项目名称:NicksAdventureWP7,代码行数:101,代码来源:TileMapParser.cs


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