Dunno
This commit is contained in:
parent
d02fe3256d
commit
f9f94b446a
|
@ -48,7 +48,6 @@ script = ExtResource( 2 )
|
||||||
scale = Vector2( 4, 4 )
|
scale = Vector2( 4, 4 )
|
||||||
frames = SubResource( 7 )
|
frames = SubResource( 7 )
|
||||||
animation = "idle"
|
animation = "idle"
|
||||||
frame = 1
|
|
||||||
playing = true
|
playing = true
|
||||||
offset = Vector2( 1, -11 )
|
offset = Vector2( 1, -11 )
|
||||||
|
|
||||||
|
@ -60,4 +59,8 @@ script = ExtResource( 3 )
|
||||||
[node name="nav_line" type="Line2D" parent="."]
|
[node name="nav_line" type="Line2D" parent="."]
|
||||||
points = PoolVector2Array( 0, 30, 30, 30, 0, 0 )
|
points = PoolVector2Array( 0, 30, 30, 30, 0, 0 )
|
||||||
|
|
||||||
|
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
|
||||||
|
target_desired_distance = 60.0
|
||||||
|
radius = 30.0
|
||||||
|
|
||||||
[connection signal="die" from="hurtbox" to="." method="_on_hurtbox_die"]
|
[connection signal="die" from="hurtbox" to="." method="_on_hurtbox_die"]
|
||||||
|
|
|
@ -31,6 +31,7 @@ func _draw():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
print("Slime nav %s %s %s" % [navigation, position, target_player.position])
|
||||||
nav_path = navigation.get_simple_path(position, target_player.position)
|
nav_path = navigation.get_simple_path(position, target_player.position)
|
||||||
if not nav_path.empty() and (position - target_player.position).length() > (128 + 64):
|
if not nav_path.empty() and (position - target_player.position).length() > (128 + 64):
|
||||||
if (nav_path[0] - position).length() < 5: target_position = nav_path[1]
|
if (nav_path[0] - position).length() < 5: target_position = nav_path[1]
|
||||||
|
|
|
@ -13,6 +13,8 @@ onready var current_zoom_level_index = 2
|
||||||
onready var player = null
|
onready var player = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
if not get_tree().network_peer:
|
||||||
|
Global.client.singleplayer()
|
||||||
for c in players.get_children(): c.queue_free()
|
for c in players.get_children(): c.queue_free()
|
||||||
# TODO: probably have to wait for all peers to be ready before we add players
|
# TODO: probably have to wait for all peers to be ready before we add players
|
||||||
# camera.zoom = Vector2(0.25, 0.25)
|
# camera.zoom = Vector2(0.25, 0.25)
|
||||||
|
|
14
server.ts
14
server.ts
|
@ -1,6 +1,6 @@
|
||||||
// import { randomInt } from "./deps.ts";
|
// import { randomInt } from "./deps.ts";
|
||||||
|
|
||||||
const SERVER_VERSION = "0.2.0";
|
const SERVER_VERSION = "1.0.0";
|
||||||
// TODO: version comparison
|
// TODO: version comparison
|
||||||
|
|
||||||
type ID = number;
|
type ID = number;
|
||||||
|
@ -69,9 +69,7 @@ class Client {
|
||||||
try {
|
try {
|
||||||
if (this.isConnected()) {
|
if (this.isConnected()) {
|
||||||
this.socket.send(
|
this.socket.send(
|
||||||
typeof message === "object"
|
typeof message === "object" ? (JSON.stringify(message)) : message,
|
||||||
? ("json:" + JSON.stringify(message))
|
|
||||||
: message,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// TODO: maybe log when we try to send and we're not connected?
|
// TODO: maybe log when we try to send and we're not connected?
|
||||||
|
@ -333,15 +331,15 @@ interface ClientMessage {
|
||||||
|
|
||||||
function parseMessage(message: string): { type: string; data?: ServerData } {
|
function parseMessage(message: string): { type: string; data?: ServerData } {
|
||||||
const trimmedMessage = message.trim();
|
const trimmedMessage = message.trim();
|
||||||
if (trimmedMessage.startsWith("json:")) {
|
if (trimmedMessage.startsWith("{")) {
|
||||||
const { type, ...data } = JSON.parse(trimmedMessage.substr(5));
|
const { type, ...data } = JSON.parse(trimmedMessage);
|
||||||
return { type, data };
|
return { type, data };
|
||||||
} else {
|
} else {
|
||||||
const splitAt = trimmedMessage.indexOf(":");
|
const splitAt = trimmedMessage.indexOf(":");
|
||||||
if (splitAt > 0) {
|
if (splitAt > 0) {
|
||||||
return {
|
return {
|
||||||
type: trimmedMessage.substr(0, splitAt),
|
type: trimmedMessage.substring(0, splitAt),
|
||||||
data: trimmedMessage.substr(splitAt + 1),
|
data: trimmedMessage.substring(splitAt + 1),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return { type: trimmedMessage };
|
return { type: trimmedMessage };
|
||||||
|
|
Loading…
Reference in a new issue