Skip to content

Commit 3c42407

Browse files
renaming action itself and adding knockback to the explosion
1 parent 212fb70 commit 3c42407

11 files changed

+26
-12
lines changed

Assets/BossRoom/Prefabs/Game/ImpBomb.prefab renamed to Assets/BossRoom/Prefabs/Game/ImpTossAttack.prefab

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ GameObject:
9999
- component: {fileID: 6687170048049847228}
100100
- component: {fileID: 5792943200133235216}
101101
m_Layer: 0
102-
m_Name: ImpBomb
102+
m_Name: ImpTossAttack
103103
m_TagString: Untagged
104104
m_Icon: {fileID: 0}
105105
m_NavMeshLayer: 0
@@ -206,6 +206,8 @@ MonoBehaviour:
206206
m_EditorClassIdentifier:
207207
m_DamagePoints: 1
208208
m_HitRadius: 5
209+
m_KnockbackSpeed: 4.2
210+
m_KnockbackDuration: 0.4
209211
m_LayerMask:
210212
serializedVersion: 2
211213
m_Bits: 72

Assets/BossRoom/Prefabs/Game/ImpBombGraphics.prefab renamed to Assets/BossRoom/Prefabs/Game/ImpTossAttackGraphics.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GameObject:
1313
- component: {fileID: 6578595960882027409}
1414
- component: {fileID: 6074465214437177532}
1515
m_Layer: 0
16-
m_Name: ImpBombGraphics
16+
m_Name: ImpTossAttackGraphics
1717
m_TagString: Untagged
1818
m_Icon: {fileID: 0}
1919
m_NavMeshLayer: 0

Assets/BossRoom/Scripts/Game/Client/Game/ClientBombDisplay.cs renamed to Assets/BossRoom/Scripts/Game/Client/Game/ClientTossAttackDisplay.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Unity.Multiplayer.Samples.BossRoom.Client
66
{
7-
public class ClientBombDisplay : NetworkBehaviour
7+
public class ClientTossAttackDisplay : NetworkBehaviour
88
{
99
[SerializeField]
1010
Transform m_BombDisplayTransform;
@@ -36,9 +36,9 @@ public override void OnNetworkDespawn()
3636

3737
void LateUpdate()
3838
{
39-
var bombPosition = transform.position;
39+
var tossedItemPosition = transform.position;
4040
m_BombDisplayTransform.SetPositionAndRotation(
41-
new Vector3(bombPosition.x, k_DisplayHeight, bombPosition.z),
41+
new Vector3(tossedItemPosition.x, k_DisplayHeight, tossedItemPosition.z),
4242
k_BombDisplayRotation);
4343
}
4444
}

Assets/BossRoom/Scripts/Game/Server/Action/Action.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static Action MakeAction(ServerCharacter parent, ref ActionRequestData da
174174
case ActionLogic.ChargedLaunchProjectile: return new ChargedLaunchProjectileAction(parent, ref data);
175175
case ActionLogic.StealthMode: return new StealthModeAction(parent, ref data);
176176
case ActionLogic.DashAttack: return new DashAttackAction(parent, ref data);
177-
case ActionLogic.ImpToss: return new ItemTossAction(parent, ref data);
177+
case ActionLogic.ImpToss: return new TossAction(parent, ref data);
178178
default: throw new System.NotImplementedException();
179179
}
180180
}

Assets/BossRoom/Scripts/Game/Server/Action/ItemTossAction.cs renamed to Assets/BossRoom/Scripts/Game/Server/Action/TossAction.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace Unity.Multiplayer.Samples.BossRoom.Server
77
/// <summary>
88
/// Action responsible for creating a projectile object.
99
/// </summary>
10-
public class ItemTossAction : Action
10+
public class TossAction : Action
1111
{
1212
bool m_Launched;
1313

14-
public ItemTossAction(ServerCharacter parent, ref ActionRequestData data) : base(parent, ref data) { }
14+
public TossAction(ServerCharacter parent, ref ActionRequestData data) : base(parent, ref data) { }
1515

1616
public override bool Start()
1717
{
@@ -98,10 +98,10 @@ void Throw()
9898

9999
// important to add a force AFTER a NetworkObject is spawned, since IsKinematic is enabled on the
100100
// Rigidbody component after it is spawned
101-
var bombRigidbody = no.GetComponent<Rigidbody>();
101+
var tossedItemRigidbody = no.GetComponent<Rigidbody>();
102102

103-
bombRigidbody.AddForce((networkObjectTransform.forward * 80f) + (networkObjectTransform.up * 150f), ForceMode.Impulse);
104-
bombRigidbody.AddTorque((networkObjectTransform.forward * Random.Range(-15f, 15f)) + (networkObjectTransform.up * Random.Range(-15f, 15f)), ForceMode.Impulse);
103+
tossedItemRigidbody.AddForce((networkObjectTransform.forward * 80f) + (networkObjectTransform.up * 150f), ForceMode.Impulse);
104+
tossedItemRigidbody.AddTorque((networkObjectTransform.forward * Random.Range(-15f, 15f)) + (networkObjectTransform.up * Random.Range(-15f, 15f)), ForceMode.Impulse);
105105
}
106106
}
107107
}

Assets/BossRoom/Scripts/Game/Server/Entity/ServerItemThrow.cs renamed to Assets/BossRoom/Scripts/Game/Server/Entity/ServerTossAttack.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33

44
namespace Unity.Multiplayer.Samples.BossRoom.Server
55
{
6-
public class ServerItemThrow : NetworkBehaviour
6+
public class ServerTossAttack : NetworkBehaviour
77
{
88
[SerializeField]
99
int m_DamagePoints;
1010

1111
[SerializeField]
1212
float m_HitRadius = 5f;
1313

14+
[SerializeField]
15+
float m_KnockbackSpeed;
16+
17+
[SerializeField]
18+
float m_KnockbackDuration;
19+
1420
[SerializeField]
1521
LayerMask m_LayerMask;
1622

@@ -57,6 +63,12 @@ void Detonate()
5763
if (m_CollisionCache[i].gameObject.TryGetComponent(out IDamageable damageReceiver))
5864
{
5965
damageReceiver.ReceiveHP(null, -m_DamagePoints);
66+
67+
var serverCharacter = m_CollisionCache[i].gameObject.GetComponentInParent<ServerCharacter>();
68+
if (serverCharacter)
69+
{
70+
serverCharacter.Movement.StartKnockback(transform.position, m_KnockbackSpeed, m_KnockbackDuration);
71+
}
6072
}
6173
}
6274

0 commit comments

Comments
 (0)