Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Multiplayer-arena-game
/
Multiplayer-arena-game-GameObjects
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9573686b
authored
Jan 19, 2025
by
alsunj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary calls
parent
f89e3fc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
39 deletions
Assets/_Game/Code/Destructable/Barrel.cs
Assets/_Game/Code/Destructable/Barrel.cs
View file @
9573686b
...
...
@@ -14,27 +14,6 @@ public class Barrel : NetworkBehaviour, IDestrucable
{
_health
.
Value
=
_destructableSettings
.
health
;
}
_health
.
OnValueChanged
+=
OnHealthChanged
;
}
public
override
void
OnDestroy
()
{
_health
.
OnValueChanged
-=
OnHealthChanged
;
}
private
void
OnHealthChanged
(
float
oldHealth
,
float
newHealth
)
{
if
(
newHealth
<=
0
)
{
transform
.
DOScale
(
Vector3
.
zero
,
0.5f
).
SetDelay
(
_destructableSettings
.
hitDelay
)
.
OnComplete
(()
=>
gameObject
.
SetActive
(
false
));
}
else
{
transform
.
DOShakePosition
(
0.5f
,
_destructableSettings
.
shakeOffset
,
10
,
90
,
false
,
true
)
.
SetDelay
(
_destructableSettings
.
hitDelay
);
}
}
[
ClientRpc
]
...
...
@@ -60,28 +39,13 @@ public class Barrel : NetworkBehaviour, IDestrucable
private
void
RequestTakeDamageServerRpc
(
float
damage
)
{
_health
.
Value
-=
damage
;
Debug
.
Log
(
_health
.
Value
);
Debug
.
Log
(
"health value at checking: "
+
_health
.
Value
);
if
(
_health
.
Value
<=
0
)
{
CmdShowBarrelDestroyForEveryOneServer
Rpc
();
RpcShowBarrelDestroyForEveryOneClient
Rpc
();
}
else
{
CmdShowBarrelDamageForEveryoneServer
Rpc
();
RpcShowBarrelDamageForEveryoneClient
Rpc
();
}
}
[
ServerRpc
(
RequireOwnership
=
false
)]
private
void
CmdShowBarrelDestroyForEveryOneServerRpc
()
{
RpcShowBarrelDestroyForEveryOneClientRpc
();
}
[
ServerRpc
(
RequireOwnership
=
false
)]
private
void
CmdShowBarrelDamageForEveryoneServerRpc
()
{
RpcShowBarrelDamageForEveryoneClientRpc
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment