public void Start() { if (!blocks.Any()) { foreach (Common.BlockInfo blockinfo in info.Blocks) { BlockInfo myInfo = new BlockInfo { entity = _entityPool.CreateEntity(info.Entity) }; // should always persist off screen PositionComponent pos = myInfo.entity.GetComponent<PositionComponent>(); pos.PersistOffScreen = true; myInfo.pos = new PointF(blockinfo.pos.X, blockinfo.pos.Y); myInfo.on = blockinfo.on; myInfo.off = blockinfo.off; blocks.Add(myInfo); } } this.playerPos = container.Entities.GetEntityById("Player").GetComponent<PositionComponent>(); container.GameThink += Update; stopped = false; }
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; }