Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 4fe40a3

Browse files
committed
More changes
1 parent 3a6170b commit 4fe40a3

6 files changed

Lines changed: 86 additions & 22 deletions

File tree

scenes/levels/ExampleScene.tscn

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=135 format=4 uid="uid://dfkwq6qwtxw25"]
1+
[gd_scene load_steps=136 format=4 uid="uid://dfkwq6qwtxw25"]
22

33
[ext_resource type="Script" path="res://scripts/EnemyManager.cs" id="1_bmkfv"]
44
[ext_resource type="Script" path="res://scripts/Map.cs" id="1_pa1ge"]
@@ -58,6 +58,7 @@
5858
[ext_resource type="Texture2D" uid="uid://b1n85g1blpu64" path="res://assets/tilemaps/Houses.png" id="49_pb6br"]
5959
[ext_resource type="Texture2D" uid="uid://cmy47y4t8sx0w" path="res://assets/sprites/BigTree.ShrubberyAnimation.png" id="58_5gqqc"]
6060
[ext_resource type="PackedScene" uid="uid://xy3d46bjniyg" path="res://scenes/levels/BigTree/insideBigTree.tscn" id="58_llp75"]
61+
[ext_resource type="PackedScene" uid="uid://dkj8strm3dfar" path="res://scenes/prefabs/teleport.tscn" id="59_8fv5o"]
6162

6263
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qwcva"]
6364
bg_color = Color(0.6, 0.6, 0.6, 0.654902)
@@ -14970,8 +14971,9 @@ vertices = PackedVector2Array(14513, -10165, 14519, 6775.99, -14133, 6772, 13685
1497014971
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(3, 2, 4, 5)])
1497114972
outlines = Array[PackedVector2Array]([PackedVector2Array(-14143, 6782, -14143, -13823, 13696, -13824, 13695, -10176, 14523, -10175, 14529, 6786), PackedVector2Array(441.376, 2548.91, 716.14, 2538.64, 721.255, 2638.77, 461.107, 2617.72)])
1497214973

14973-
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g520r"]
14974-
size = Vector2(190.043, 242.52)
14974+
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_6rxiw"]
14975+
radius = 198.002
14976+
height = 625.975
1497514977

1497614978
[sub_resource type="SegmentShape2D" id="SegmentShape2D_i54bb"]
1497714979
a = Vector2(-14, -120)
@@ -15895,9 +15897,9 @@ ShowWhileInRadius = true
1589515897

1589615898
[node name="CollisionShape2D" type="CollisionShape2D" parent="Big Tree/StaticBody2D"]
1589715899
z_index = 50
15898-
position = Vector2(95, -200)
15900+
position = Vector2(94, -259)
1589915901
rotation = -1.56722
15900-
shape = SubResource("RectangleShape2D_g520r")
15902+
shape = SubResource("CapsuleShape2D_6rxiw")
1590115903

1590215904
[node name="CaveEntranceTerminal" parent="." instance=ExtResource("13_05imv")]
1590315905
unique_name_in_owner = true
@@ -15914,7 +15916,7 @@ position = Vector2(-60, 114)
1591415916
shape = SubResource("SegmentShape2D_i54bb")
1591515917

1591615918
[node name="Scar" parent="." instance=ExtResource("13_05imv")]
15917-
position = Vector2(5613, -8059)
15919+
position = Vector2(5647, -8048)
1591815920
ObjectName = "Scar"
1591915921
ObjectDescription = "A big scar on the tree which could be the reason for the tree looking dead. It is not reachable because of the scrub"
1592015922
CustomOverrideMessage = "The tree seems to have recovered from the injurys and opens up to give the entrance to it's inside."
@@ -15954,17 +15956,6 @@ shape = SubResource("SegmentShape2D_k0qre")
1595415956
[node name="Big Tree" type="Sprite2D" parent="Node2D"]
1595515957
position = Vector2(5613, -8059)
1595615958

15957-
[node name="InsideBigTree" parent="Node2D/Big Tree" instance=ExtResource("58_llp75")]
15958-
z_index = 30
15959-
position = Vector2(114, 58)
15960-
scale = Vector2(2.5, 2.5)
15961-
15962-
[node name="ShowWhileInRadius" type="Node2D" parent="Node2D/Big Tree"]
15963-
scale = Vector2(2.5, 2.5)
15964-
script = ExtResource("25_0y114")
15965-
SceneToShow = ExtResource("58_llp75")
15966-
Radius = 500
15967-
1596815959
[node name="AnimationPlayer" type="AnimationPlayer" parent="Node2D"]
1596915960
root_node = NodePath("../TreeScrub")
1597015961
libraries = {
@@ -15977,3 +15968,13 @@ position = Vector2(5655, -8388)
1597715968
scale = Vector2(3.5, 3.5)
1597815969
texture = ExtResource("58_5gqqc")
1597915970
hframes = 17
15971+
15972+
[node name="Teleport" parent="." instance=ExtResource("59_8fv5o")]
15973+
position = Vector2(5994, -7764)
15974+
X = 9641
15975+
Y = -8454
15976+
Length = 100
15977+
Width = 20
15978+
15979+
[node name="InsideBigTree" parent="." instance=ExtResource("58_llp75")]
15980+
position = Vector2(9641, -8454)

scenes/prefabs/teleport.tscn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://dkj8strm3dfar"]
2+
3+
[ext_resource type="Script" path="res://scripts/Teleport.cs" id="1_dwwji"]
4+
5+
[node name="Teleport" type="Node2D"]
6+
script = ExtResource("1_dwwji")

scripts/AI/GeminiService.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.Generic;
34
using System.IO;
5+
using System.Linq;
46
using System.Threading;
57
using System.Threading.Tasks;
8+
using System.Transactions;
69

10+
using GenerativeAI.Exceptions;
711
using GenerativeAI.Methods;
812
using GenerativeAI.Models;
913
using GenerativeAI.Types;
1014

1115
using Godot;
16+
using Godot.Collections;
1217

1318
namespace Game.Scripts.AI;
1419

@@ -60,10 +65,13 @@ public GeminiService(string apiKeyFilePath, string systemPrompt) // Add systemPr
6065
}
6166
}
6267

