예제 #1
0
 public BlocksPattern(BlockPatternInfo info, IGameplayContainer container, IEntityPool entityPool)
 {
     this.info = info;
     length = info.Length;
     leftBoundary = info.LeftBoundary;
     rightBoundary = info.RightBoundary;
     blocks = new List<BlockInfo>();
     running = false;
     frame = 0;
     this.container = container;
     this._entityPool = entityPool;
 }
        public void Save(XmlTextWriter writer, BlockPatternInfo blockPattern)
        {
            writer.WriteStartElement("Blocks");
            writer.WriteAttributeString("left", blockPattern.LeftBoundary.ToString());
            writer.WriteAttributeString("right", blockPattern.RightBoundary.ToString());
            writer.WriteAttributeString("length", blockPattern.Length.ToString());
            writer.WriteAttributeString("entity", blockPattern.Entity);

            foreach (BlockInfo block in blockPattern.Blocks)
            {
                writer.WriteStartElement("Block");
                writer.WriteAttributeString("x", block.pos.X.ToString());
                writer.WriteAttributeString("y", block.pos.Y.ToString());
                writer.WriteAttributeString("on", block.on.ToString());
                writer.WriteAttributeString("off", block.off.ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
        public static BlockPatternInfo FromXml(XElement xmlNode)
        {
            var info = new BlockPatternInfo();

            info.Entity = xmlNode.RequireAttribute("entity").Value;
            info.LeftBoundary = xmlNode.GetInteger("left");
            info.RightBoundary = xmlNode.GetInteger("right");
            info.Length = xmlNode.GetInteger("length");

            info.Blocks = new List<BlockInfo>();
            foreach (XElement blockInfo in xmlNode.Elements("Block"))
            {
                BlockInfo block = new BlockInfo();
                block.pos = new PointF((float)blockInfo.GetDouble("x"), (float)blockInfo.GetDouble("y"));
                block.on = blockInfo.GetInteger("on");
                block.off = blockInfo.GetInteger("off");

                info.Blocks.Add(block);
            }

            return info;
        }
예제 #4
0
 public void AddBlockPattern(BlockPatternInfo info)
 {
     BlockPatternInfo.Add(info);
 }