legacy
Jan Heemstra 2021-04-12 22:57:16 +02:00
commit 673f193ae7
10 changed files with 79 additions and 18 deletions

View File

@ -86,7 +86,6 @@ curve = SubResource( 6 )
[sub_resource type="ParticlesMaterial" id=8]
lifetime_randomness = 0.65
spread = 180.0
initial_velocity = 10.0
initial_velocity_random = 1.0
damping = 7.82
@ -116,9 +115,9 @@ gradient = SubResource( 11 )
[sub_resource type="ParticlesMaterial" id=13]
lifetime_randomness = 0.34
spread = 180.0
initial_velocity = 10.0
initial_velocity_random = 1.0
spread = 35.0
initial_velocity = 14.0
initial_velocity_random = 0.7
damping = 7.82
damping_random = 0.92
scale = 0.5
@ -160,7 +159,7 @@ _data = [ Vector2( 0, 0.278253 ), 0.0, 1.12677, 0, 0, Vector2( 1, 1 ), 0.0, 0.0,
curve = SubResource( 18 )
[sub_resource type="ParticlesMaterial" id=20]
spread = 180.0
spread = 30.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 5.0
initial_velocity_random = 0.2
@ -205,28 +204,34 @@ mesh = SubResource( 5 )
material/0 = null
[node name="ParticlesDust" type="Particles" parent="."]
transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
emitting = false
amount = 128
lifetime = 2.0
one_shot = true
explosiveness = 1.0
local_coords = false
process_material = SubResource( 8 )
draw_pass_1 = SubResource( 10 )
[node name="ParticlesSparks" type="Particles" parent="."]
transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
emitting = false
amount = 32
lifetime = 2.0
one_shot = true
explosiveness = 1.0
local_coords = false
process_material = SubResource( 13 )
draw_pass_1 = SubResource( 15 )
[node name="ParticlesSmoke" type="Particles" parent="."]
transform = Transform( -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0 )
emitting = false
lifetime = 4.0
one_shot = true
explosiveness = 1.0
local_coords = false
process_material = SubResource( 20 )
draw_pass_1 = SubResource( 22 )

View File

@ -3,6 +3,8 @@ extends Spatial
var first = true
var velocity = 200
const bullet_hit = preload("res://Assets/Effects/BulletHit.tscn")
func _ready():
translate_object_local(Vector3(-10,0,0))
set_process(true)
@ -10,9 +12,22 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
translate_object_local(Vector3(-velocity * delta,0,0))
if $RayCast.is_colliding():
if $RayCast.get_collider() is Player:
queue_free()
else:
var bullet_hit_effect = bullet_hit.instance()
bullet_hit_effect.global_translate($RayCast.get_collision_point())
#bullet_hit_effect.global_transform *= bullet_hit_effect.global_transform.looking_at($RayCast.get_collision_point() + $RayCast.get_collision_normal(), Vector3.UP)
get_tree().root.call_deferred("add_child", bullet_hit_effect)
queue_free()
const casing = preload("res://Assets/Weapons/Handgun/Casing.gd")
func _on_Raycast_body_entered(body):
if not (body is Player) and not (body is casing):
queue_free()
#var bullet_hit_effect = bullet_hit.instance()
#bullet_hit_effect.global_transform =
#get_tree().root.call_deferred("add_child")

View File

@ -10,9 +10,15 @@ length = 3.0
[node name="BulletTracer" type="Spatial"]
script = ExtResource( 1 )
[node name="RayCast" type="RayCast" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 0, 0.001 )
enabled = true
cast_to = Vector3( -10, 0, 0 )
[node name="Raycast" type="Area" parent="."]
transform = Transform( -1.62417e-07, 0, -0.996909, 0, 0.996909, 0, 0.996909, 0, -1.62417e-07, 2.816, -2.38419e-07, 0.000590307 )
input_ray_pickable = false
monitoring = false
monitorable = false
[node name="CollisionShape" type="CollisionShape" parent="Raycast"]

View File

@ -10,9 +10,11 @@ func updateHealth(health: int):
func update_crosshair(kill):
$Crosshair.visible = true # visible
$Crosshair/HitConfirmation.activate(0.15, false)
#$Crosshair/HitConfirmation.activate(0.15, false)
#if hit:
# $Crosshair/HitConfirmation.activate(0.15, false)
#elif kill:
# $Crosshair/HitConfirmation.activate(0.3, true)
print("HUD: kill = ", kill)
if kill:
$Crosshair/HitConfirmation.activate(0.3, true)
else:
$Crosshair/HitConfirmation.activate(0.15, false)

View File

@ -67,6 +67,14 @@ var bodyHitEffect = preload("res://Assets/Effects/BodyHit.tscn")
onready var nickname = "guest" setget set_nickname
var player_class = "none"
var player_stats = stats.new()
class stats:
var score: int
var kills: int
var deaths: int
var suicides: int
#func sfx_play_footsteps():
# if not sfx_footsteps_play:
# sfx_footsteps_play = true
@ -78,6 +86,11 @@ var player_class = "none"
# yield(get_tree().create_timer(sfx_footsteps_delay),"timeout")
# sfx_footsteps_play = false
func score(target):
print("Player ", name, " scored a kill on ", target)
player_stats.kills += 1
player_stats.score += 1
func set_health(value):
health = value
$HUD.updateHealth(value)
@ -305,6 +318,8 @@ master func kill():
$Sounds/Death.rpc("play")
is_dead = true
player_stats.deaths += 1
set_health(0)
$CollisionShapeBody.disabled = true

View File

@ -221,7 +221,7 @@ script = ExtResource( 8 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.53592, -0.0651628 )
[node name="Hand" type="Spatial" parent="Camera"]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.335, -0.394656, -0.559 )
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.335, -0.39946, -0.559 )
[node name="WeaponBobAnimationTree" type="AnimationTree" parent="Camera/Hand"]
tree_root = SubResource( 12 )

