-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayButton.cs
58 lines (51 loc) · 1.74 KB
/
PlayButton.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
using Godot;
public class PlayButton : Button
{
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
// Called when the node enters the scene tree for the first time.
private PackedScene _sceneRes;
public override void _Ready()
{
this.Connect("pressed", this, "HandlePressed");
this._sceneRes = GD.Load<PackedScene>("res://Node2D.tscn");
}
public void HandlePressed()
{
if (this.Name.ToLower().Contains("play"))
{
Node newRoot = this._sceneRes.Instance();
Node sceneRoot = this.GetParent().GetParent().GetParent().GetParent().GetParent();
Node uiRoot = this.GetParent().GetParent().GetParent().GetParent();
GD.Print(uiRoot.Name);
if (newRoot is GameScript gs)
{
gs.SetMainMenu((Node2D)uiRoot);
}
sceneRoot.RemoveChild(uiRoot);
sceneRoot.AddChild(newRoot);
}
else
{
if (this.Name.ToLower().Contains("bestiary"))
{
Node uiRoot = this.GetParent().GetParent().GetParent().GetParent();
Node2D selfContainer = (Node2D)uiRoot.GetNode("MainMenuProper");
Node2D bestiaryContainer = (Node2D)uiRoot.GetNode("Bestiary");
bestiaryContainer.Visible = true;
selfContainer.Visible = false;
((UIRoot)uiRoot).PrepareBestiary();
}
else
{
this.GetTree().Quit();
}
}
}
// // Called every frame. 'delta' is the elapsed time since the previous frame.
// public override void _Process(float delta)
// {
//
// }
}