-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDice.cs
More file actions
34 lines (28 loc) · 992 Bytes
/
Dice.cs
File metadata and controls
34 lines (28 loc) · 992 Bytes
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
using Godot;
using System;
public partial class Dice : AnimatedSprite2D
{
public DiceValue Value => (DiceValue) this.Frame + 1;
// This represents which
public int Ordinal => this.Name.ToString()[^1] - '0';
// 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 void OnMouseInput(Node viewPort, InputEvent @event, int shapeIdx)
{
Main mainScene = GetNode<Main>("../..");
if (mainScene.CanLockDice && @event is InputEventMouseButton mouseButton)
{
if (mouseButton.ButtonIndex == MouseButton.Left && mouseButton.Pressed)
{
string lockName = "../Lock" + Ordinal;
GetNode<Sprite2D>(lockName).Visible = !GetNode<Sprite2D>(lockName).Visible;
}
}
}
}