Pellet collision
This commit is contained in:
@@ -120,6 +120,11 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
}
|
||||
|
||||
if (CrossesTileBorder(position, nextPosition, direction))
|
||||
{
|
||||
CheckNewTile(nextPosition);
|
||||
}
|
||||
|
||||
SetPosition(nextPosition);
|
||||
}
|
||||
|
||||
@@ -207,6 +212,20 @@ namespace Marro.PacManUdon
|
||||
return nextPosition;
|
||||
}
|
||||
|
||||
private void CheckNewTile(Vector2 position)
|
||||
{
|
||||
var pellet = pelletManager.CollectPelletAt(position);
|
||||
|
||||
if (pellet == PelletType.Pellet)
|
||||
{
|
||||
freezeSeconds = 0.0166666666666667f;
|
||||
}
|
||||
else if (pellet == PelletType.PowerPellet)
|
||||
{
|
||||
freezeSeconds = freezeSeconds = 0.05f;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateAnimator()
|
||||
{
|
||||
// Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}");
|
||||
@@ -324,22 +343,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Pellet pellet = other.gameObject.GetComponent<Pellet>();
|
||||
if (pellet)
|
||||
{
|
||||
if (pellet.isPowerPellet)
|
||||
{
|
||||
gameManager.GotPowerPellet(pellet);
|
||||
freezeSeconds = 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
gameManager.GotPellet(pellet);
|
||||
freezeSeconds = 0.0166666666666667f;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (other.gameObject.GetComponent<BonusFruit>())
|
||||
if (other.gameObject.GetComponent<BonusFruit>())
|
||||
{
|
||||
gameManager.GotFruit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user