Money
This commit is contained in:
parent
4e8971b12d
commit
e9f4c6e5f8
4 changed files with 59 additions and 6 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://j5lgbg8c0pq"]
|
[gd_scene load_steps=5 format=3 uid="uid://j5lgbg8c0pq"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://b1ej6kmbjpm78" path="res://scenes/gui/buy_menu/buy_button/buy_button.tscn" id="1_8guql"]
|
[ext_resource type="PackedScene" uid="uid://b1ej6kmbjpm78" path="res://scenes/gui/buy_menu/buy_button/buy_button.tscn" id="1_8guql"]
|
||||||
[ext_resource type="Script" uid="uid://dba17sgimp4j0" path="res://scenes/gui/buy_menu/buy_menu.gd" id="1_ko0fn"]
|
[ext_resource type="Script" uid="uid://dba17sgimp4j0" path="res://scenes/gui/buy_menu/buy_menu.gd" id="1_ko0fn"]
|
||||||
[ext_resource type="Resource" uid="uid://b081hg7uxx1wu" path="res://weapons/molikman_molotov.tres" id="2_0gws3"]
|
[ext_resource type="Resource" uid="uid://b081hg7uxx1wu" path="res://weapons/molikman_molotov.tres" id="2_0gws3"]
|
||||||
|
[ext_resource type="Script" uid="uid://dk4diwvruvkch" path="res://scenes/gui/buy_menu/player_money_label.gd" id="2_ll0n6"]
|
||||||
|
|
||||||
[node name="BuyMenu" type="ColorRect"]
|
[node name="BuyMenu" type="ColorRect"]
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -25,13 +26,20 @@ mouse_filter = 2
|
||||||
[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"]
|
[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="WeaponsContainer" type="GridContainer" parent="CenterContainer/PanelContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
columns = 5
|
|
||||||
|
|
||||||
[node name="AbilitiesContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
|
[node name="AbilitiesContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="BuyButton" parent="CenterContainer/PanelContainer/AbilitiesContainer" instance=ExtResource("1_8guql")]
|
[node name="Label" type="Label" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
script = ExtResource("2_ll0n6")
|
||||||
|
|
||||||
|
[node name="WeaponsContainer" type="GridContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
columns = 5
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/PanelContainer/AbilitiesContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="BuyButton" parent="CenterContainer/PanelContainer/AbilitiesContainer/HBoxContainer" instance=ExtResource("1_8guql")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
weapon = ExtResource("2_0gws3")
|
weapon = ExtResource("2_0gws3")
|
||||||
|
|
|
||||||
7
scenes/gui/buy_menu/player_money_label.gd
Normal file
7
scenes/gui/buy_menu/player_money_label.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Label
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
var data = Session.get_player_data()
|
||||||
|
if data.has("money"):
|
||||||
|
text = str(data["money"])
|
||||||
1
scenes/gui/buy_menu/player_money_label.gd.uid
Normal file
1
scenes/gui/buy_menu/player_money_label.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dk4diwvruvkch
|
||||||
|
|
@ -16,6 +16,9 @@ enum ROUND_STATES {
|
||||||
AFTER_SESSION = 5,
|
AFTER_SESSION = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const WIN_MONEY: int = 3400
|
||||||
|
const LOSE_MONEY: int = 2000
|
||||||
|
|
||||||
const ATTACK_LAYER: int = 0b10000
|
const ATTACK_LAYER: int = 0b10000
|
||||||
const DEFENCE_LAYER: int = 0b100000
|
const DEFENCE_LAYER: int = 0b100000
|
||||||
|
|
||||||
|
|
@ -27,6 +30,7 @@ signal round_state_changed(state: int)
|
||||||
signal player_stopped_interacting(id: int)
|
signal player_stopped_interacting(id: int)
|
||||||
|
|
||||||
var player_nodes: Dictionary[int,Player] = {}
|
var player_nodes: Dictionary[int,Player] = {}
|
||||||
|
var player_data: Dictionary[int,Dictionary] = {}
|
||||||
var object_containers: Array[ObjectContainer]
|
var object_containers: Array[ObjectContainer]
|
||||||
|
|
||||||
var dynamic_objects_spawner: MultiplayerSpawner
|
var dynamic_objects_spawner: MultiplayerSpawner
|
||||||
|
|
@ -72,6 +76,7 @@ func _ready() -> void:
|
||||||
add_child(buy_timer)
|
add_child(buy_timer)
|
||||||
|
|
||||||
multiplayer.peer_connected.connect(sync_session_server)
|
multiplayer.peer_connected.connect(sync_session_server)
|
||||||
|
multiplayer.peer_disconnected.connect(delete_player)
|
||||||
|
|
||||||
func sync_session_server(id: int):
|
func sync_session_server(id: int):
|
||||||
if multiplayer.is_server() == false or session_started_flag == false:
|
if multiplayer.is_server() == false or session_started_flag == false:
|
||||||
|
|
@ -138,6 +143,14 @@ func start_session() -> void:
|
||||||
round_timer.wait_time = Lobby.round_time
|
round_timer.wait_time = Lobby.round_time
|
||||||
buy_timer.wait_time = Lobby.buy_time
|
buy_timer.wait_time = Lobby.buy_time
|
||||||
|
|
||||||
|
var all_players: PackedInt32Array = multiplayer.get_peers()
|
||||||
|
all_players.append(multiplayer.get_unique_id())
|
||||||
|
for player in all_players:
|
||||||
|
player_data[player] = {
|
||||||
|
"money" : 800,
|
||||||
|
"nickname" : "Seliboba"
|
||||||
|
}
|
||||||
|
|
||||||
start_round()
|
start_round()
|
||||||
|
|
||||||
@rpc("authority","call_remote","reliable")
|
@rpc("authority","call_remote","reliable")
|
||||||
|
|
@ -205,8 +218,16 @@ func end_round(win_team: int) -> void:
|
||||||
|
|
||||||
if win_team == TEAMS.DEFENCE:
|
if win_team == TEAMS.DEFENCE:
|
||||||
defender_score += 1
|
defender_score += 1
|
||||||
|
for defender in Lobby.defence_team:
|
||||||
|
player_data[defender].money += WIN_MONEY
|
||||||
|
for attacker in Lobby.attack_team:
|
||||||
|
player_data[attacker].money += LOSE_MONEY
|
||||||
elif win_team == TEAMS.ATTACK:
|
elif win_team == TEAMS.ATTACK:
|
||||||
attacker_score += 1
|
attacker_score += 1
|
||||||
|
for defender in Lobby.defence_team:
|
||||||
|
player_data[defender].money += LOSE_MONEY
|
||||||
|
for attacker in Lobby.attack_team:
|
||||||
|
player_data[attacker].money += WIN_MONEY
|
||||||
|
|
||||||
|
|
||||||
round_state = ROUND_STATES.AFTER_ROUND
|
round_state = ROUND_STATES.AFTER_ROUND
|
||||||
|
|
@ -353,3 +374,19 @@ func kill_site(site: StringName) -> void:
|
||||||
func sync_score(attack: int, defence: int):
|
func sync_score(attack: int, defence: int):
|
||||||
attacker_score = attack
|
attacker_score = attack
|
||||||
defender_score = defence
|
defender_score = defence
|
||||||
|
|
||||||
|
@rpc("authority","call_remote","reliable")
|
||||||
|
func delete_player(id: int):
|
||||||
|
if not is_server_request():
|
||||||
|
return
|
||||||
|
if multiplayer.is_server():
|
||||||
|
delete_player.rpc_id(id)
|
||||||
|
|
||||||
|
player_data.erase(id)
|
||||||
|
|
||||||
|
func get_player_data() -> Dictionary:
|
||||||
|
var id: int = multiplayer.get_unique_id()
|
||||||
|
if player_data.has(id):
|
||||||
|
return player_data[id]
|
||||||
|
else:
|
||||||
|
return {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue