mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Squashed commit of the following:
commitdb69386b6d
Author: Andrew Tang <tandrew@gmail.com> Date: Mon Aug 1 02:48:32 2022 +0800 Test Lobby Working Server creation works and others are able to join by entering the creator's IP. Shows a list of player names (currently only shows player #) commit3fbf2640da
Author: Andrew Tang <tandrew@gmail.com> Date: Mon Jul 25 02:29:27 2022 +0800 Test Multiplayer commit59b74b946a
Author: Andrew Tang <tandrew@gmail.com> Date: Mon Jul 11 01:16:34 2022 +0800 Complete DiceRoller Singleton Version Created script: "DiceRoller.gd" to be the only dice script attached to a node and will act as a singleton. A single DieManager object is created in this script. The DieManager's values can be changed and methods can be called through the DiceRoller Script commit3a402d4331
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com> Date: Sun Jul 3 13:05:28 2022 -0400 Delete .DS_Store commitc00b24c60a
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com> Date: Sun Jul 3 13:05:16 2022 -0400 Delete .DS_Store commit4f788de0c7
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com> Date: Sun Jul 3 13:05:05 2022 -0400 Delete .DS_Store commitc20fd85567
Author: Andrew Tang <tandrew@gmail.com> Date: Mon Jul 4 00:13:15 2022 +0800 Added D10 and easier die selection
This commit is contained in:
parent
3bbeb5ddd6
commit
348823f34f
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1,3 @@
|
||||
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
|
||||
dest_md5="26ea799ea0a3da9e753b3ebe822e0570"
|
||||
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
|
||||
func instance_node(node: Object, parent: Object) -> Object:
|
||||
var node_instance = node.instance()
|
||||
parent.add_child(node_instance)
|
||||
return node_instance
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
extends Node
|
||||
|
||||
const DEFAULT_PORT = 28960
|
||||
const MAX_CLIENTS = 6
|
||||
|
||||
var server = null
|
||||
var client = null
|
||||
|
||||
var ip_address = ""
|
||||
|
||||
func _ready() -> void:
|
||||
ip_address = IP.get_local_addresses()[3]
|
||||
|
||||
for ip in IP.get_local_addresses():
|
||||
if ip.begins_with("192.168.") and not ip.ends_with(".1"):
|
||||
ip_address = ip
|
||||
|
||||
get_tree().connect("connected_to_server", self, "_connected_to_server")
|
||||
get_tree().connect("server_disconnected", self, "_server_disconnected")
|
||||
|
||||
func _create_server() -> void:
|
||||
server = NetworkedMultiplayerENet.new()
|
||||
server.create_server(DEFAULT_PORT, MAX_CLIENTS)
|
||||
get_tree().set_network_peer(server)
|
||||
|
||||
func _join_server() -> void:
|
||||
client = NetworkedMultiplayerENet.new()
|
||||
client.create_client(ip_address, DEFAULT_PORT)
|
||||
get_tree().set_network_peer(client)
|
||||
|
||||
func _connected_to_server() -> void:
|
||||
print("Successfully connected to the server")
|
||||
|
||||
func _server_disconnected() -> void:
|
||||
print("Disconnected from the server")
|
@ -0,0 +1,53 @@
|
||||
extends Control
|
||||
|
||||
|
||||
var playerCounter = 1
|
||||
var player = load("res://Player.tscn")
|
||||
|
||||
onready var multiplayer_config_ui = $Multiplayer_Configure
|
||||
onready var server_ip_address = $Multiplayer_Configure/Server_IP_Address
|
||||
onready var device_ip_address = $CanvasLayer/Device_IP_Address
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||
get_tree().connect("connected_to_server", self, "_connected_to_server")
|
||||
|
||||
device_ip_address.text = Network.ip_address
|
||||
|
||||
func _player_connected(id) -> void:
|
||||
print("Player " + str(id) + "connected")
|
||||
instance_player(id)
|
||||
|
||||
func _player_disconnected(id) -> void:
|
||||
print("Player " + str(id) + "disconnected")
|
||||
|
||||
if Players.has_node(str(id)):
|
||||
Players.get_node(str(id)).queue_free()
|
||||
|
||||
func _on_Create_Server_pressed():
|
||||
multiplayer_config_ui.hide()
|
||||
Network._create_server()
|
||||
instance_player(get_tree().get_network_unique_id())
|
||||
|
||||
func _on_Join_Server_pressed():
|
||||
if server_ip_address.text != "":
|
||||
multiplayer_config_ui.hide()
|
||||
Network.ip_address = server_ip_address.text
|
||||
Network._join_server()
|
||||
|
||||
func _connected_to_server() -> void:
|
||||
yield(get_tree().create_timer(0.1), "timeout")
|
||||
instance_player(get_tree().get_network_unique_id())
|
||||
|
||||
func instance_player(id) -> void:
|
||||
var player_instance = Global.instance_node(player, Players)
|
||||
player_instance.name = str(id)
|
||||
var player_name = "Player " + str(playerCounter)
|
||||
player_instance._set_name(player_name)
|
||||
player_instance._set_name_position(playerCounter)
|
||||
player_instance.set_network_master(id)
|
||||
playerCounter += 1
|
@ -0,0 +1,58 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Network_Setup.gd" type="Script" id=1]
|
||||
|
||||
[node name="Network_Setup" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Multiplayer_Configure" type="Control" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="Create_Server" type="Button" parent="Multiplayer_Configure"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -125.0
|
||||
margin_top = 21.0
|
||||
margin_right = 125.0
|
||||
margin_bottom = 121.0
|
||||
text = "Create Server"
|
||||
|
||||
[node name="Join_Server" type="Button" parent="Multiplayer_Configure"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -125.0
|
||||
margin_top = -129.0
|
||||
margin_right = 125.0
|
||||
margin_bottom = -29.0
|
||||
text = "Join Server"
|
||||
|
||||
[node name="Server_IP_Address" type="LineEdit" parent="Multiplayer_Configure"]
|
||||
margin_left = 389.0
|
||||
margin_top = 82.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 132.0
|
||||
text = "Enter IP Address"
|
||||
align = 1
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Device_IP_Address" type="Label" parent="CanvasLayer"]
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -1.0
|
||||
margin_top = -76.0
|
||||
margin_right = -1.0
|
||||
margin_bottom = -26.0
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[connection signal="pressed" from="Multiplayer_Configure/Create_Server" to="." method="_on_Create_Server_pressed"]
|
||||
[connection signal="pressed" from="Multiplayer_Configure/Join_Server" to="." method="_on_Join_Server_pressed"]
|
@ -0,0 +1,7 @@
|
||||
extends Control
|
||||
|
||||
func _set_name(name) -> void:
|
||||
$Name.text = name
|
||||
|
||||
func _set_name_position(counterVal) -> void:
|
||||
$Name.rect_position.y = -225 + (50 * counterVal)
|
@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||
|
||||
[node name="Player" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Name" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -175.0
|
||||
margin_bottom = -175.0
|
||||
text = "Name"
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Players" type="Label" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -225.0
|
||||
margin_bottom = -225.0
|
||||
text = "Players:"
|
||||
align = 1
|
||||
valign = 1
|
@ -0,0 +1,3 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Players" type="Node"]
|
@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -0,0 +1,29 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Multiplayer Test"
|
||||
run/main_scene="res://Network_Setup.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
Network="*res://Network.gd"
|
||||
Global="*res://Global.gd"
|
||||
Players="*res://Players.tscn"
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
Loading…
Reference in New Issue
Block a user