-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunicQuestMap.cs
37 lines (33 loc) · 1.47 KB
/
RunicQuestMap.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using GoRogue;
using Microsoft.Xna.Framework;
using SadConsole;
namespace RunicQuest
{
internal enum MapLayer
{
TERRAIN,
ITEMS,
MONSTERS,
PLAYER
}
internal class RunicQuestMap : BasicMap
{
// Handles the changing of tile/entity visiblity as appropriate based on Map.FOV.
public FOVVisibilityHandler FovVisibilityHandler { get; }
// Since we'll want to access the player as our Player type, create a property to do the cast for us. The cast must succeed thanks to the ControlledGameObjectTypeCheck
// implemented in the constructor.
public new Player ControlledGameObject
{
get => (Player)base.ControlledGameObject;
set => base.ControlledGameObject = value;
}
public RunicQuestMap(int width, int height)
// Allow multiple items on the same location only on the items layer. This example uses 8-way movement, so Chebyshev distance is selected.
: base(width, height, Enum.GetNames(typeof(MapLayer)).Length - 1, Distance.CHEBYSHEV, entityLayersSupportingMultipleItems: LayerMasker.DEFAULT.Mask((int)MapLayer.ITEMS))
{
ControlledGameObjectChanged += ControlledGameObjectTypeCheck<Player>; // Make sure we don't accidentally assign anything that isn't a Player type to ControlledGameObject
FovVisibilityHandler = new DefaultFOVVisibilityHandler(this, ColorAnsi.BlackBright);
}
}
}