Files
Nockin_On_Hells_Door/script/DoorView.cs
2024-10-20 14:52:24 +02:00

90 lines
1.5 KiB
C#

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;}
bool shot {get; set;}= true;
bool caniche {get; set;}= false;
CharacterBody2D player;
[Export] Label text_mob;
[Export] Button butA;
[Export] Button butB;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
player = (CharacterBody2D)GetParent().GetParent();
}
public async void start()
{
GetParent<Camera2D>().PositionSmoothingEnabled = false;
Input.MouseMode = Input.MouseModeEnum.Visible;
GetTree().Paused = true;
Visible = true;
mob.Texture = mobTex;
if(shot)
{
anim.Play("shot");
player.Call("OverShotgun");
}
else if (caniche)
{
anim.Play("can");
}
else
{
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;
}
public void APressed()
{
if(answerA_good)
{
player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40));
}
stop();
}
public void BPressed()
{
if(!answerA_good)
{
player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40));
}
stop();
}
}