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
|
2024-01-19 21:09:49 +01:00
|
|
|
@onready var topBG = $MainMC/VBoxContainer/Die/DiceCR
|
2024-01-17 23:40:36 +01:00
|
|
|
|
|
|
|
var Multiplier : int = 1
|
|
|
|
var ChosenDie : int = 20
|
|
|
|
|
2024-01-19 21:09:49 +01:00
|
|
|
|
|
|
|
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():
|
2024-01-19 21:09:49 +01:00
|
|
|
topBG.color = topBGdef
|
2024-01-17 23:40:36 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
func _process(_delta):
|
2024-01-19 14:07:20 +01:00
|
|
|
MultiplierLB.text = str(Multiplier)
|
|
|
|
DieTypeLB.text = str(ChosenDie)
|
2024-01-17 23:40:36 +01:00
|
|
|
|
|
|
|
func Die():
|
2024-01-19 14:07:20 +01:00
|
|
|
var result = ChosenDie * Multiplier
|
2024-01-19 21:09:49 +01:00
|
|
|
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
|
|
|
|
2024-01-19 14:07:20 +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):
|
2024-01-19 14:07:20 +01:00
|
|
|
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):
|
2024-01-19 14:07:20 +01:00
|
|
|
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):
|
2024-01-19 14:07:20 +01:00
|
|
|
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():
|
2024-01-19 21:09:49 +01:00
|
|
|
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)
|