game-dev #8

Merged
leon merged 9 commits from game-dev into dev/game 2023-09-24 13:32:16 +02:00
2 changed files with 30 additions and 9 deletions
Showing only changes of commit 0b7257c971 - Show all commits

10
godot/God of AI.csproj Normal file
View File

@ -0,0 +1,10 @@
<Project Sdk="Godot.NET.Sdk/4.1.1">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>GodofAI</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

View File

@ -1,27 +1,38 @@
using Godot; using Godot;
using System; using System;
using System.Net.Cache;
public partial class Playbutton : Button public partial class Playbutton : Button
{ {
private LLMApiRequest llmApiRequest;
// Called when the node enters the scene tree for the first time. // Called when the node enters the scene tree for the first time.
public override void _Ready() public override void _Ready()
{ {
this.Pressed += ButtonPressed; SetProcess(false);
llmApiRequest = GetNode<LLMApiRequest>("/root/Node2D/HTTPRequests");
} }
// Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Pressed()
public override void _Process(double delta) {
{ // llmApiRequest.RequestCompleted += OnRequestCompleted;
// llmApiRequest.Request("https://api.github.com/repos/godotengine/godot/releases/latest");
llmApiRequest?.PostToApi(OnRequestCompleted);
}
private void ButtonPressed()
{
GD.Print("a"); GD.Print("a");
var node = this.GetNode<CanvasLayer>("Ingame/Ingame"); var node = this.GetNode<CanvasLayer>("Ingame/Ingame");
node.SetProcess(true); node.SetProcess(true);
node.Show(); node.Show();
var GParent = this.GetTree().Root.GetNode<CanvasLayer>("Root/Hauptmenü/HauptMenü"); var GParent = this.GetTree().Root.GetNode<CanvasLayer>("Root/Hauptmenü/HauptMenü");
GParent.Hide(); GParent.Hide();
} }
private void OnRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
{
// Godot.Collections.Dictionary json = Json.ParseString(System.Text.Encoding.UTF8.GetString(body)).AsGodotDictionary();
// GD.Print(json["name"]);
// GD.Print(Json.ParseString(System.Text.Encoding.UTF8.GetString(body)).AsGodotDictionary());
GD.Print(System.Text.Encoding.UTF8.GetString(body));
}
} }