Files
PacManUdon/Assets/Scripts/PacManConstants.cs
2026-06-15 17:21:16 +02:00

411 lines
20 KiB
C#

namespace Marro.PacManUdon
{
using UnityEngine;
using VRC.Udon;
public enum PacManFruitType
{
None = -1,
Cherries = 0,
Strawberry = 1,
Peach = 2,
Apple = 3,
Grapes = 4,
Galaxian = 5,
Bell = 6,
Key = 7
}
public enum PacManGameState
{
AttractMode,
AttractModeDemo,
WaitForStart,
InGame,
}
public enum PacManGhostFrozenState
{
Frozen,
FrozenIfNotCaught,
NotFrozen
}
public enum PacManTimeSequence
{
AttractScreenIntroduction,
AttractScreenDemo,
AttractScreenWaitToRestart,
WaitForStart,
WaitForStartTimeout,
StartNewGame,
BoardClear,
StartNewLevel,
GhostCaught,
PacManCaught,
RestartLevel,
GameOver,
Intermission1,
Intermission2,
Intermission3
}
public enum PacManCollisionType
{
Empty = -1,
Wall = -2,
}
public enum PacManConsumableType
{
None = -1,
FruitLeft = -2,
FruitRight = -3,
}
public static class PacManConstants
{
// Jagged or 2D arrays can't be static so we work with 1D arrays
public static int[] GetMazeCollisionInfo() => new int[]
{
-02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02,
-02, 009, -01, -01, -01, -01, 013, -01, -01, -01, -01, -01, 005, -02, -02, 009, -01, -01, -01, -01, -01, 013, -01, -01, -01, -01, 005, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, -01, -02, -01, -01, -02, -01, -02, -01, -01, -01, -02, -01, -02, -02, -01, -02, -01, -01, -01, -02, -01, -02, -01, -01, -02, -01, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, 011, -01, -01, -01, -01, 015, -01, -01, 013, -01, -01, 014, -01, -01, 014, -01, -01, 013, -01, -01, 015, -01, -01, -01, -01, 007, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, 010, -01, -01, -01, -01, 007, -02, -02, 010, -01, -01, 005, -02, -02, 009, -01, -01, 006, -02, -02, 011, -01, -01, -01, -01, 006, -02,
-02, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -02,
013, 013, 013, 013, 005, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, 009, 013, 013, 013, 013,
015, 015, 015, 015, 007, -02, -01, -02, -02, 009, -01, -01, 014, -01, -01, 014, -01, -01, 005, -02, -02, -01, -02, 011, 015, 015, 015, 015,
014, 014, 014, 014, 006, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, 010, 014, 014, 014, 014,
-02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, 009, 013, 013, 013, 013, 005, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02,
-01, -01, -01, -01, -01, -01, 015, -01, -01, 007, -02, 011, 015, 015, 015, 015, 007, -02, 011, -01, -01, 015, -01, -01, -01, -01, -01, -01,
-02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, 010, 014, 014, 014, 014, 006, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02,
013, 013, 013, 013, 005, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, 009, 013, 013, 013, 013,
015, 015, 015, 015, 007, -02, -01, -02, -02, 011, -01, -01, -01, -01, -01, -01, -01, -01, 007, -02, -02, -01, -02, 011, 015, 015, 015, 015,
014, 014, 014, 014, 006, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, 010, 014, 014, 014, 014,
-02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02,
-02, 009, -01, -01, -01, -01, 015, -01, -01, 014, -01, -01, 005, -02, -02, 009, -01, -01, 014, -01, -01, 015, -01, -01, -01, -01, 005, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, -01, -02, -02, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -01, -02, -02, -02, -02, -01, -02,
-02, 010, -01, 005, -02, -02, 011, -01, -01, 013, -01, -01, 014, -01, -01, 014, -01, -01, 013, -01, -01, 007, -02, -02, 009, -01, 006, -02,
-02, -02, -02, -01, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -01, -02, -02, -02,
-02, -02, -02, -01, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -01, -02, -02, -02,
-02, 009, -01, 014, -01, -01, 006, -02, -02, 010, -01, -01, 005, -02, -02, 009, -01, -01, 006, -02, -02, 010, -01, -01, 014, -01, 005, -02,
-02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02,
-02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02, -02, -01, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -01, -02,
-02, 010, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 014, -01, -01, 014, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 006, -02,
-02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02, -02,
};
public static int[] GetMazePelletMap() => new int[]
{
-01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01,
-01, 215, 214, 213, 212, 211, 195, 194, 193, 192, 191, 190, 189, -01, -01, 177, 178, 179, 180, 181, 182, 151, 150, 149, 148, 147, 146, -01,
-01, 216, -01, -01, -01, -01, 196, -01, -01, -01, -01, -01, 188, -01, -01, 176, -01, -01, -01, -01, -01, 152, -01, -01, -01, -01, 145, -01,
-01, 003, -01, -01, -01, -01, 197, -01, -01, -01, -01, -01, 187, -01, -01, 175, -01, -01, -01, -01, -01, 153, -01, -01, -01, -01, 002, -01,
-01, 217, -01, -01, -01, -01, 198, -01, -01, -01, -01, -01, 186, -01, -01, 174, -01, -01, -01, -01, -01, 154, -01, -01, -01, -01, 144, -01,
-01, 218, 219, 220, 221, 222, 199, 200, 201, 202, 203, 204, 185, 184, 183, 173, 172, 171, 164, 163, 162, 155, 156, 157, 158, 159, 143, -01,
-01, 223, -01, -01, -01, -01, 230, -01, -01, 205, -01, -01, -01, -01, -01, -01, -01, -01, 165, -01, -01, 160, -01, -01, -01, -01, 142, -01,
-01, 224, -01, -01, -01, -01, 231, -01, -01, 206, -01, -01, -01, -01, -01, -01, -01, -01, 166, -01, -01, 161, -01, -01, -01, -01, 141, -01,
-01, 225, 226, 227, 228, 229, 232, -01, -01, 207, 208, 209, 210, -01, -01, 170, 169, 168, 167, -01, -01, 135, 136, 137, 138, 139, 140, -01,
-01, -01, -01, -01, -01, -01, 233, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 134, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 234, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 133, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 235, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 132, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 236, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 131, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 237, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 130, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 238, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 129, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 239, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 128, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 240, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 127, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 241, -01, -01, -01, -01, -01, -01, -02, -03, -01, -01, -01, -01, -01, -01, 126, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 242, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 125, -01, -01, -01, -01, -01, -01,
-01, -01, -01, -01, -01, -01, 243, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 124, -01, -01, -01, -01, -01, -01,
-01, 086, 087, 088, 089, 090, 091, 094, 095, 096, 097, 098, 099, -01, -01, 104, 105, 106, 107, 108, 109, 110, 123, 122, 121, 120, 119, -01,
-01, 085, -01, -01, -01, -01, 092, -01, -01, -01, -01, -01, 100, -01, -01, 103, -01, -01, -01, -01, -01, 111, -01, -01, -01, -01, 118, -01,
-01, 084, -01, -01, -01, -01, 093, -01, -01, -01, -01, -01, 101, -01, -01, 102, -01, -01, -01, -01, -01, 112, -01, -01, -01, -01, 117, -01,
-01, 000, 083, 082, -01, -01, 010, 009, 008, 007, 006, 005, 004, -01, -01, 063, 062, 061, 060, 059, 058, 057, -01, -01, 115, 116, 001, -01,
-01, -01, -01, 081, -01, -01, 011, -01, -01, 079, -01, -01, -01, -01, -01, -01, -01, -01, 064, -01, -01, 056, -01, -01, 114, -01, -01, -01,
-01, -01, -01, 080, -01, -01, 012, -01, -01, 078, -01, -01, -01, -01, -01, -01, -01, -01, 065, -01, -01, 055, -01, -01, 113, -01, -01, -01,
-01, 018, 017, 016, 015, 014, 013, -01, -01, 077, 076, 075, 074, -01, -01, 069, 068, 067, 066, -01, -01, 054, 053, 052, 051, 050, 049, -01,
-01, 019, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 073, -01, -01, 070, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 048, -01,
-01, 020, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 072, -01, -01, 071, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, 047, -01,
-01, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, -01,
-01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01, -01,
};
public static int[] GetMazePelletIndices() => new int[]
{
645, 670, 110, 085, 656, 655, 654, 653, 652, 651, 650, 678, 706, 734, 733, 732,
731, 730, 729, 757, 785, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823,
824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 810,
782, 754, 753, 752, 751, 750, 749, 721, 693, 665, 664, 663, 662, 661, 660, 659,
690, 718, 746, 745, 744, 743, 771, 799, 796, 768, 740, 739, 738, 737, 709, 681,
703, 675, 647, 646, 617, 589, 561, 562, 563, 564, 565, 566, 594, 622, 567, 568,
569, 570, 571, 572, 600, 628, 631, 603, 575, 576, 577, 578, 579, 580, 581, 609,
637, 724, 696, 668, 669, 642, 614, 586, 585, 584, 583, 582, 553, 525, 497, 469,
441, 413, 385, 357, 329, 301, 273, 245, 246, 247, 248, 249, 250, 222, 194, 166,
138, 082, 054, 053, 052, 051, 050, 049, 077, 105, 133, 161, 162, 163, 164, 165,
189, 217, 160, 159, 158, 186, 214, 242, 241, 240, 239, 157, 156, 155, 127, 099,
071, 043, 044, 045, 046, 047, 048, 154, 153, 152, 124, 096, 068, 040, 039, 038,
037, 036, 035, 034, 062, 090, 118, 146, 147, 148, 149, 150, 151, 177, 205, 233,
234, 235, 236, 033, 032, 031, 030, 029, 057, 113, 141, 142, 143, 144, 145, 169,
197, 225, 226, 227, 228, 229, 174, 202, 230, 258, 286, 314, 342, 370, 398, 426,
454, 482, 510, 538,
};
public static GameObject[] ComponentsToGameObjects(Component[] components, bool skipFirstComponent = false)
{
if (skipFirstComponent)
{
GameObject[] gameObjects = new GameObject[components.Length - 1];
for (int i = 0; i < components.Length - 1; i++)
{
gameObjects[i] = components[i + 1].gameObject;
}
return gameObjects;
}
else
{
GameObject[] gameObjects = new GameObject[components.Length];
for (int i = 0; i < components.Length; i++)
{
gameObjects[i] = components[i].gameObject;
}
return gameObjects;
}
}
public static float GetPowerPelletBlinkToggleInterval()
{
return 0.1666666666f;
}
public static PacManFruitType GetFruitTypeForLevel(int level)
{
PacManFruitType[] FruitTypePerLevel = new PacManFruitType[]
{
PacManFruitType.Cherries,
PacManFruitType.Strawberry,
PacManFruitType.Peach,
PacManFruitType.Peach,
PacManFruitType.Apple,
PacManFruitType.Apple,
PacManFruitType.Grapes,
PacManFruitType.Grapes,
PacManFruitType.Galaxian,
PacManFruitType.Galaxian,
PacManFruitType.Bell,
PacManFruitType.Bell,
PacManFruitType.Key
};
if (level - 1 < 0)
{
return PacManFruitType.None;
}
if (level - 1 >= FruitTypePerLevel.Length)
{
return FruitTypePerLevel[FruitTypePerLevel.Length - 1];
}
return FruitTypePerLevel[level - 1];
}
public static float GetGhostHomeSpeed()
{
return 3.5f;
}
public static float GetPacManDefaultSpeedForLevel(int level)
{
if (level <= 1) return 7.576f;
if (level <= 4) return 8.523f;
if (level <= 20) return 9.470f;
return 8.523f;
}
public static float GetPacManPowerPelletSpeedForLevel(int level)
{
if (level <= 1) return 8.523f;
if (level <= 4) return 8.996f;
return 9.470f;
}
public static float GetGhostDefaultSpeedForLevel(int level)
{
if (level <= 1) return 7.102f;
if (level <= 4) return 8.049f;
return 8.996f;
}
public static float GetGhostTunnelSpeedForLevel(int level)
{
if (level <= 1) return 3.788f;
if (level <= 4) return 4.261f;
return 4.735f;
}
public static float GetBlinkyElroy1SpeedForLevel(int level)
{
if (level <= 1) return 7.576f;
if (level <= 4) return 8.523f;
return 9.470f;
}
public static float GetBlinkyElroy2SpeedForLevel(int level)
{
if (level <= 1) return 8.049f;
if (level <= 4) return 8.996f;
return 9.943f;
}
public static float GetGhostScaredSpeedForLevel(int level)
{
if (level <= 1) return 4.735f;
if (level <= 4) return 5.208f;
return 5.682f;
}
public static int GetElroy1PelletsRemainingForLevel(int level)
{
if (level <= 1) return 20;
if (level <= 2) return 30;
if (level <= 5) return 40;
if (level <= 8) return 50;
if (level <= 11) return 60;
if (level <= 14) return 80;
if (level <= 18) return 100;
return 120;
}
public static int GetElroy2PelletsRemainingForLevel(int level)
{
if (level <= 1) return 10;
if (level <= 2) return 15;
if (level <= 5) return 20;
if (level <= 8) return 25;
if (level <= 11) return 30;
if (level <= 14) return 40;
if (level <= 18) return 50;
return 60;
}
public static float GetGhostHousePelletTimeoutLimitForLevel(int level)
{
if (level <= 4) return 4;
return 3;
}
public static int[] GetGhostHousePrivatePelletCounterLimitForLevel(int level)
{
if (level <= 1) return new int[] { 0, 0, 30, 60 };
if (level <= 2) return new int[] { 0, 0, 0, 50 };
return new int[] { 0, 0, 0, 0 };
}
public static float[] GetScatterPatternForLevel(int level)
{
if (level <= 1) return new float[] { 7, 27, 34, 54, 59, 79, 84 };
if (level <= 4) return new float[] { 7, 27, 34, 54, 59, 1092, 1092.0166667f };
return new float[] { 5, 25, 30, 50, 55, 1092, 1092.0166667f };
}
public static float GetScaredDurationForLevel(int level)
{
float[] scaredDurationPerLevel =
{
6,
5,
4,
3,
2,
5,
2,
2,
1,
5,
2,
1,
1,
3,
1,
1,
0,
1,
0
};
if (level - 1 < 0)
{
return scaredDurationPerLevel[0];
}
if (level - 1 >= scaredDurationPerLevel.Length)
{
return scaredDurationPerLevel[scaredDurationPerLevel.Length - 1];
}
return scaredDurationPerLevel[level - 1];
}
public static float GetScaredNumberOfFlashesForLevel(int level)
{
int[] scaredNumberOfFlashesPerLevel = new int[]
{
5,
5,
5,
5,
5,
5,
5,
5,
3,
5,
5,
3,
3,
5,
3,
3,
0,
3,
0
};
if (level - 1 < 0)
{
return scaredNumberOfFlashesPerLevel[0];
}
if (level - 1 >= scaredNumberOfFlashesPerLevel.Length)
{
return scaredNumberOfFlashesPerLevel[scaredNumberOfFlashesPerLevel.Length - 1];
}
return scaredNumberOfFlashesPerLevel[level - 1];
}
public static int FruitTypeToValue(PacManFruitType fruitType)
{ // I can't get casting from enum to int to work so this is a workaround
switch (fruitType)
{
default:
case PacManFruitType.None:
return -1;
case PacManFruitType.Cherries:
return 0;
case PacManFruitType.Strawberry:
return 1;
case PacManFruitType.Peach:
return 2;
case PacManFruitType.Apple:
return 3;
case PacManFruitType.Grapes:
return 4;
case PacManFruitType.Galaxian:
return 5;
case PacManFruitType.Bell:
return 6;
case PacManFruitType.Key:
return 7;
}
}
}
}