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


C# Chunk.Add方法代码示例

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


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

示例1: WriteConfiguration

        public override bool WriteConfiguration(Chunk chunk)
        {
            if (base.WriteConfiguration(chunk))
            {
                foreach (IActor a in collectionEnvironment)
                {
                    Chunk subChunk = Utility.WriteActor(a);
                    if (subChunk != null)
                    {
                        chunk.Add(subChunk);
                    }
                    else
                    {
                        return false;
                    }
                }

                return true;
            }
            return false;
        }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:21,代码来源:CollectionActor.cs

示例2: ReadStep

        private static Chunk ReadStep(Xml.XmlElement element)
        {
            Chunk newChunk = new Chunk(element.Name);

            foreach (Xml.XmlNode n in element.ChildNodes)
            {
                if (n is Xml.XmlElement)
                {
                    Xml.XmlElement subElement = (Xml.XmlElement)n;

                    if (subElement.Name == "Value")
                    {
                        if (subElement.HasAttribute("Name"))
                        {
                            string valueName = subElement.GetAttribute("Name");
                            newChunk.Values[valueName] = GetElementText(subElement);
                        }
                    }
                }
            }

            // Recurse.
            foreach (Xml.XmlNode n in element.ChildNodes)
            {
                if (n is Xml.XmlElement )
                {
                    Xml.XmlElement subElement = (Xml.XmlElement)n;

                    if (subElement.Name != "Value")
                    {
                        newChunk.Add(ReadStep(subElement));
                    }
                }
            }

            return newChunk;
        }
开发者ID:BackupTheBerlios,项目名称:proteus-svn,代码行数:37,代码来源:XmlDocument.cs

示例3: Load

        //TODO: Actually load from file
        public static State Load(string fileName, Fader fader)
        {
            fader.Timestep = 0.1f;
            fader.FadeIn();

            //disabled because otherwise it gets annoying to run the game while listening to music and stuff
            //Resource<Sound>.Get("BGM/HonorForAll", "mp3").IsLooped = true;
            //Resource<Sound>.Get("BGM/HonorForAll", "mp3").Play();

            string file = Path.Combine("Content/Maps/", fileName);
            var level = new LoadedLevel(new FileStream(file, FileMode.Open));

            var chunk = new Chunk(level.Width, level.Height);
            var camera = new Camera();

            var layers = level.Layers;
            var objectgroups = level.ObjectGroups;

            foreach (var layer in layers)
            {
                int[] tiles = layer.Value.Tiles;
                int z = int.Parse(layer.Key);

                for (int x = 0; x < chunk.Width; x++)
                    for (int y = 0; y < chunk.Height; y++)
                    {
                        Texture2D tex = Resource<Texture2D>.Get(level.Tileset.Image);

                        int id = tiles[x + y * chunk.Width];

                        //Texture coordinates

                        int tx = (int)(id * 32 / 1.5); //why does this work
                        int ty = 0;
                        //int tx = (id % (tex.Width / 32)) * 32;
                        //int ty = (id / (tex.Width / 32)) * 32;
                        int tw = 32;
                        int th = 32;

                        var tile = new Chunk.Tile(tex, tx, ty, tw, th);

                        Dictionary<string, string> properties;
                        if (level.Tileset.TileData.TryGetValue(id, out properties)) //If id isn't found, that means the tile id has no properties defined
                            foreach (var property in properties)
                                tile.AddProperty(property.Key, property.Value); //If id IS found, set all properties

                        tile.AddProperty("FrictionMultiplier", 1);

                        chunk.Set(x, y, z, tile);
                    }
            }

            Physical player = null; //This gets set down here

            foreach (var objectgroup in objectgroups)
            {
                var objects = objectgroup.Value.Entities;
                int z = int.Parse(objectgroup.Key); //TODO: Does this even work too?

                foreach (var obj in objects)
                {
                    string name = obj.Name;

                    bool isPassable = false;
                    bool isRamp = false;

                    if (obj.Properties != null)
                    {
                        isRamp = bool.Parse(obj.Properties["IsRamp"]);
                        isPassable = bool.Parse(obj.Properties["IsPassable"]);
                    }

                    int x = (int)(obj.Position.X / 32f) - 0; //This is...
                    int y = (int)(obj.Position.Y / 32f) - 1; //Pretty wonky.

                    if (isRamp) //If it's a ramp, we don't create an entity at all, but a tile!
                    {
                        Texture2D tex = Resource<Texture2D>.Get(level.Tileset.Image);

                        int id = obj.GID;

                        //Texture coordinates

                        int tx = (int)(id * 16); //why does this work
                        int ty = 0;
                        int tw = 32;
                        int th = 32;

                        var tile = new Chunk.Tile(tex, tx, ty, tw, th);

                        foreach (var property in obj.Properties)
                            tile.AddProperty(property.Key, property.Value);

                        chunk.Set(x, y, z, tile);
                    }
                    else
                    {
                        Physical entity;

//.........这里部分代码省略.........
开发者ID:BrianLive,项目名称:MemoryLeak,代码行数:101,代码来源:Level.cs


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