63-
private readonly Queue<string> _queryQueue = new();
64-
private readonly SemaphoreSlim _semaphore = new(1, 1);
68+
private readonly Queue<string> _queryQueue = new Queue<string>();
69+
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
6570

66-
public bool IsBusy() => _queryQueue.Count > 0;
71+
public bool IsBusy()
72+
{
73+
return _queryQueue.Count > 0;
74+
}
6775

6876
public async Task<string?> MakeQuery(string input)
6977
{
@@ -100,7 +108,13 @@ public GeminiService(string apiKeyFilePath, string systemPrompt) // Add systemPr
100108
{
101109
GD.Print("tried 3 times but didn't get a response. Giving up now.");
102110
}
103-
111+
else
112+
{
113+
int waitingTimeInMs = (int)(1000 * 0.01f * result!.Length);
114+
GD.Print("got response of length: " + result!.Length + ". Waiting for: " +
115+
waitingTimeInMs + " ms.");
116+
await Task.Delay(waitingTimeInMs);
117+
}
104118
return result;
105119
}
106120
finally

scripts/Ally.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ private async void ProcessResponseQueue() // Changed to async Task
351351
// Get the ButtonControl (consider caching this)
352352
ButtonControl buttonControl = GetTree().Root.GetNode<ButtonControl>("Node2D/UI");
353353

354-
buttonControl.TypeWriterEffect(richtext, _responseField);
354+
await buttonControl.TypeWriterEffect(richtext, _responseField);
355355

356356
IsTextBoxReady = true; // Consider removing this; see below
357357
}

scripts/Interaction/Interactable.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ public void Trigger(Node caller)
7272
//Tree is now cured (for story progression)
7373
GD.Print("Tree cured");
7474
TreeCured = true;
75+
76+
GD.Print("Teleport spawned");
77+
PackedScene scene = (PackedScene)ResourceLoader.Load("res://scenes/prefabs/teleport.tscn");
78+
Teleport instance = scene.Instantiate<Teleport>();
79+
instance.Position += new Vector2(0, 100);
80+
81+
7582
}
7683
//Cave entrance
7784
if(GetParent<AiNode>().Name.Equals("CaveEntranceTerminal") && caller.Name.ToString().Contains("Ally")) {

scripts/Teleport.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Game.Scripts;
2+
3+
using Godot;
4+
using System;
5+
6+
public partial class Teleport : Node2D
7+
{
8+
[Export] public int X {get; set; }
9+
[Export] public int Y { get; set; }
10+
[Export] public int Length { get; set; }
11+
[Export] public int Width { get; set; }
12+
[Export] public bool Vertical { get; set; }
13+
Ally _ally1 = null!;
14+
Ally _ally2 = null!;
15+
16+
public override void _Ready()
17+
{
18+
_ally1 = GetTree().Root.GetNode<Ally>("Node2D/Ally");
19+
_ally2 = GetTree().Root.GetNode<Ally>("Node2D/Ally2");
20+
}
21+
22+
23+
public override void _Process(double delta)
24+
{
25+
if(!Vertical &&_ally1.GlobalPosition.Y < GlobalPosition.Y + Width && _ally1.GlobalPosition.Y > GlobalPosition.Y - Width && _ally1.GlobalPosition.X < GlobalPosition.X + Length && _ally1.GlobalPosition.X > GlobalPosition.X - Length) {
26+
_ally1.GlobalPosition = new Vector2(X, GlobalPosition.Y);
27+
} else if(Vertical && _ally1.GlobalPosition.Y < GlobalPosition.Y + Length && _ally1.GlobalPosition.Y > GlobalPosition.Y - Length && _ally1.GlobalPosition.X < GlobalPosition.X + Width && _ally1.GlobalPosition.X > GlobalPosition.X - Width) {
28+
_ally1.GlobalPosition = new Vector2(X, Y);
29+
}
30+
if(!Vertical &&_ally2.GlobalPosition.Y < GlobalPosition.Y + Width && _ally2.GlobalPosition.Y > GlobalPosition.Y - Width && _ally2.GlobalPosition.X < GlobalPosition.X + Length && _ally2.GlobalPosition.X > GlobalPosition.X - Length) {
31+
_ally2.GlobalPosition = new Vector2(X, Y);
32+
} else if(Vertical && _ally2.GlobalPosition.Y < GlobalPosition.Y + Length && _ally2.GlobalPosition.Y > GlobalPosition.Y - Length && _ally2.GlobalPosition.X < GlobalPosition.X + Width && _ally2.GlobalPosition.X > GlobalPosition.X - Width) {
33+
_ally2.GlobalPosition = new Vector2(X, Y);
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)