-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiniMapPanel.cs
81 lines (75 loc) · 1.98 KB
/
MiniMapPanel.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class MiniMapPanel : MonoBehaviour
{
public Dictionary<Vector2,MapCell> mapCells;
public Dictionary<Vector2, TileType> mapData;
public static MiniMapPanel instance;
void Start()
{
SetInstance();
}
public void SetInstance()
{
if (instance != null)
{
return;
}
else
{
instance = this;
}
}
public void SetCellPosition()
{
int count = 0;
foreach (Vector2 pos in mapData.Keys.ToList())
{
MapCell mapCell = transform.GetChild(count).transform.GetComponent<MapCell>();
Vector2 transePos = new Vector2(pos.y, pos.x);
mapCell.SetPosition(transePos);
mapCells[transePos] = mapCell;
mapCells[transePos].SetTilePosition(mapData[pos]);
count++;
}
}
public void UpDateMinimap()
{
MapMake mapScript = GameManager.instance.mapScript;
foreach(Vector2 pos in mapScript.objLayers.Keys)
{
if(mapCells[pos].tileLayer != mapScript.objLayers[pos])
{
mapCells[pos].tileLayer = mapScript.objLayers[pos];
CellColorChange(pos, mapScript.objLayers[pos]);
}
}
Debug.Log("minimap Update");
}
public void CellColorChange(Vector2 pos, int layer)
{
if(mapData == null)
{
mapData = GameManager.instance.mapScript.TileMap;
}
if (mapData.ContainsKey(pos))
{
if(layer == 7)
{
layer = 8;
}
mapCells[pos].tileLayer = layer;
mapCells[pos].ChangeToLayer();
}
}
public void MiniMapReset()
{
foreach(Vector2 key in mapCells.Keys)
{
mapCells[key].tileLayer = 6;
CellColorChange(key,6);
}
}
}