Skip to content

Commit

Permalink
#6: Basic inventory system with network sync, but still cannot gurant…
Browse files Browse the repository at this point in the history
…ee inventory always sync (include items + ammos). And will cause initial slowness in sync
  • Loading branch information
Danil Ko committed Mar 7, 2021
1 parent 23c11bd commit 763678b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ top - down 2D multiplayer base on godot

[Youtube Sample](https://www.youtube.com/playlist?list=PLlwvRbWsWmGUtEd47nyo0MUZJVJqvd4Iv)

[![Youtube Video Demo](https://i.ytimg.com/vi/6LY4GNfpTS8/hqdefault.jpg)](https://www.youtube.com/playlist?list=PLlwvRbWsWmGUtEd47nyo0MUZJVJqvd4Iv)
[![Youtube Video Demo](https://i.ytimg.com/vi/7CSTonTiJrk/hqdefault.jpg?sqp=-oaymwEXCNACELwBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLBPZMplyKSycnOMdniZqFKOLHUKFA)](https://www.youtube.com/playlist?list=PLlwvRbWsWmGUtEd47nyo0MUZJVJqvd4Iv)


Build Downloads
Expand Down
2 changes: 1 addition & 1 deletion inventory/InventoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public void UseItem(int inventoryIndex, Inventory inventory)
}
else
{
RpcId(1, nameof(_serverRemoveItem), info);
RpcId(1, nameof(_serverUseItem), info);
}

}
Expand Down
6 changes: 3 additions & 3 deletions map/GameWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,10 @@ private void _updateState()

foreach (KeyValuePair<int, GameStates.PlayerInput> input in GameStates.playerInputs[networkPlayer.Key])
{
Vector2 moveDir = new Vector2();
moveDir.y = -1 * input.Value.Up;
Vector2 moveDir = Vector2.Zero;
moveDir.y -= 1 * input.Value.Up;
moveDir.y += 1 * input.Value.Down;
moveDir.x = -1 * input.Value.Left;
moveDir.x -= 1 * input.Value.Left;
moveDir.x += 1 * input.Value.Right;

playerNode.changeWeapon(input.Value.RightWeaponIndex, Weapon.WeaponOrder.Right);
Expand Down
38 changes: 21 additions & 17 deletions projectiles/LaserRay.tscn
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=12 format=2]

[ext_resource path="res://projectiles/LaserRay.cs" type="Script" id=1]
[ext_resource path="res://assets/ui/blue_circle.png" type="Texture" id=2]
[ext_resource path="res://assets/ui/blue_tick.png" type="Texture" id=3]

[sub_resource type="Gradient" id=1]
[sub_resource type="CanvasItemMaterial" id=1]
blend_mode = 1

[sub_resource type="Gradient" id=2]
offsets = PoolRealArray( 0, 0.688222 )
colors = PoolColorArray( 0.5, 6, 9, 0.98, 1, 1, 1, 0 )

[sub_resource type="GradientTexture" id=2]
gradient = SubResource( 1 )
[sub_resource type="GradientTexture" id=3]
gradient = SubResource( 2 )

[sub_resource type="Curve" id=3]
[sub_resource type="Curve" id=4]
_data = [ Vector2( 0, 0.976136 ), 0.0, -0.0740261, 0, 0, Vector2( 0.502193, 0.976136 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), -1.36878, -1.36878, 0, 0 ]

[sub_resource type="CurveTexture" id=4]
curve = SubResource( 3 )
[sub_resource type="CurveTexture" id=5]
curve = SubResource( 4 )

[sub_resource type="ParticlesMaterial" id=5]
[sub_resource type="ParticlesMaterial" id=6]
flag_disable_z = true
gravity = Vector3( 0, 0, 0 )
initial_velocity = 120.0
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale = 0.5
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
scale_curve = SubResource( 5 )
color_ramp = SubResource( 3 )

[sub_resource type="ParticlesMaterial" id=6]
[sub_resource type="ParticlesMaterial" id=7]
flag_disable_z = true
gravity = Vector3( 0, 0, 0 )
initial_velocity = 250.0
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale = 0.5
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
scale_curve = SubResource( 5 )
color_ramp = SubResource( 3 )

[sub_resource type="ParticlesMaterial" id=7]
[sub_resource type="ParticlesMaterial" id=8]
emission_shape = 2
emission_box_extents = Vector3( 20, 20, 0 )
direction = Vector3( 0, 0, 0 )
Expand All @@ -54,6 +57,7 @@ script = ExtResource( 1 )
Damage = 60

[node name="Line2D" type="Line2D" parent="."]
material = SubResource( 1 )
points = PoolVector2Array( 0, 0, 100, 0 )
width = 0.0
default_color = Color( 0.5, 3, 6, 1 )
Expand All @@ -63,17 +67,17 @@ default_color = Color( 0.5, 3, 6, 1 )
[node name="particles2DCasting" type="Particles2D" parent="."]
emitting = false
lifetime = 0.5
process_material = SubResource( 5 )
process_material = SubResource( 6 )
texture = ExtResource( 2 )

[node name="particles2DCollision" type="Particles2D" parent="."]
emitting = false
lifetime = 0.5
process_material = SubResource( 6 )
process_material = SubResource( 7 )
texture = ExtResource( 2 )

[node name="particles2DBeam" type="Particles2D" parent="."]
emitting = false
amount = 20
process_material = SubResource( 7 )
process_material = SubResource( 8 )
texture = ExtResource( 3 )
2 changes: 1 addition & 1 deletion weapons/LaserGun.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ script = ExtResource( 4 )
CurrentWeaponType = 1
KnockbackForce = 10.0
ItemResourceID = "SYC-1000"
MaxAmmo = 10
MaxAmmo = 20
CooldownTime = 0.5
ReloadTime = 5.0

Expand Down

0 comments on commit 763678b

Please sign in to comment.