summaryrefslogtreecommitdiff
path: root/scripts/map/Map.cs
blob: 41bd7f8e6540469f44b94ca11b2b069ad83291a5 (plain)
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
38
39
40
41
42
43
using Godot;
using System;

public partial class Map : Node2D
{
	public MapData Map_Data { get; private set; }

	[Export]
	private int fovRadius = 12;

	DungeonGenerator generator;

	FieldOfView fieldOfView;

	public override void _Ready()
	{
		base._Ready();

		generator = GetNode<DungeonGenerator>("Generator");
		fieldOfView = GetNode<FieldOfView>("FieldOfView");
	}

	private void PlaceTiles() {
		foreach (Tile tile in Map_Data.Tiles) {
			AddChild(tile);
		}
	}

	public void Generate(Player player)
	{
		Map_Data = generator.GenerateDungeon(player);

		Map_Data.InsertActor(player);

		player.Map_Data = Map_Data;

		PlaceTiles();
	}

	public void UpdateFOV(Vector2I pos) {
		fieldOfView.UpdateFOV(Map_Data, pos, fovRadius);
	}
}