game-dev #8
30
godot/AttributeBox.cs
Normal file
30
godot/AttributeBox.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class AttributeBox : SpinBox
|
||||
{
|
||||
// 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 override void _ValueChanged(double new_value)
|
||||
{
|
||||
nuint Strength = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Strength/SpinBox").Value;
|
||||
nuint Perception = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Perception/SpinBox").Value;
|
||||
nuint Endurance = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Endurance/SpinBox").Value;
|
||||
nuint Charisma = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Charisma/SpinBox").Value;
|
||||
nuint Intelligence = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Intelligence/SpinBox").Value;
|
||||
nuint Agility = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Agility/SpinBox").Value;
|
||||
nuint Luck = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Luck/SpinBox").Value;
|
||||
string Name = GetTree().Root.GetNode<TextEdit>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Name/NameEdit").Text;
|
||||
Player player = new Player{Name = Name, Strength = Strength, Perception = Perception, Endurance = Endurance, Charisma = Charisma, Intelligence = Intelligence, Agility = Agility, Luck = Luck};
|
||||
|
||||
GetTree().Root.GetNode<TextEdit>("Root/MainMenu/MainMenuCanvas/VBoxContainer/PointsLeft").Text = String.Format("Attribute Points Left: {0}", 35-player.StatSum());
|
||||
}
|
||||
}
|
@ -14,6 +14,5 @@ public partial class MainMenu : Node2D
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,36 @@ public partial class Playbutton : Button
|
||||
|
||||
public override void _Pressed()
|
||||
{
|
||||
llmApiRequests?.PostToApi(OnRequestCompleted);
|
||||
// GD.Print("is null? " + llmApiRequests is null);
|
||||
nuint Strength = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Strength/SpinBox").Value;
|
||||
nuint Perception = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Perception/SpinBox").Value;
|
||||
nuint Endurance = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Endurance/SpinBox").Value;
|
||||
nuint Charisma = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Charisma/SpinBox").Value;
|
||||
nuint Intelligence = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Intelligence/SpinBox").Value;
|
||||
nuint Agility = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Agility/SpinBox").Value;
|
||||
nuint Luck = (nuint) GetTree().Root.GetNode<SpinBox>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Luck/SpinBox").Value;
|
||||
string Name = GetTree().Root.GetNode<TextEdit>("Root/MainMenu/MainMenuCanvas/VBoxContainer/Name/NameEdit").Text;
|
||||
Player player = new Player{Name = Name, Strength = Strength, Perception = Perception, Endurance = Endurance, Charisma = Charisma, Intelligence = Intelligence, Agility = Agility, Luck = Luck};
|
||||
|
||||
if (player.isValid())
|
||||
{
|
||||
llmApiRequests?.PostToApi(OnRequestCompleted);
|
||||
|
||||
GD.Print("a");
|
||||
var node = this.GetTree().Root.GetNode<CanvasLayer>("Root/Ingame/IngameCanvas");
|
||||
node.SetProcess(true);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Strength").Text = String.Format("Strength: {0}", Strength);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Perception").Text = String.Format("Perception: {0}", Perception);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Endurance").Text = String.Format("Endurance: {0}", Endurance);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Charisma").Text = String.Format("Charisma: {0}", Charisma);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Intelligence").Text = String.Format("Intelligence: {0}", Intelligence);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Agility").Text = String.Format("Agility: {0}", Agility);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Luck").Text = String.Format("Luck: {0}", Luck);
|
||||
GetTree().Root.GetNode<TextEdit>("Root/Ingame/IngameCanvas/Stats/Name").Text = String.Format("Name: {0}", Name);
|
||||
|
||||
node.Show();
|
||||
var GParent = this.GetTree().Root.GetNode<CanvasLayer>("Root/MainMenu/MainMenuCanvas");
|
||||
GParent.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
|
||||
{
|
||||
|
36
godot/Player.cs
Normal file
36
godot/Player.cs
Normal file
@ -0,0 +1,36 @@
|
||||
public record Player
|
||||
{
|
||||
public string Name { get; init; }
|
||||
public nuint Strength { get; init; }
|
||||
public nuint Perception { get; init; }
|
||||
public nuint Endurance { get; init; }
|
||||
public nuint Charisma { get; init; }
|
||||
public nuint Intelligence { get; init; }
|
||||
public nuint Agility { get; init; }
|
||||
public nuint Luck { get; init; }
|
||||
|
||||
// public Person(string Name, nuint Strength, nuint Perception, nuint Endurance, nuint Charisma, nuint Intelligence, nuint Agility, nuint Luck, )
|
||||
// {
|
||||
// Name
|
||||
//}
|
||||
|
||||
public bool isValid()
|
||||
{
|
||||
return StatSum() <= 35;
|
||||
}
|
||||
|
||||
public nint StatSum()
|
||||
{
|
||||
nuint sum = 0;
|
||||
|
||||
sum += Strength;
|
||||
sum += Perception;
|
||||
sum += Endurance;
|
||||
sum += Charisma;
|
||||
sum += Intelligence;
|
||||
sum += Agility;
|
||||
sum += Luck;
|
||||
|
||||
return (nint) sum;
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://1gar30yhw8ay"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://1gar30yhw8ay"]
|
||||
|
||||
[ext_resource type="Script" path="res://MainMenu.cs" id="1_m0gay"]
|
||||
[ext_resource type="Texture2D" uid="uid://vn2ficr8n4n5" path="res://GodofAi.jpg" id="2_m684j"]
|
||||
[ext_resource type="Script" path="res://AttributeBox.cs" id="3_hpms0"]
|
||||
[ext_resource type="Script" path="res://Playbutton.cs" id="3_ucfae"]
|
||||
[ext_resource type="Script" path="res://LLMApiRequests.cs" id="4_ff2gi"]
|
||||
|
||||
@ -81,6 +82,39 @@ placeholder_text = "Enter a custom setting"
|
||||
drag_and_drop_selection_enabled = false
|
||||
middle_mouse_paste_enabled = false
|
||||
|
||||
[node name="PointsLeft" type="TextEdit" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
layout_direction = 1
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Attribute Points Left: 28"
|
||||
editable = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
middle_mouse_paste_enabled = false
|
||||
|
||||
[node name="Name" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="NameLabel" type="TextEdit" parent="MainMenu/MainMenuCanvas/VBoxContainer/Name"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Character Name:"
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
shortcut_keys_enabled = false
|
||||
selecting_enabled = false
|
||||
deselect_on_focus_loss_enabled = false
|
||||
drag_and_drop_selection_enabled = false
|
||||
virtual_keyboard_enabled = false
|
||||
middle_mouse_paste_enabled = false
|
||||
|
||||
[node name="NameEdit" type="TextEdit" parent="MainMenu/MainMenuCanvas/VBoxContainer/Name"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Strength" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
layout_mode = 2
|
||||
@ -105,6 +139,7 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Perception" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
@ -130,6 +165,7 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Endurance" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
@ -155,6 +191,7 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Charisma" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
@ -180,6 +217,7 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Intelligence" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
@ -205,14 +243,15 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Agillity" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
[node name="Agility" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 2
|
||||
|
||||
[node name="AgillityLabel" type="TextEdit" parent="MainMenu/MainMenuCanvas/VBoxContainer/Agillity"]
|
||||
[node name="AgilityLabel" type="TextEdit" parent="MainMenu/MainMenuCanvas/VBoxContainer/Agility"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Agillity"
|
||||
@ -225,11 +264,12 @@ drag_and_drop_selection_enabled = false
|
||||
virtual_keyboard_enabled = false
|
||||
middle_mouse_paste_enabled = false
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="MainMenu/MainMenuCanvas/VBoxContainer/Agillity"]
|
||||
[node name="SpinBox" type="SpinBox" parent="MainMenu/MainMenuCanvas/VBoxContainer/Agility"]
|
||||
layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Luck" type="HBoxContainer" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(520, 50)
|
||||
@ -255,6 +295,7 @@ layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 10.0
|
||||
value = 1.0
|
||||
script = ExtResource("3_hpms0")
|
||||
|
||||
[node name="Playbutton" type="Button" parent="MainMenu/MainMenuCanvas/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
@ -310,7 +351,13 @@ offset_bottom = -360.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="TextEdit" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Name" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
wrap_mode = 1
|
||||
|
||||
[node name="Strength" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
placeholder_text = "SampleStat = 1
|
||||
@ -318,37 +365,37 @@ placeholder_text = "SampleStat = 1
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit2" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Perception" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit3" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Endurance" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit4" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Charisma" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit5" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Intelligence" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit6" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Agility" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
context_menu_enabled = false
|
||||
|
||||
[node name="TextEdit7" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
[node name="Luck" type="TextEdit" parent="Ingame/IngameCanvas/Stats"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
editable = false
|
||||
|
Reference in New Issue
Block a user