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;}
	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 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;
	}
	
	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();
	}
}