View File

@ -5,4 +5,5 @@ var network_id
func set_player(_player):
$Nickname.text = _player.nickname
$Score.text = String(_player.player_stats.score)
network_id = _player.name

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Classes/UI/PlayerListItem.gd" type="Script" id=1]
[ext_resource path="res://Classes/UI/theme.tres" type="Theme" id=2]
[node name="Player" type="HBoxContainer"]
margin_bottom = 14.0
@ -9,7 +10,18 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Score" type="Label" parent="."]
margin_right = 87.0
margin_bottom = 38.0
theme = ExtResource( 2 )
custom_colors/font_color = Color( 0.32549, 0.960784, 0.603922, 1 )
custom_constants/shadow_as_outline = 0
text = "SCORE"
[node name="Nickname" type="Label" parent="."]
margin_right = 28.0
margin_bottom = 14.0
text = "TEST"
margin_left = 91.0
margin_right = 232.0
margin_bottom = 38.0
theme = ExtResource( 2 )
text = "NICKNAME"
align = 2

View File

@ -68,12 +68,18 @@ func shoot(camera):
hit.rpc("on_hit", 30, result.position)
if hit is Player:
var kill = hit.health <= 0
var kill = true if hit.health <= 0 else false
print ("Player: kill = ", kill, " Target health: ", hit.health)
emit_signal("damage_dealt", kill)
print(get_signal_connection_list("damage_dealt")[0]["target"].name)
if kill:
player.score(hit.name)
#print(get_signal_connection_list("ammo_changed")[0]["target"].name)
emit_signal("ammo_changed", self)
else:
reload()

View File

@ -12,4 +12,3 @@ func update_player_list():
var player_list_item = preload("res://Classes/UI/PlayerListItem.tscn").instance()
$Panel/PlayerList.add_child(player_list_item)
player_list_item.player = player