/// <summary> /// create chart wall style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> private WallStyle CreateChartWallStyle(XmlNode nodeStyle) { WallStyle wallStyle = new WallStyle(this.Chart.Document); wallStyle.Node = nodeStyle; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasChildNodes) { foreach (XmlNode nodeChild in nodeStyle.ChildNodes) { IProperty property = this.GetProperty(wallStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } wallStyle.Node.InnerXml = ""; foreach (IProperty property in pCollection) { wallStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (wallStyle); return(wallStyle); }
/// <summary> /// create chart wall style /// </summary> /// <param name="nodeStyle"></param> /// <returns></returns> private WallStyle CreateChartWallStyle(XElement nodeStyle) { WallStyle wallStyle = new WallStyle(Chart.Document) { Node = nodeStyle }; IPropertyCollection pCollection = new IPropertyCollection(); if (nodeStyle.HasElements) { foreach (XElement nodeChild in nodeStyle.Elements()) { IProperty property = GetProperty(wallStyle, nodeChild); if (property != null) { pCollection.Add(property); } } } wallStyle.Node.Value = ""; foreach (IProperty property in pCollection) { wallStyle.PropertyCollection.Add(property); } //this.Chart .Styles .Add (wallStyle); return(wallStyle); }
public ChartWall(Chart chart, string styleName) { Chart = chart; Document = chart.Document; Node = new XElement(Ns.Chart + "wall"); StyleName = styleName; WallStyle = new WallStyle(chart.Document, styleName); Chart.Styles.Add(WallStyle); Chart.Content.Add(this); }
public virtual void PositionChange(VMContext context) { var blueprint = context.Blueprint; if (((VMEntityFlags2)ObjectData[(int)VMStackObjectVariable.FlagField2] & (VMEntityFlags2.ArchitectualWindow | VMEntityFlags2.ArchitectualDoor)) > 0) { //if wall or door, attempt to place style on wall if (Object.OBJ.WallStyle > 21 && Object.OBJ.WallStyle < 256) { //first thing's first, is the style between 22-255 inclusive? If it is, then the style is stored in the object. Need to load its sprites and change the id for the objd. var id = Object.OBJ.WallStyleSpriteID; var style = new WallStyle() { WallsUpFar = Object.Resource.Get <SPR>(id), WallsUpMedium = Object.Resource.Get <SPR>((ushort)(id + 1)), WallsUpNear = Object.Resource.Get <SPR>((ushort)(id + 2)), WallsDownFar = Object.Resource.Get <SPR>((ushort)(id + 3)), WallsDownMedium = Object.Resource.Get <SPR>((ushort)(id + 4)), WallsDownNear = Object.Resource.Get <SPR>((ushort)(id + 5)) }; Object.OBJ.WallStyle = TSO.Content.Content.Get().WorldWalls.AddDynamicWallStyle(style); } var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags]; var dir = DirectionToWallOff(Direction); if ((placeFlags & WallPlacementFlags.WallRequiredInFront) > 0) { SetWallStyle((dir) % 4,blueprint,Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredOnRight) > 0) { SetWallStyle((dir + 1) % 4,blueprint,Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredBehind) > 0) { SetWallStyle((dir + 2) % 4,blueprint,Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredOnLeft) > 0) { SetWallStyle((dir + 3) % 4,blueprint,Object.OBJ.WallStyle); } } if (EntryPoints[15].ActionFunction != 0) { //portal context.AddRoomPortal(this); } context.RegisterObjectPos(this); }
public void RegenerateDecorations(Map map) { WallStyle wallStyle = (this.wallStyle == null) ? map.baseWallStyle : this.wallStyle; if (wallStyle == null) { Debug.LogError("Wall style is undefined in Map. Define a wall style"); return; } if (tileType == TileType.Wall || tileType == TileType.Door || tileType == TileType.EntryDoor) { SpriteRenderer.sprite = wallStyle.fill; } else { SpriteRenderer.sprite = wallStyle.floor; } if (!Application.isPlaying) { DestroyImmediate(GeneratedDecorationsParent.gameObject); } else { foreach (Transform child in GeneratedDecorationsParent) { Destroy(child.gameObject); } } if (wallStyle != null) { var spriteInfos = wallStyle.GetWallSprites(map, Coordinates); foreach (var spriteInfo in spriteInfos) { AddGeneratedDecoratorSprite(spriteInfo.sprite, spriteInfo.rotation, spriteInfo.sortingLayer, spriteInfo.orderInLayer); } } }
public Wall(int i, int j, WallStyle style) { I = i; J = j; Style = style; }
/// <summary> /// Adds a dynamic wall style to WorldWallProvider. /// </summary> /// <param name="input">Wallstyle to add.</param> /// <returns>The ID of the wallstyle.</returns> public ushort AddDynamicWallStyle(WallStyle input) //adds a new wall and returns its id { input.ID = DynamicStyleID++; AddWallStyle(input); return((ushort)(DynamicStyleID - 1)); }
private void AddWallStyle(WallStyle wall) { WallStyles.Add(wall); StyleById.Add(wall.ID, wall); }
public Boolean AddWallTest(int i, int j, WallStyle style) { Boolean settingWall = CanSetWall(i, j, style); if (settingWall) { AddWall(i, j, style); } return settingWall; }
public override void PositionChange(VMContext context, bool noEntryPoint) { if (GhostImage) { return; } var room = context.GetObjectRoom(this); SetRoom(room); for (int i = 0; i < Contained.Length; i++) { if (Contained[i] != null) { context.UnregisterObjectPos(Contained[i]); Contained[i].Position = Position; Contained[i].PositionChange(context, noEntryPoint); //recursive } } context.RegisterObjectPos(this); if (Container != null) { return; } if (Position == LotTilePos.OUT_OF_WORLD) { return; } var arch = context.Architecture; if (((VMEntityFlags2)ObjectData[(int)VMStackObjectVariable.FlagField2] & (VMEntityFlags2.ArchitectualWindow | VMEntityFlags2.ArchitectualDoor)) > 0) { //if wall or door, attempt to place style on wall if (Object.OBJ.WallStyle > 21 && Object.OBJ.WallStyle < 256) { //first thing's first, is the style between 22-255 inclusive? If it is, then the style is stored in the object. Need to load its sprites and change the id for the objd. var id = Object.OBJ.WallStyleSpriteID; var sprs = new SPR[6]; for (int i = 0; i < 6; i++) { sprs[i] = Object.Resource.Get <SPR>((ushort)(id + i)); if (sprs[i] != null) { sprs[i].WallStyle = true; } } var style = new WallStyle() { WallsUpFar = sprs[0], WallsUpMedium = sprs[1], WallsUpNear = sprs[2], WallsDownFar = sprs[3], WallsDownMedium = sprs[4], WallsDownNear = sprs[5] }; Object.OBJ.WallStyle = FSO.Content.Content.Get().WorldWalls.AddDynamicWallStyle(style); } var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags]; var dir = DirectionToWallOff(Direction); if ((placeFlags & WallPlacementFlags.WallRequiredInFront) > 0) { SetWallStyle((dir) % 4, arch, Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredOnRight) > 0) { SetWallStyle((dir + 1) % 4, arch, Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredBehind) > 0) { SetWallStyle((dir + 2) % 4, arch, Object.OBJ.WallStyle); } if ((placeFlags & WallPlacementFlags.WallRequiredOnLeft) > 0) { SetWallStyle((dir + 3) % 4, arch, Object.OBJ.WallStyle); } } var exclusive = GetValue(VMStackObjectVariable.ExclusivePlacementFlags); SetWallUse(arch, true, ((exclusive & 2) > 0)); if (GetValue(VMStackObjectVariable.Category) == 8) { context.Architecture.SetObjectSupported(Position.TileX, Position.TileY, Position.Level, true); } if (EntryPoints[8].ActionFunction != 0) { UpdateDynamicMultitile(context); } base.PositionChange(context, noEntryPoint); }
public virtual void PositionChange(VMContext context) { if (Container != null) return; if (Position == LotTilePos.OUT_OF_WORLD) return; var arch = context.Architecture; if (((VMEntityFlags2)ObjectData[(int)VMStackObjectVariable.FlagField2] & (VMEntityFlags2.ArchitectualWindow | VMEntityFlags2.ArchitectualDoor)) > 0) { //if wall or door, attempt to place style on wall if (Object.OBJ.WallStyle > 21 && Object.OBJ.WallStyle < 256) { //first thing's first, is the style between 22-255 inclusive? If it is, then the style is stored in the object. Need to load its sprites and change the id for the objd. var id = Object.OBJ.WallStyleSpriteID; var style = new WallStyle() { WallsUpFar = Object.Resource.Get<SPR>(id), WallsUpMedium = Object.Resource.Get<SPR>((ushort)(id + 1)), WallsUpNear = Object.Resource.Get<SPR>((ushort)(id + 2)), WallsDownFar = Object.Resource.Get<SPR>((ushort)(id + 3)), WallsDownMedium = Object.Resource.Get<SPR>((ushort)(id + 4)), WallsDownNear = Object.Resource.Get<SPR>((ushort)(id + 5)) }; Object.OBJ.WallStyle = TSO.Content.Content.Get().WorldWalls.AddDynamicWallStyle(style); } var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags]; var dir = DirectionToWallOff(Direction); if ((placeFlags & WallPlacementFlags.WallRequiredInFront) > 0) SetWallStyle((dir) % 4, arch, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredOnRight) > 0) SetWallStyle((dir+1) % 4, arch, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredBehind) > 0) SetWallStyle((dir+2) % 4, arch, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredOnLeft) > 0) SetWallStyle((dir+3) % 4, arch, Object.OBJ.WallStyle); } SetWallUse(arch, true); if (GetValue(VMStackObjectVariable.Category) == 8) context.Architecture.SetObjectSupported(Position.TileX, Position.TileY, Position.Level, true); if (EntryPoints[15].ActionFunction != 0) { //portal context.AddRoomPortal(this); } context.RegisterObjectPos(this); ExecuteEntryPoint(9, context, true); //Placement }
private _2DSprite GetWallSprite(Wall pattern, WallStyle style, int rotation, bool down, WorldState world) { var _Sprite = new _2DSprite() { RenderMode = _2DBatchRenderMode.WALL }; SPR sprite = null; SPR mask = null; switch (world.Zoom) { case WorldZoom.Far: sprite = pattern.Far; if (style != null) mask = (down) ? style.WallsDownFar : style.WallsUpFar; _Sprite.DestRect = DESTINATION_FAR[rotation]; _Sprite.Depth = WallZBuffers[rotation+8]; break; case WorldZoom.Medium: sprite = pattern.Medium; if (style != null) mask = (down) ? style.WallsDownMedium : style.WallsUpMedium; _Sprite.DestRect = DESTINATION_MED[rotation]; _Sprite.Depth = WallZBuffers[rotation+4]; break; case WorldZoom.Near: sprite = pattern.Near; if (style != null) mask = (down) ? style.WallsDownNear : style.WallsUpNear; _Sprite.DestRect = DESTINATION_NEAR[rotation]; _Sprite.Depth = WallZBuffers[rotation]; break; } if (sprite != null) { if (mask == null) mask = sprite; _Sprite.Pixel = world._2D.GetTexture(sprite.Frames[rotation]); _Sprite.Mask = world._2D.GetTexture(mask.Frames[rotation]); _Sprite.SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, _Sprite.Pixel.Width, _Sprite.Pixel.Height); } return _Sprite; }
/// <summary> /// Проверяет, есть ли пересечения стены с существующими стенами /// </summary> /// <param name="i">Строка</param> /// <param name="j">Столбец</param> /// <param name="style">Напраление стены</param> /// <returns></returns> public bool IsFreeForWall(int i, int j, WallStyle style) { if (walls[i, j] != null) return false; if (style == WallStyle.Horizontal) { Wall left = GetWall(i, j - 1); if (left != null && left.Style == WallStyle.Horizontal) return false; Wall right = GetWall(i, j + 1); if (right != null && right.Style == WallStyle.Horizontal) return false; } else /* style == WallStyle.Vertical */ { Wall up = GetWall(i - 1, j); if (up != null && up.Style == WallStyle.Vertical) return false; Wall down = GetWall(i + 1, j); if (down != null && down.Style == WallStyle.Vertical) return false; } return true; }
/// <summary> /// Проверяет, можно ли поставить стену типа style на позицию (i, j). /// </summary> /// <param name="i">Строка</param> /// <param name="j">Столбец</param> /// <param name="style">Направление стены</param> /// <returns>true, если стену можно поставить</returns> public bool CanSetWall(int i, int j, WallStyle style) { if (IsFreeForWall(i, j, style)) { AddWall(i, j, style); bool check = false; for (int k = 0; k < endOfPathForHero1.Count; k++) { if (GraphAlgorithms.DFS(matrix, VertexNumber(Hero1.Y, Hero1.X), endOfPathForHero1[k])) { check = true; break; } } if (check == true) { check = false; for (int k = 0; k < endOfPathForHero2.Count; k++) { if (GraphAlgorithms.DFS(matrix, VertexNumber(Hero2.Y, Hero2.X), endOfPathForHero2[k])) { check = true; break; } } } RemoveWall(i, j, style); return check; } else return false; }
public virtual void PositionChange(VMContext context) { var blueprint = context.Blueprint; if (((VMEntityFlags2)ObjectData[(int)VMStackObjectVariable.FlagField2] & (VMEntityFlags2.ArchitectualWindow | VMEntityFlags2.ArchitectualDoor)) > 0) { //if wall or door, attempt to place style on wall if (Object.OBJ.WallStyle > 21 && Object.OBJ.WallStyle < 256) { //first thing's first, is the style between 22-255 inclusive? If it is, then the style is stored in the object. Need to load its sprites and change the id for the objd. var id = Object.OBJ.WallStyleSpriteID; var style = new WallStyle() { WallsUpFar = Object.Resource.Get<SPR>(id), WallsUpMedium = Object.Resource.Get<SPR>((ushort)(id + 1)), WallsUpNear = Object.Resource.Get<SPR>((ushort)(id + 2)), WallsDownFar = Object.Resource.Get<SPR>((ushort)(id + 3)), WallsDownMedium = Object.Resource.Get<SPR>((ushort)(id + 4)), WallsDownNear = Object.Resource.Get<SPR>((ushort)(id + 5)) }; Object.OBJ.WallStyle = TSO.Content.Content.Get().WorldWalls.AddDynamicWallStyle(style); } var placeFlags = (WallPlacementFlags)ObjectData[(int)VMStackObjectVariable.WallPlacementFlags]; var dir = DirectionToWallOff(Direction); if ((placeFlags & WallPlacementFlags.WallRequiredInFront) > 0) SetWallStyle((dir) % 4, blueprint, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredOnRight) > 0) SetWallStyle((dir+1) % 4, blueprint, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredBehind) > 0) SetWallStyle((dir+2) % 4, blueprint, Object.OBJ.WallStyle); if ((placeFlags & WallPlacementFlags.WallRequiredOnLeft) > 0) SetWallStyle((dir+3) % 4, blueprint, Object.OBJ.WallStyle); } if (EntryPoints[15].ActionFunction != 0) { //portal context.AddRoomPortal(this); } context.RegisterObjectPos(this); }
/// <summary> /// Процедура вызывается при установке игроком стены. /// Контракт: /// при успешном выполнении: /// вызывает событие; /// посылает сообщение об установке стены; /// посылает сообщение о завершении хода; /// завершает ход. /// </summary> /// <param name="dx"></param> /// <param name="dy"></param> public virtual void OnSetWall(int i, int j, WallStyle style) { if (player.NumberOfWalls > 0 && Field.CanSetWall(i, j, style)) { player.DecreaseNumberOfWalls(); Field.AddWall(i, j, style); if (PlayerSetWall != null) PlayerSetWall(this, new WallArgs() { I = i, J = j, Style = style }); SendMessage(new WallMessage() { I = i, J = j, Style = style }); SendMessage(new ChangeTurnMessage()); PostMessage(new ChangeTurnMessage()); } }
/// <summary> /// Отправляет в очередь событие установки стены. /// </summary> /// <param name="i">Строка относительно центра стены</param> /// <param name="j">Столбец относительно центра стены</param> /// <param name="style">Напраление стены</param> public void PostSetWall(int i, int j, WallStyle style) { PostMessage(new WallMessage() { I = i, J = j, Style = style }); }
/// <summary> /// Ставит стену. /// Не осуществляет проверок. /// </summary> /// <param name="i">Строка</param> /// <param name="j">Столбец</param> /// <param name="style">Направление</param> public void AddWall(int i, int j, WallStyle style) { Wall wall = new Wall(i, j, style); walls[i, j] = wall; if (style == WallStyle.Horizontal) { matrix.RemoveEdge(VertexNumber(i, j), VertexNumber(i + 1, j)); matrix.RemoveEdge(VertexNumber(i, j + 1), VertexNumber(i + 1, j + 1)); } else { matrix.RemoveEdge(VertexNumber(i, j), VertexNumber(i, j + 1)); matrix.RemoveEdge(VertexNumber(i + 1, j), VertexNumber(i + 1, j + 1)); } }
/// <summary> /// Удаляет стену из заданной позиции. /// </summary> /// <param name="i">Строка</param> /// <param name="j">Столбец</param> /// <param name="style">Направление</param> /*$ONLY FOR TEST*/ /*protected$*/ public void RemoveWall(int i, int j, WallStyle style) { walls[i, j] = null; if (style == WallStyle.Horizontal) { matrix.AddEdge(VertexNumber(i, j), VertexNumber(i + 1, j)); matrix.AddEdge(VertexNumber(i, j + 1), VertexNumber(i + 1, j + 1)); } else { matrix.AddEdge(VertexNumber(i, j), VertexNumber(i, j + 1)); matrix.AddEdge(VertexNumber(i + 1, j), VertexNumber(i + 1, j + 1)); } }