Dwenny/Scripts/Main.gd

62 lines
1.7 KiB
GDScript3
Raw Normal View History

2024-01-17 23:40:36 +01:00
extends Control
@onready var MultiplierLB = $MainMC/VBoxContainer/EnumMC/EnumHB/VBoxContainer/MPLB/MultiplierLB
@onready var DieTypeLB = $MainMC/VBoxContainer/EnumMC/EnumHB/VBoxContainer2/DTTP/DieTypeLB
@onready var DieLB = $MainMC/VBoxContainer/Die/DiceCR/DieLB
@onready var topBG = $MainMC/VBoxContainer/Die/DiceCR
2024-01-17 23:40:36 +01:00
var Multiplier : int = 1
var ChosenDie : int = 20
var topBGdef = Color8(22, 22, 32, 255)
var topBGnat = Color8(0, 112, 57, 255)
var topBGcrit = Color8(136, 16, 0, 255)
2024-01-17 23:40:36 +01:00
func _ready():
topBG.color = topBGdef
2024-01-17 23:40:36 +01:00
pass
func _process(_delta):
MultiplierLB.text = str(Multiplier)
DieTypeLB.text = str(ChosenDie)
2024-01-17 23:40:36 +01:00
func Die():
var result = ChosenDie * Multiplier
var randomNumber = randi() % result + 1
if randomNumber != 20 and randf_range(0, 1) < 0.05:
randomNumber = 20
return randomNumber
2024-01-17 23:40:36 +01:00
var dice_values = [4, 6, 8, 10, 12, 20]
func _on_updt_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if ChosenDie < 20:
ChosenDie = dice_values[dice_values.find(ChosenDie)+1]
2024-01-17 23:40:36 +01:00
func _on_dwdt_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if ChosenDie > 4:
ChosenDie = dice_values[dice_values.find(ChosenDie)-1]
2024-01-17 23:40:36 +01:00
func _on_mpup_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if Multiplier < 10:
Multiplier += 1
2024-01-17 23:40:36 +01:00
func _on_mpdw_gui_input(event):
if event is InputEventScreenTouch and event.is_pressed():
if Multiplier > 1:
Multiplier -= 1
func _on_roll_rect_gui_input(event:InputEvent):
if event is InputEventScreenTouch and event.is_pressed():
var roll = Die();
DieLB.text = str(roll);
if roll == 20:
topBG.set_color(topBGnat)
if roll == 1:
topBG.set_color(topBGcrit)
if roll != 20 and roll != 1:
topBG.set_color(topBGdef)