first Prototype
This commit is contained in:
parent
e11825c698
commit
35ce267482
481 changed files with 17315 additions and 1 deletions
14
scenes/camera/UI/card.gd
Normal file
14
scenes/camera/UI/card.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class_name Card extends CenterContainer
|
||||
|
||||
@onready var itemButton = $ItemButton
|
||||
@onready var ItemAmountLabel = $ItemButton/ItemAmountLabel
|
||||
|
||||
@export var itemType: GLOBALS.ITEMTYPES = GLOBALS.ITEMTYPES.STANDARDBULLET
|
||||
|
||||
signal selected(_itemType: GLOBALS.ITEMTYPES)
|
||||
|
||||
func _on_item_button_pressed() -> void:
|
||||
selected.emit(itemType)
|
||||
|
||||
func setAmount(amount: int) -> void:
|
||||
ItemAmountLabel.text = str(amount)
|
||||
1
scenes/camera/UI/card.gd.uid
Normal file
1
scenes/camera/UI/card.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://culacsksqcquo
|
||||
39
scenes/camera/UI/card.tscn
Normal file
39
scenes/camera/UI/card.tscn
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bc84ynsnwc1ew"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bprr1g5mf44sm" path="res://assets/cards/cardPlaceholder.png" id="1_fobdo"]
|
||||
[ext_resource type="Script" uid="uid://culacsksqcquo" path="res://scenes/camera/UI/card.gd" id="1_wa0td"]
|
||||
[ext_resource type="Texture2D" uid="uid://cmnnfrkp1h5s0" path="res://assets/cards/bullet.png" id="2_wa0td"]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_qr7cc"]
|
||||
texture = ExtResource("1_fobdo")
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_6m2n3"]
|
||||
font_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="Card" type="CenterContainer"]
|
||||
script = ExtResource("1_wa0td")
|
||||
|
||||
[node name="ItemButton" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
tooltip_auto_translate_mode = 1
|
||||
theme_override_styles/normal = SubResource("StyleBoxTexture_qr7cc")
|
||||
icon = ExtResource("2_wa0td")
|
||||
|
||||
[node name="ItemAmountLabel" type="Label" parent="ItemButton"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -48.0
|
||||
offset_top = -30.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = -7.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "1"
|
||||
label_settings = SubResource("LabelSettings_6m2n3")
|
||||
horizontal_alignment = 2
|
||||
|
||||
[connection signal="pressed" from="ItemButton" to="." method="_on_item_button_pressed"]
|
||||
7
scenes/camera/UI/playerSelectionButton.gd
Normal file
7
scenes/camera/UI/playerSelectionButton.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
extends CheckBox
|
||||
|
||||
var player: Player
|
||||
|
||||
func setPlayer(_player: Player) -> void:
|
||||
text = _player.gameName
|
||||
player = _player
|
||||
1
scenes/camera/UI/playerSelectionButton.gd.uid
Normal file
1
scenes/camera/UI/playerSelectionButton.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0elwhiqu20i8
|
||||
8
scenes/camera/UI/playerSelectionButton.tscn
Normal file
8
scenes/camera/UI/playerSelectionButton.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://lsg8l7r66uyr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c0elwhiqu20i8" path="res://scenes/camera/UI/playerSelectionButton.gd" id="1_scfyp"]
|
||||
|
||||
[node name="playerSelectionButton" type="CheckBox"]
|
||||
offset_right = 24.0
|
||||
offset_bottom = 24.0
|
||||
script = ExtResource("1_scfyp")
|
||||
93
scenes/camera/camera.gd
Normal file
93
scenes/camera/camera.gd
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
extends Camera3D
|
||||
|
||||
@onready var playerSelectButton = preload("res://scenes/camera/UI/playerSelectionButton.tscn")
|
||||
|
||||
@onready var roundLabel = $CanvasLayer/Control/General/roundLabel
|
||||
@onready var playerNameLabel = $CanvasLayer/Control/Player/PlayerNameLabel
|
||||
@onready var itemCards = $CanvasLayer/Control/Player/ItemCards
|
||||
@onready var magazineLabel = $CanvasLayer/Control/Player/MagazineLabel
|
||||
@onready var playerSelection = $CanvasLayer/Control/Player/PlayerSelection
|
||||
|
||||
#@onready var itemStandardBulletButton = $
|
||||
var currentPlayer: Player
|
||||
var selectablePlayers: Array[Player]
|
||||
|
||||
signal itemSelected(_itemType: GLOBALS.ITEMTYPES)
|
||||
signal nextTurn()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
for i in itemCards.get_children():
|
||||
if i.has_signal("selected"):
|
||||
i.selected.connect(selectItem.bind())
|
||||
|
||||
func setRound(_round: int) -> void:
|
||||
roundLabel.text = str(_round)
|
||||
|
||||
func updatePlayerStats():
|
||||
playerNameLabel.text = str(currentPlayer.getGameName())
|
||||
magazineLabel.text = str(currentPlayer.gun.magazineSize) + "/" + str(currentPlayer.gun.getBulletAmount())
|
||||
updatePlayerSelection()
|
||||
updateItemCards()
|
||||
|
||||
func setCurrentPlayer(_currentPlayer: Player):
|
||||
currentPlayer = _currentPlayer
|
||||
updatePlayerStats()
|
||||
|
||||
func selectItem(_itemType: GLOBALS.ITEMTYPES):
|
||||
print(currentPlayer.gun.magazineSizeLeft())
|
||||
if currentPlayer.gun.magazineSizeLeft() > 0:
|
||||
itemSelected.emit(_itemType)
|
||||
|
||||
func updateItemCards() -> void:
|
||||
if currentPlayer.gun.magazineSizeLeft() <= 0:
|
||||
for i in itemCards.get_children():
|
||||
if i.has_node("ItemButton"):
|
||||
i.itemButton.disabled = true
|
||||
else:
|
||||
for i in itemCards.get_children():
|
||||
if i.has_node("ItemButton"):
|
||||
i.itemButton.disabled = false
|
||||
for i in GLOBALS.ITEMTYPES:
|
||||
var counter = 0
|
||||
for j in currentPlayer.getItems():
|
||||
if j.type == GLOBALS.ITEMTYPES[i]:
|
||||
counter += 1
|
||||
for j in itemCards.get_children():
|
||||
if j.has_node("ItemButton/ItemAmountLabel") and j.itemType == GLOBALS.ITEMTYPES[i]:
|
||||
j.setAmount(counter)
|
||||
if counter <= 0:
|
||||
j.visible = false
|
||||
else:
|
||||
j.visible = true
|
||||
|
||||
|
||||
func updatePlayerSelection() -> void:
|
||||
for i in playerSelection.get_children():
|
||||
i.free()
|
||||
var newButtonGroup = ButtonGroup.new()
|
||||
for i in selectablePlayers:
|
||||
if i != currentPlayer:
|
||||
var newSelection = playerSelectButton.instantiate()
|
||||
newSelection.setPlayer(i)
|
||||
newSelection.button_group = newButtonGroup
|
||||
playerSelection.add_child(newSelection)
|
||||
|
||||
playerSelection.get_child(0).button_pressed = true
|
||||
var newSelection = playerSelectButton.instantiate()
|
||||
newSelection.setPlayer(currentPlayer)
|
||||
newSelection.button_group = newButtonGroup
|
||||
playerSelection.add_child(newSelection)
|
||||
|
||||
|
||||
|
||||
func _on_next_turn_button_pressed() -> void:
|
||||
currentPlayer.selectPlayer(getPlayerSelection())
|
||||
nextTurn.emit()
|
||||
|
||||
|
||||
func getPlayerSelection() -> Player:
|
||||
for i in playerSelection.get_children():
|
||||
if i.button_pressed == true:
|
||||
return i.player
|
||||
return currentPlayer
|
||||
1
scenes/camera/camera.gd.uid
Normal file
1
scenes/camera/camera.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bvkbh5ngdd0dt
|
||||
120
scenes/camera/camera.tscn
Normal file
120
scenes/camera/camera.tscn
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://ct45lmxlrkhaj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bvkbh5ngdd0dt" path="res://scenes/camera/camera.gd" id="1_xejhd"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc84ynsnwc1ew" path="res://scenes/camera/UI/card.tscn" id="2_6m2n3"]
|
||||
|
||||
[node name="Camera3D" type="Camera3D"]
|
||||
current = true
|
||||
script = ExtResource("1_xejhd")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Control" type="Control" parent="CanvasLayer"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="General" type="Control" parent="CanvasLayer/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="roundLabel" type="Label" parent="CanvasLayer/Control/General"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -32.0
|
||||
offset_top = 16.0
|
||||
offset_right = -22.0
|
||||
offset_bottom = 39.0
|
||||
grow_horizontal = 0
|
||||
text = "0"
|
||||
|
||||
[node name="Player" type="Control" parent="CanvasLayer/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PlayerNameLabel" type="Label" parent="CanvasLayer/Control/Player"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -24.0
|
||||
offset_top = 16.0
|
||||
offset_right = 24.0
|
||||
offset_bottom = 39.0
|
||||
grow_horizontal = 2
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="nextTurnButton" type="Button" parent="CanvasLayer/Control/Player"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -96.0
|
||||
offset_top = -48.0
|
||||
offset_right = -17.0
|
||||
offset_bottom = -17.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "Continue"
|
||||
|
||||
[node name="ItemCards" type="HBoxContainer" parent="CanvasLayer/Control/Player"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -136.0
|
||||
offset_right = 112.0
|
||||
offset_bottom = -10.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="Card" parent="CanvasLayer/Control/Player/ItemCards" instance=ExtResource("2_6m2n3")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Card2" parent="CanvasLayer/Control/Player/ItemCards" instance=ExtResource("2_6m2n3")]
|
||||
layout_mode = 2
|
||||
itemType = 2
|
||||
|
||||
[node name="MagazineLabel" type="Label" parent="CanvasLayer/Control/Player"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 16.0
|
||||
offset_top = -184.0
|
||||
offset_right = 56.0
|
||||
offset_bottom = -161.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="PlayerSelection" type="VBoxContainer" parent="CanvasLayer/Control/Player"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
anchor_top = 0.5
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -64.0
|
||||
offset_top = -20.0
|
||||
offset_right = -24.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
alignment = 1
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/Control/Player/nextTurnButton" to="." method="_on_next_turn_button_pressed"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue