Browse Source

fgnfgjngfjh

galo 1 year ago
parent
commit
8564036010
10 changed files with 150 additions and 139 deletions
  1. 6 0
      Client.gd
  2. 1 1
      Enemy.tscn
  3. 10 12
      NPC/soldier/soldieranim.tscn
  4. 3 0
      Server.gd
  5. 23 24
      enemy.tres.gd
  6. 87 87
      main.tscn
  7. 1 1
      placeholder.gd
  8. 1 0
      playerphysics.gd
  9. 14 10
      playersprite.tscn
  10. 4 4
      project.godot

+ 6 - 0
Client.gd

@@ -198,6 +198,12 @@ remote func atr_update(arg):
 	if has_node('Hud/HBoxContainer/'+arg.keys()[0]):
 		get_node('Hud/HBoxContainer/'+arg.keys()[0])._update(arg.values()[0])
 
+remote func player_death_update(id):
+	print('die1')
+	if not has_node("players"): return
+	print('die2')
+	$players.get_node(str(id))._die()
+
 remote func level_up(arg, id):
 	if not has_node("players"): return
 	$players.get_node(str(id)).level_up_anim()

+ 1 - 1
Enemy.tscn

@@ -79,7 +79,7 @@ collision_mask = 2
 shape = SubResource( 2 )
 
 [connection signal="body_entered" from="damage_enemy" to="damage_enemy" method="_on_damage_player_body_entered"]
-[connection signal="body_entered" from="damage_enemy2" to="damage_enemy2" method="_on_damage_enemy2_body_entered"]
 [connection signal="body_entered" from="damage_enemy2" to="damage_enemy2" method="_on_damage_player_body_entered"]
