mirror of
https://github.com/Kaveinator/NetickProForUnity.git
synced 2025-10-27 02:09:06 -07:00
Read the description for detailed changes.
- Added `Sandbox.Players`: a synchronized list of `NetworkPlayerId` structs representing connected players. - Added `Sandbox.Events.OnPlayerJoined` and `Sandbox.Events.OnPlayerLeft` callbacks, synchronized across all clients. - Changed internal interpolation of quaternions to use `Slerp` instead of `Lerp`. - Fixed a potential crash caused by undefined behavior when reaching `NetickConfig.MaxPlayers` and destroying network objects. - Fixed an issue where sandbox-loaded scenes were not being unloaded during shutdown. - Fixed a bug preventing Prediction Error Correction from functioning correctly.
This commit is contained in:
@@ -4,44 +4,44 @@ using Netick.Unity;
|
||||
|
||||
namespace Netick.Samples.Bomberman
|
||||
{
|
||||
public enum PowerUpType
|
||||
public enum PowerUpType
|
||||
{
|
||||
Speed,
|
||||
IncreaseBombs
|
||||
}
|
||||
|
||||
public class PowerUp : NetworkBehaviour
|
||||
{
|
||||
public float PowerUpTime = 35;
|
||||
private Material _mat;
|
||||
|
||||
// Networked Properties
|
||||
[Networked]
|
||||
public PowerUpType Type { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Speed,
|
||||
IncreaseBombs
|
||||
_mat = GetComponentInChildren<Renderer>().material;
|
||||
}
|
||||
|
||||
public class PowerUp : NetworkBehaviour
|
||||
public override void NetworkRender()
|
||||
{
|
||||
public float PowerUpTime = 35;
|
||||
private Material _mat;
|
||||
|
||||
// Networked Properties
|
||||
[Networked]
|
||||
public PowerUpType Type { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_mat = GetComponentInChildren<Renderer>().material;
|
||||
}
|
||||
|
||||
public override void NetworkRender()
|
||||
{
|
||||
var color = Type == PowerUpType.IncreaseBombs ? Color.green : Color.blue;
|
||||
_mat.color = Color.Lerp(color, color * 0.5f, Mathf.InverseLerp(-1f, 1f, Mathf.Sin(15f * Time.time)));
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Sandbox == null)
|
||||
return;
|
||||
|
||||
var player = other.gameObject.GetComponent<BombermanController>();
|
||||
|
||||
if (Sandbox.IsServer && player != null)
|
||||
{
|
||||
player.ReceivePowerUp(Type, PowerUpTime);
|
||||
Sandbox.Destroy(Object);
|
||||
}
|
||||
}
|
||||
var color = Type == PowerUpType.IncreaseBombs ? Color.green : Color.blue;
|
||||
_mat.color = Color.Lerp(color, color * 0.5f, Mathf.InverseLerp(-1f, 1f, Mathf.Sin(15f * Time.time)));
|
||||
}
|
||||
|
||||
public void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Sandbox == null)
|
||||
return;
|
||||
|
||||
var player = other.gameObject.GetComponent<BombermanController>();
|
||||
|
||||
if (Sandbox.IsServer && player != null)
|
||||
{
|
||||
player.ReceivePowerUp(Type, PowerUpTime);
|
||||
Sandbox.Destroy(Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user