public VisualEngine(Framework.FlatArray<GameCell> map, int range, FOVMethod method, RangeLimitShape shape) { this.fieldOfView = new FieldOfView<GameCell>(map); this.range = range; this.method = method; this.shape = shape; this.map = map; this.itemCharacters = new char[Enum.GetNames(typeof(BaseType)).Length]; this.itemCharacters[(int)BaseType.Armor] = '['; this.itemCharacters[(int)BaseType.Weapon] = ')'; this.itemCharacters[(int)BaseType.Consumable] = '%'; this.itemCharacters[(int)BaseType.Container] = '&'; this.itemCharacters[(int)BaseType.Gem] = '\u263c'; this.itemCharacters[(int)BaseType.Key] = '\u2552'; this.itemCharacters[(int)BaseType.Money] = '$'; this.itemCharacters[(int)BaseType.Reagent] = '\u220f'; this.itemCharacters[(int)BaseType.Recipe] = '\u222b'; this.itemCharacters[(int)BaseType.Projectile] = '('; this.itemCharacters[(int)BaseType.QuestPlot] = '\u2021'; this.itemCharacters[(int)BaseType.Quiver] = '\u00b6'; this.itemCharacters[(int)BaseType.TradeGoods] = '\u2211'; this.itemCharacters[(int)BaseType.Miscellaneous] = '}'; this.itemCharacters[(int)BaseType.Jewellery] = '\u00a7'; }
public FOVSettings( int maxRange = 4, bool lightWalls = true, FOVMethod method = FOVMethod.MRPAS, RangeLimitShape shape = RangeLimitShape.Circle) { this.MaxRange = maxRange; this.LightWalls = lightWalls; this.Method = method; this.Shape = shape; }
/// <summary> /// Computes the field of view using the specified method. This will modify the visible state of each cell /// using the IFovCell.IsVisible setter. /// </summary> /// <param name="viewpointX">The point of view X coordinate (e.g. player position)</param> /// <param name="viewpointY">The point of view Y coordinate (e.g. player position)</param> /// <param name="maxRange">The maximum range of the field of view.</param> /// <param name="lightWalls">True if walls within the field-of-view should be set as visible</param> /// <param name="method">The method to be used to compute the field of view</param> /// <param name="rangeShape">The shape of the boundary between cells within maxRange and those outside maxRange</param> public void ComputeFov(int viewpointX, int viewpointY, int maxRange, bool lightWalls, FOVMethod method, RangeLimitShape rangeShape = RangeLimitShape.Circle) { ClearFov(); switch (method) { case FOVMethod.MRPAS: if (mrps == null) { mrps = new MRPAS <TFovCell>(this); } mrps.ComputeFOV(viewpointX, viewpointY, maxRange, lightWalls, rangeShape); break; case FOVMethod.RecursiveShadowcasting: if (shadowCaster == null) { shadowCaster = new ShadowCasting <TFovCell>(this); } shadowCaster.ComputeFOV(viewpointX, viewpointY, maxRange, lightWalls, rangeShape); break; } }