+[connection signal="body_entered" from="damage_enemy2" to="damage_enemy2" method="_on_damage_enemy2_body_entered"]
 [connection signal="body_exited" from="damage_enemy2" to="damage_enemy2" method="_on_damage_enemy2_body_exited"]
 [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

+ 10 - 12
NPC/soldier/soldieranim.tscn

@@ -5075,7 +5075,7 @@ tracks/67/keys = {
 }
 
 [sub_resource type="Animation" id=7]
-length = 1.3
+length = 9999.0
 tracks/0/type = "value"
 tracks/0/path = NodePath("body/arm2/forearm/hand:scale")
 tracks/0/interp = 1
@@ -28811,7 +28811,7 @@ text1 = ExtResource( 5 )
 text2 = ExtResource( 16 )
 
 [node name="body2" type="Sprite" parent="body"]
-position = Vector2( -2.75282, 22.6649 )
+position = Vector2( -50.4592, 37.7804 )
 rotation = -0.079361
 texture = ExtResource( 5 )
 offset = Vector2( 0.543118, -4.89887 )
@@ -28847,22 +28847,22 @@ frame = 7
 
 [node name="Sprite3" type="Sprite" parent="body/head"]
 position = Vector2( 1, 0 )
-scale = Vector2( 1.1, 1 )
 texture = ExtResource( 2 )
-offset = Vector2( 0, -7 )
+offset = Vector2( 0, -6 )
 hframes = 5
 vframes = 4
 frame = 5
 
 [node name="medal" type="Sprite" parent="body"]
-position = Vector2( 1.38842, 17.3504 )
-z_index = 3
+position = Vector2( -53.6039, 32.9591 )
+rotation = -1.38497
+z_index = 1
 texture = ExtResource( 5 )
 region_enabled = true
 region_rect = Rect2( 126.614, 74.6779, 5.20671, 6.94229 )
 
 [node name="belt" type="Sprite" parent="body"]
-position = Vector2( -2.57571, 23.7251 )
+position = Vector2( -47.4071, 37.8406 )
 rotation = -0.316536
 z_index = 1
 texture = ExtResource( 5 )
@@ -28889,6 +28889,7 @@ region_rect = Rect2( 82, 34, 7, 13 )
 
 [node name="feet" type="Sprite" parent="body/leg"]
 position = Vector2( -2.1086, 9.42322 )
+rotation = 1.80001
 texture = ExtResource( 5 )
 region_enabled = true
 region_rect = Rect2( 7, 45, 6, 10 )
@@ -28911,7 +28912,7 @@ region_rect = Rect2( 7, 44, 6, 10 )
 
 [node name="arm" type="Sprite" parent="body"]
 show_behind_parent = true
-position = Vector2( -7.23355, 13.0581 )
+position = Vector2( -59.6218, 43.3193 )
 rotation = -0.714288
 z_index = 4
 texture = ExtResource( 5 )
@@ -28936,7 +28937,6 @@ region_rect = Rect2( 76.8466, 81.4215, 10.1525, 6.2971 )
 
 [node name="hand" type="Sprite" parent="body/arm/forearm"]
 position = Vector2( 4.42659, 3.85746 )
-rotation = 1.14058
 texture = ExtResource( 5 )
 offset = Vector2( 1.62801, 0.0316229 )
 region_enabled = true
@@ -28962,7 +28962,6 @@ rotation = -0.874789
 z_index = 3
 
 [node name="handle" type="Node2D" parent="body/gun"]
-position = Vector2( 14.9428, -3.99877 )
 
 [node name="Sprite" type="Sprite" parent="body/gun/handle"]
 position = Vector2( 0.255894, 1.32609 )
@@ -28986,7 +28985,7 @@ texture = ExtResource( 14 )
 
 [node name="arm2" type="Sprite" parent="body"]
 show_behind_parent = true
-position = Vector2( 0.744329, 14.8486 )
+position = Vector2( -56.4615, 32.1943 )
 rotation = -1.16319
 texture = ExtResource( 5 )
 offset = Vector2( 0, 3.18198 )
@@ -29019,7 +29018,6 @@ region_rect = Rect2( 76.8466, 81.4215, 10.1525, 6.2971 )
 
 [node name="hand" type="Sprite" parent="body/arm2/forearm"]
 position = Vector2( 4.42659, 2.26468 )
-rotation = 1.28061
 z_index = 2
 texture = ExtResource( 5 )
 offset = Vector2( 1.62801, 0.0316229 )

+ 3 - 0
Server.gd

@@ -185,6 +185,9 @@ func player_anim(attack,arg):
 func hp_update(vida, id):
 	rpc_id( 0,'atr_update', {id:{'hp':vida}})
 
+func player_death(id):
+	rpc_id( 0,'player_death_update', id)
+
 func kill_update(kill, xp, lv, nxt, id):
 	rpc_id( 0,'atr_update', {id:{'k':kill, 'xp':xp, 'lv':lv, 'nxt':nxt}})
 

+ 23 - 24
enemy.tres.gd

@@ -27,30 +27,29 @@ var state = 'runaround'
 var fliph = false
 
 func _physics_process(delta):
-	tick += 1
-	if fmod(tick,tickrate) == 0:
-		match state:
-			'runaround':
-				type = 0 if motion.x == 0 else 1
-				fliph = motion.x > 0 and motion.x != 0
-				if target == null: _ready()
-				if target == null: return
-				dir_buffer += 1
-				if fmod(dir_buffer,reaction_time) == 0:
-					if is_instance_valid(target): motion.x = (target.global_position - global_position).normalized().x * speed
-				motion.y += 15
-				if motion.y > 0 and is_on_floor(): motion.y = 0
-				move_and_slide(motion*tickrate,Vector2.UP)
-			'shooting':
-					type = 2
-					if fmod(tick,75) == 0:
-						var instance = bullet.instance()
-						instance.motion.x = 200 if fliph else -200
-						instance.global_position = global_position + Vector2(0,-8)
-						instance.id = name
-						instance.dmg = 10
-						instance.target = 'player'
-						get_tree().get_nodes_in_group('proj')[0].add_child(instance)
+	match state:
+		'runaround':
+			type = 0 if motion.x == 0 else 1
+			fliph = motion.x > 0 and motion.x != 0
+			if target == null: _ready()
+			if target == null: return
+			dir_buffer += 1
+			if fmod(dir_buffer,reaction_time) == 0:
+				if is_instance_valid(target): motion.x = (target.global_position - global_position).normalized().x * speed
+			motion.y += 15
+			if motion.y > 0 and is_on_floor(): motion.y = 0
+			move_and_slide(motion*tickrate,Vector2.UP)
+		'shooting':
+				type = 2
+				tick += 1
+				if fmod(tick,75) == 0:
+					var instance = bullet.instance()
+					instance.motion.x = 200 if fliph else -200
+					instance.global_position = global_position + Vector2(0,-8)
+					instance.id = name
+					instance.dmg = 10
+					instance.target = 'player'
+					get_tree().get_nodes_in_group('proj')[0].add_child(instance)
 
 func _on_Area2D_body_entered(body):
 	print(body)

File diff suppressed because it is too large
+ 87 - 87
main.tscn


+ 1 - 1
placeholder.gd

@@ -25,7 +25,7 @@ func find_target():
 		return data[0]
 
 var bullet = preload('res://bullet.tscn')
-var firerate = 0
+var firerate = 30
 var fireratebuff = 30
 var alert = false
 

+ 1 - 0
playerphysics.gd

@@ -20,6 +20,7 @@ func damage(arg, id):
 	vida += arg
 	get_tree().get_nodes_in_group('server')[0].hp_update(vida, name)
 	if vida <= 0: 
+		get_tree().get_nodes_in_group('server')[0].player_death(name)
 		queue_free()
 
 func regenhp(arg):

+ 14 - 10
playersprite.tscn

@@ -13,13 +13,13 @@ script/source = "extends Node2D
 export var animation = 'idle'
 export var flip_h = false
 
-# Called when the node enters the scene tree for the first time.
-func _ready():
-#	speed_scale = rand_range(0.8,1.2)
-	pass # Replace with function body.
+var die = false
 
 func _physics_process(delta):
-	$SoldierAnim/AnimationPlayer.play(animation)
+	if die:
+		$SoldierAnim/AnimationPlayer.play('die4')
+	else:
+		$SoldierAnim/AnimationPlayer.play(animation)
 	$SoldierAnim.scale.x = -1 if flip_h else 1
 
 func shooting():
@@ -34,6 +34,10 @@ func message(arg):
 	$message.text = arg
 	$AnimationPlayer3.play(\"msg\")
 
+func _die():
+	print('die3')
+	die = true
+
 # Called every frame. 'delta' is the elapsed time since the previous frame.
 #func _process(delta):
 #	pass
@@ -209,13 +213,13 @@ anchor_top = 0.5
 anchor_right = 0.5
 anchor_bottom = 0.5
 margin_left = -29.5
-margin_top = -67.1752
+margin_top = -6.0
 margin_right = 29.5
-margin_bottom = -55.1752
-rect_scale = Vector2( 3, 1e-05 )
+margin_bottom = 6.0
+rect_scale = Vector2( 1e-05, 3 )
 rect_pivot_offset = Vector2( 27.5174, 6.3988 )
-custom_colors/font_color = Color( 0.688718, 0.956076, 0.892019, 1 )
-custom_colors/font_outline_modulate = Color( 0.221796, 0.266142, 0.474243, 1 )
+custom_colors/font_color = Color( 1, 0.717647, 0.305882, 1 )
+custom_colors/font_outline_modulate = Color( 1, 0.156863, 0.0470588, 1 )
 custom_fonts/font = SubResource( 34 )
 text = "Level Up"
 align = 1

+ 4 - 4
project.godot

@@ -71,25 +71,25 @@ f3={
 }
 ui_attack={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":88,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
 , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
  ]
 }
 ui_jump={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
 , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
  ]
 }
 opts={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777217,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
 , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
  ]
 }
 f12={
 "deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":16777255,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
  ]
 }
 

Some files were not shown because too many files changed in this diff