je sais pas trop mais bcp

This commit is contained in:
2024-10-19 17:51:07 +02:00
parent 1594b25ffc
commit 585d6d787e
31 changed files with 1410 additions and 14 deletions

View File

@@ -8,10 +8,12 @@ public partial class Door : Node2D
[Export] string answerA;
[Export] string answerB;
[Export] bool answerA_good;
[ExportGroup("image")]
[Export] Texture2D image_mob;
bool player_in = false;
public override void _Ready()
{
}
CharacterBody2D player;
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
@@ -19,14 +21,22 @@ public partial class Door : Node2D
if(player_in && Input.IsActionPressed("interact"))
{
Control view = player.GetNode<Control>("Camera2D/door_view");
view.Set("text_char", text_char);
view.Set("answerA", answerA);
view.Set("answerB", answerB);
view.Set("answerA_good", answerA_good);
view.Set("mobTex", image_mob);
view.Call("start");
}
}
public void BodyEntered(Node body)
public void BodyEntered(Node2D body)
{
if(body is CharacterBody2D)
{
player = (CharacterBody2D)body;
player_in = true;
}
}

46
script/DoorView.cs Normal file
View File

@@ -0,0 +1,46 @@
using Godot;
using System;
using System.Diagnostics;
public partial class DoorView : Control
{
[Export] Sprite2D mob;
[Export] AnimationPlayer anim;
Texture2D mobTex {get; set;}
string text_char{get; set;}
string answerA{get; set;}
string answerB{get; set;}
bool answerA_good {get; set;}
[Export] Label text_mob;
[Export] Button butA;
[Export] Button butB;
// Called when the node enters the scene tree for the first time.
public void start()
{
GetParent<Camera2D>().PositionSmoothingEnabled = false;
GetTree().Paused = true;
Visible = true;
mob.Texture = mobTex;
anim.Play("enter");
}
public void stop()
{
GetParent<Camera2D>().PositionSmoothingEnabled = false;
GetTree().Paused = false;
Visible = false;
anim.Play("RESET");
}
public void TreatPressed()
{
anim.Play("question");
text_mob.Text = text_char;
butA.Text = answerA;
butB.Text = answerB;
}
}