using Godot; using System; using System.Collections.Generic; using System.Diagnostics; public partial class DoorView : Control { [Export] Sprite2D mob; [Export] AnimationPlayer anim; [Export] Control menu; 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; bool trick_bool = false; List txt = new List(); // Called when the node enters the scene tree for the first time. public override void _Ready() { txt.Add("Black spell of destruction"); txt.Add("Necromancy"); txt.Add("Freezing Moon"); txt.Add("Journey to the stars"); txt.Add("The power of souls"); txt.Add("Mutilations internes"); txt.Add("Manual Breathing"); txt.Add("Spectral visions of mental warfare"); player = (CharacterBody2D)GetParent().GetParent(); } public async void start() { trick_bool = false; GetParent().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("cani"); player.Call("OverCanicheAsync"); } else { anim.Play("enter"); } } public void stop() { Input.MouseMode = Input.MouseModeEnum.Hidden; GetParent().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(trick_bool) { anim.Play("close"); } else if(answerA_good) { player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40)); } stop(); } public void BPressed() { if(trick_bool) { anim.Play("close"); } else if(!answerA_good) { player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40)); } stop(); } public void TrickPressed() { trick_bool = true; int s = (int)menu.Get("spell"); menu.Set("spell", ++s); text_mob.Text = "-You have casted : " + txt[s-1] + "\n- It : ...?"; butA.Text = "##############"; butB.Text = "##############"; anim.Play("question"); } }