-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTile.cs
115 lines (103 loc) · 1.72 KB
/
Tile.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using Godot;
using System;
using CustomConstants;
using System.Collections.Generic;
public partial class Tile : Control
{
private int _tileID;
private TileTypes _type;
private ColorRect _filter;
private TileStates _state;
private Stack<Piece> _pieces;
public Tile()
{
_tileID = -1;
_type = TileTypes.NONE;
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
_filter = GetNode<ColorRect>("Filter");
_state = TileStates.NONE;
_pieces = new Stack<Piece>();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public int TileID
{
get
{
return _tileID;
}
set
{
_tileID = value;
}
}
public TileTypes Type
{
get
{
return _type;
}
set
{
if (value != TileTypes.PLAYGROUND)
{
GetNode<TextureRect>("Icon").Texture = null;
}
_type = value;
}
}
public TileStates State
{
get
{
return _state;
}
set
{
_state = value;
}
}
public Stack<Piece> Pieces
{
get
{
return _pieces;
}
set
{
_pieces = value;
}
}
public void SetFilter(TileStates state = TileStates.NONE)
{
_state = state;
switch (state)
{
case TileStates.NONE:
_filter.Color = new Color(0, 0, 0, 0);
break;
case TileStates.LEGITIMATE:
_filter.Color = new Color(0, 1, 0, (float)0.4);
break;
case TileStates.ILLEGITIMATE:
_filter.Color = new Color(1, 0, 0, (float)0.4);
break;
default:
break;
}
}
[Signal]
public delegate void TileClickedEventHandler(Tile tile);
private void OnGUIInput(InputEvent @event)
{
if (@event.IsActionPressed("mouse_left"))
{
EmitSignal(SignalName.TileClicked, this);
}
}
}