Removed most old networking stuff
This commit is contained in:
@@ -35,7 +35,6 @@ namespace Marro.PacManUdon
|
||||
[SerializeField] private int pelletCountOverride = -1;
|
||||
|
||||
private Maze maze;
|
||||
private VRCObjectPool pelletPool;
|
||||
private Intermission2Pole intermission2Pole;
|
||||
|
||||
private Animator mazeSpriteAnimator;
|
||||
@@ -65,14 +64,13 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
|
||||
maze = mazes[0];
|
||||
pelletPool = maze.pelletContainer.GetComponent<VRCObjectPool>();
|
||||
mazeSpriteAnimator = maze.mazeSprite.GetComponent<Animator>();
|
||||
intermission2Pole = intermissionScreenElements[4].GetComponent<Intermission2Pole>();
|
||||
|
||||
ghostManager.Initialize(maze.ghostTargets, pacMan, this);
|
||||
pacMan.Initialize(playerInput, pelletPool, this);
|
||||
pacMan.Initialize(playerInput, this);
|
||||
bonusFruit.Initialize();
|
||||
pelletManager.Initialize(pelletPool);
|
||||
pelletManager.Initialize();
|
||||
statusDisplay.Initialize();
|
||||
playerInput.Initialize(this);
|
||||
soundManager.Initialize();
|
||||
@@ -114,7 +112,6 @@ namespace Marro.PacManUdon
|
||||
public void StartGameButtonPressed()
|
||||
{
|
||||
Debug.Log($"{gameObject} Start Game Button was pressed!");
|
||||
TakeOwnership();
|
||||
StartTimeSequence(PacManTimeSequence.StartNewGame);
|
||||
}
|
||||
|
||||
@@ -142,7 +139,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
Debug.Log($"{gameObject} New level started!");
|
||||
|
||||
pelletCountTotal = pelletPool.Pool.Length;
|
||||
pelletCountTotal = pelletManager.PelletCount;
|
||||
pelletCountRemaining = pelletCountTotal;
|
||||
ghostManager.SetPelletsRemaining(pelletCountRemaining);
|
||||
ghostManager.NewLevel();
|
||||
@@ -283,7 +280,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
void SetPelletsActive(bool active)
|
||||
{
|
||||
pelletPool.gameObject.SetActive(active);
|
||||
pelletManager.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
void SetMazeVisible(bool visible)
|
||||
@@ -365,20 +362,12 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void DecrementLives()
|
||||
{
|
||||
if (!Networking.IsOwner(gameObject))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Debug.Log($"{gameObject} Decremented lives from {extraLives} to {extraLives - 1}");
|
||||
SetExtraLives(extraLives - 1);
|
||||
}
|
||||
|
||||
void IncrementLives()
|
||||
{
|
||||
if (!Networking.IsOwner(gameObject))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Debug.Log($"{gameObject} Incremented lives from {extraLives} to {extraLives + 1}");
|
||||
SetExtraLives(extraLives + 1);
|
||||
}
|
||||
@@ -409,14 +398,6 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
}
|
||||
|
||||
void TakeOwnership()
|
||||
{
|
||||
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
||||
Networking.SetOwner(Networking.LocalPlayer, pacMan.gameObject);
|
||||
Networking.SetOwner(Networking.LocalPlayer, pelletPool.gameObject);
|
||||
ghostManager.SetOwner(Networking.LocalPlayer);
|
||||
}
|
||||
|
||||
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType)
|
||||
{
|
||||
data[offset++] = new byte[] { NetworkManager.Int32ToByte((int)gameState) };
|
||||
|
||||
@@ -779,7 +779,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Networking.IsOwner(gameObject) && other.gameObject.GetComponent<PacManGhostCollider>())
|
||||
if (other.gameObject.GetComponent<PacManGhostCollider>())
|
||||
{
|
||||
if (isScared)
|
||||
{
|
||||
|
||||
@@ -332,15 +332,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOwner(VRCPlayerApi player)
|
||||
{
|
||||
Networking.SetOwner(player, gameObject);
|
||||
foreach (Ghost ghost in ghosts)
|
||||
{
|
||||
Networking.SetOwner(player, ghost.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public float GetTargetSpeed(Ghost ghost, PacManGhostState ghostState, bool isScared, bool inTunnel)
|
||||
{
|
||||
if (ghostState == PacManGhostState.Returning || ghostState == PacManGhostState.Entering)
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace Marro.PacManUdon
|
||||
private Vector3 startScale;
|
||||
private Animator animator;
|
||||
new Renderer renderer;
|
||||
private VRCObjectPool pelletPool;
|
||||
private bool hideUntilUnfrozen;
|
||||
private bool dead;
|
||||
private bool kinematic;
|
||||
@@ -44,11 +43,10 @@ namespace Marro.PacManUdon
|
||||
#endregion
|
||||
|
||||
|
||||
public void Initialize(PlayerInput input, VRCObjectPool pelletPool, GameManager gameController)
|
||||
public void Initialize(PlayerInput input, GameManager gameController)
|
||||
{
|
||||
this.gameController = gameController;
|
||||
this.input = input;
|
||||
this.pelletPool = pelletPool;
|
||||
animator = GetComponent<Animator>();
|
||||
renderer = GetComponent<Renderer>();
|
||||
frozen = false;
|
||||
@@ -143,8 +141,6 @@ namespace Marro.PacManUdon
|
||||
// Debug.Log($"{gameObject} crossed Y tile center from {currentPosition} with targetDirection {targetDirection}, nextPosition is now {nextPosition} and direction is now {direction}");
|
||||
}
|
||||
|
||||
if (Networking.IsOwner(gameObject))
|
||||
{
|
||||
Vector2 inputDirection = input.GetDirection();
|
||||
if (!inputDirection.Equals(Vector2.zero) && !inputDirection.Equals(targetDirection) // Ignore neutral input or input in our current direction
|
||||
&& (inputDirection.x == 0 || (Math.Round(nextPosition.y, 5) - 0.5) % 1 != 0) && (inputDirection.y == 0 || (Math.Round(nextPosition.x, 5) - 0.5) % 1 != 0) // Target grid position near the edge of a tile may not be correct, ignore inputs near the border
|
||||
@@ -160,7 +156,6 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
SetTargetDirection(inputDirection); // This is the direction most logic should assume pacman is moving, the actual direction may be different due to cornering
|
||||
}
|
||||
}
|
||||
|
||||
return nextPosition;
|
||||
}
|
||||
@@ -324,15 +319,7 @@ namespace Marro.PacManUdon
|
||||
Pellet pellet = other.gameObject.GetComponent<Pellet>();
|
||||
if (pellet)
|
||||
{
|
||||
if (Networking.IsOwner(gameObject))
|
||||
{
|
||||
pelletPool.Return(pellet.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
pellet.pelletRenderer.enabled = false;
|
||||
pellet.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (pellet.isPowerPellet)
|
||||
{
|
||||
@@ -346,7 +333,7 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (Networking.IsOwner(gameObject) && other.gameObject.GetComponent<BonusFruit>())
|
||||
else if (other.gameObject.GetComponent<BonusFruit>())
|
||||
{
|
||||
gameController.GotFruit();
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Renderer))]
|
||||
public class Pellet : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] public bool isPowerPellet = false;
|
||||
public bool isPowerPellet = false;
|
||||
public Renderer pelletRenderer;
|
||||
|
||||
void Start()
|
||||
|
||||
@@ -1,42 +1,24 @@
|
||||
namespace Marro.PacManUdon
|
||||
{
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Components;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Marro.PacManUdon
|
||||
{
|
||||
public class PelletManager : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] Pellet[] pellets;
|
||||
VRCObjectPool pelletPool;
|
||||
Pellet[] pellets;
|
||||
Renderer[] pelletRenderers;
|
||||
Animator[] powerPellets;
|
||||
|
||||
|
||||
bool powerPelletBlinkEnabled;
|
||||
float powerPelletBlinkToggleInterval;
|
||||
float powerPelletBlinkProgress;
|
||||
bool powerPelletBlinkCurrentlyVisible;
|
||||
|
||||
public void Initialize(VRCObjectPool pelletPool)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
this.pelletPool = pelletPool;
|
||||
pelletRenderers = new Renderer[pelletPool.Pool.Length];
|
||||
for (int i = 0; i < pelletRenderers.Length; i++)
|
||||
{
|
||||
pelletRenderers[i] = pelletPool.Pool[i].GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
powerPellets = GetComponentsInChildren<Animator>(true);
|
||||
// Debug.Log($"{gameObject} Initialized, powerPellets: {powerPellets}");
|
||||
powerPelletBlinkToggleInterval = PacManConstants.GetPowerPelletBlinkToggleInterval();
|
||||
SetPowerPelletsBlink(false);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
pellets = GetComponentsInChildren<Pellet>(includeInactive: true);
|
||||
|
||||
pelletRenderers = new Renderer[pellets.Length];
|
||||
for (int i = 0; i < pelletRenderers.Length; i++)
|
||||
{
|
||||
@@ -91,12 +73,9 @@
|
||||
|
||||
public void RestoreAllPellets()
|
||||
{
|
||||
foreach (GameObject pellet in pelletPool.Pool)
|
||||
foreach (var pellet in pellets)
|
||||
{
|
||||
if (pelletPool.TryToSpawn() == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
pellet.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
foreach (Renderer pelletRenderer in pelletRenderers)
|
||||
@@ -104,5 +83,7 @@
|
||||
pelletRenderer.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int PelletCount => pellets.Length;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
private void TimeSequencePrepareForFinish(PacManTimeSequence timeSequence)
|
||||
{
|
||||
if (Networking.IsOwner(gameObject))
|
||||
if (networkManager.IsOwner)
|
||||
{
|
||||
TimeSequenceExecuteFinalize(timeSequence);
|
||||
if (!jumpingToTimeSequence)
|
||||
|
||||
Reference in New Issue
Block a user