Bonus fruit hitbox

This commit is contained in:
2026-06-15 17:21:16 +02:00
parent c601dda10a
commit a24f237bd5
11 changed files with 439 additions and 294 deletions

View File

@@ -2,11 +2,15 @@
using Marro.PacManUdon;
using UdonSharp;
using UnityEngine;
using UnityEngine.UIElements;
using VRC.SDKBase;
using VRC.Udon;
public class MazeDefinitionGenerator : UdonSharpBehaviour
{
public BonusFruit bonusFruit;
public PelletManager pelletManager;
void Start()
{
PrintPelletMap();
@@ -18,7 +22,7 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
var width = 28;
var height = 31;
var pellets = GetComponentsInChildren<Pellet>(includeInactive: true);
var pellets = pelletManager.gameObject.GetComponentsInChildren<Pellet>(includeInactive: true);
int[] map = new int[width * height];
int[] pelletLocations = new int[pellets.Length];
@@ -37,10 +41,21 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
pelletLocations[i] = index;
}
WriteBonusFruitTiles(map);
PrintMap(map, width);
PrintMap(pelletLocations, 16);
}
private void WriteBonusFruitTiles(int[] map)
{
var position = bonusFruit.transform.localPosition;
var leftTileIndex = PelletManager.GetTilemapIndex(new Vector2(position.x - 0.5f, position.y));
map[leftTileIndex] = (int)PacManConsumableType.FruitLeft;
var rightTileIndex = PelletManager.GetTilemapIndex(new Vector2(position.x + 0.5f, position.y));
map[rightTileIndex] = (int)PacManConsumableType.FruitRight;
}
private void PrintMazeMap()
{
var width = 28;
@@ -53,7 +68,7 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
{
if (collisionMap[i])
{
map[i] = (int)PacManTileType.Wall;
map[i] = (int)PacManCollisionType.Wall;
continue;
}
@@ -90,12 +105,12 @@ public class MazeDefinitionGenerator : UdonSharpBehaviour
if (totalAvailableDirections < 2)
{
return (int)PacManTileType.Empty;
return (int)PacManCollisionType.Empty;
}
if (availableDirections == 0b0011 || availableDirections == 0b1100)
{
return (int)PacManTileType.Empty;
return (int)PacManCollisionType.Empty;
}
return availableDirections;