-
Notifications
You must be signed in to change notification settings - Fork 0
/
Piece.cs
91 lines (80 loc) · 1.36 KB
/
Piece.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
using Godot;
using System;
using System.Collections.Generic;
using CustomConstants;
public partial class Piece : Node2D
{
private int _tileID;
// | Type | Value |
// | ---- | ----------- |
// | -4 | BLACK_100PX |
// | -3 | BLACK_75PX |
// | -2 | BLACK_50PX |
// | -1 | BLACK_25PX |
// | +4 | WHITE_100PX |
// | +3 | WHITE_75PX |
// | +2 | WHITE_50PX |
// | +1 | WHITE_25PX |
private int _type;
private TileTypes _tileType;
public Piece()
{
_tileID = -1;
_type = 0;
_tileType = TileTypes.NONE;
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// 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 int Type
{
get
{
return _type;
}
set
{
_type = value;
}
}
public TileTypes TileType
{
get
{
return _tileType;
}
set
{
_tileType = value;
}
}
public void SetTexture(Texture2D texture)
{
GetNode<TextureRect>("Icon").Texture = texture;
}
[Signal]
public delegate void PieceSelectedEventHandler(Piece piece);
private void OnGUIInput(InputEvent @event)
{
if (@event.IsActionPressed("mouse_left"))
{
EmitSignal(SignalName.PieceSelected, this);
}
}
}