Ghost - PacMan collision detection
This commit is contained in:
@@ -197,15 +197,10 @@ namespace Marro.PacManUdon
|
||||
TryToTurn(position, ref nextPosition);
|
||||
}
|
||||
|
||||
var distance = Vector2.Distance(position, nextPosition);
|
||||
if (distance > 0.5f)
|
||||
{
|
||||
Debug.LogError($"{gameObject} Just jumped by distance {distance}! position: {position}, nextPosition: {nextPosition}, direction: {direction}, offGrid: {offGrid}, ghostState: {ghostState}");
|
||||
}
|
||||
|
||||
if (CrossesTileBorder(position, nextPosition, direction))
|
||||
{
|
||||
var inTunnel = pelletManager.IsInTunnel(nextPosition);
|
||||
var inTunnel = pelletManager.GhostMoveToTile(nextPosition, Index);
|
||||
|
||||
if (inTunnel != this.inTunnel)
|
||||
{
|
||||
this.inTunnel = inTunnel;
|
||||
@@ -595,6 +590,20 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
}
|
||||
|
||||
internal void HitPacMan()
|
||||
{
|
||||
if (isScared)
|
||||
{
|
||||
Debug.Log($"{gameObject} was cought!");
|
||||
ghostManager.GhostCaughtQueue(this);
|
||||
}
|
||||
else if (ghostState == PacManGhostState.Normal)
|
||||
{
|
||||
Debug.Log($"{gameObject} cought PacMan!");
|
||||
ghostManager.CapturedPacMan();
|
||||
}
|
||||
}
|
||||
|
||||
public void Caught(int scoreBonus)
|
||||
{
|
||||
isScared = false;
|
||||
@@ -844,22 +853,5 @@ namespace Marro.PacManUdon
|
||||
|
||||
return base.WriteSyncedData(data, ref index, eventType);
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.GetComponent<PacManGhostCollider>())
|
||||
{
|
||||
if (isScared)
|
||||
{
|
||||
// Debug.Log($"{gameObject} was cought!");
|
||||
ghostManager.GhostCaughtQueue(this);
|
||||
}
|
||||
else if (ghostState == PacManGhostState.Normal)
|
||||
{
|
||||
// Debug.Log($"{gameObject} cought PacMan!");
|
||||
ghostManager.CapturedPacMan();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user