Add basic gavel and bidding window functionality
This commit is contained in:
parent
5f20aa5907
commit
cb51053572
7 changed files with 71 additions and 3 deletions
18
desk.tscn
Normal file
18
desk.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bohp0o2smdkwe"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c2mrlu8d75ry4" path="res://gavel.gd" id="1_ep8l3"]
|
||||||
|
[ext_resource type="Script" uid="uid://l7wiwo13pb0f" path="res://numpad.gd" id="2_t5y75"]
|
||||||
|
|
||||||
|
[node name="Desk" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Gavel" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("1_ep8l3")
|
||||||
|
|
||||||
|
[node name="TextureButton" type="TextureButton" parent="Gavel"]
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="Numpad" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("2_t5y75")
|
||||||
|
|
||||||
|
[connection signal="button_down" from="Gavel/TextureButton" to="Gavel" method="_on_texture_button_button_down"]
|
||||||
|
|
@ -3,6 +3,8 @@ extends Node2D
|
||||||
var paintings_sold = 0
|
var paintings_sold = 0
|
||||||
var paintings_total = 0
|
var paintings_total = 0
|
||||||
|
|
||||||
|
var paintings: Array = Array()
|
||||||
|
|
||||||
# tracker variables for bid markers, proposing bids happens between numpad and audience
|
# tracker variables for bid markers, proposing bids happens between numpad and audience
|
||||||
var current_bid = 0
|
var current_bid = 0
|
||||||
var final_bid = 0
|
var final_bid = 0
|
||||||
|
|
@ -11,11 +13,24 @@ var target_sales: int = 0
|
||||||
var total_sales: int = 0
|
var total_sales: int = 0
|
||||||
|
|
||||||
# state tracker for a given painting's auction
|
# state tracker for a given painting's auction
|
||||||
var bidding_open = false
|
var bidding_open: bool = false
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
paintings_total = randi_range(7,10)
|
paintings_total = randi_range(7,10)
|
||||||
target_sales = (paintings_total * 100000)/randf_range(1.25,2) # need to workshop the target sales generation process for more interesting numbers
|
target_sales = (paintings_total * 100000)/randf_range(1.25,2) # need to workshop the target sales generation process for more interesting numbers
|
||||||
|
|
||||||
|
#var e = 0
|
||||||
|
#for painting in paintings:
|
||||||
|
#if e <= paintings_total:
|
||||||
|
#paintings.append()
|
||||||
|
|
||||||
|
|
||||||
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
print("You have " + str(paintings_total) + " paintings. Sell them for at least $" + str(target_sales) + " or face the consequences!")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func _on_gavel_gavel_hit():
|
||||||
|
bidding_open = not bidding_open
|
||||||
|
if bidding_open == true:
|
||||||
|
current_bid = target_sales/(paintings_total + 2)
|
||||||
|
else:
|
||||||
|
total_sales = total_sales + current_bid
|
||||||
|
|
|
||||||
29
gavel.gd
Normal file
29
gavel.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
signal gavel_hit
|
||||||
|
|
||||||
|
var swinging
|
||||||
|
var click_radius = 32 # will need to determine click radius based on sprite size -- should be equal
|
||||||
|
var swing_threshold = 64 # will also need to scale this based on sprite size
|
||||||
|
var swing_start = Vector2(0, 0)
|
||||||
|
@export var gavel_root_position = Vector2(0, 0)
|
||||||
|
|
||||||
|
#func _input(event: InputEvent) -> void:
|
||||||
|
#if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
## check to see if the player clicked on the gavel
|
||||||
|
#if (event.position - $Sprite2D.position).length() < click_radius:
|
||||||
|
#if not swinging and event.pressed():
|
||||||
|
#swinging = true
|
||||||
|
#swing_start = InputEventMouseMotion.screen_relative
|
||||||
|
#if swinging and not event.pressed():
|
||||||
|
#swinging = false
|
||||||
|
#
|
||||||
|
#if event is InputEventMouseMotion and swinging:
|
||||||
|
#$Sprite2D.position = event.position
|
||||||
|
#if InputEventMouseMotion.screen_relative.length() - swing_start.length() == swing_threshold:
|
||||||
|
#gavel_hit.emit()
|
||||||
|
#$Sprite2D.position = gavel_root_position
|
||||||
|
|
||||||
|
|
||||||
|
func _on_texture_button_button_down() -> void:
|
||||||
|
gavel_hit.emit()
|
||||||
1
gavel.gd.uid
Normal file
1
gavel.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://c2mrlu8d75ry4
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://dt4nq0nkmjiit"]
|
[gd_scene load_steps=3 format=3 uid="uid://dt4nq0nkmjiit"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"]
|
[ext_resource type="Script" uid="uid://b5tcsve1oo5ht" path="res://game_manager.gd" id="1_ig7tw"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bohp0o2smdkwe" path="res://desk.tscn" id="2_0xm2m"]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
[node name="GameManager" type="Node2D" parent="."]
|
[node name="GameManager" type="Node2D" parent="."]
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
|
|
||||||
|
[node name="Desk" parent="." instance=ExtResource("2_0xm2m")]
|
||||||
|
|
|
||||||
1
numpad.gd
Normal file
1
numpad.gd
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
extends Node2D
|
||||||
1
numpad.gd.uid
Normal file
1
numpad.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://l7wiwo13pb0f
|
||||||
Loading…
Add table
Reference in a new issue