This commit is contained in:
djkellerman
2025-02-28 13:51:22 -05:00
3 changed files with 223 additions and 44 deletions

View File

@@ -346,7 +346,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &804358385
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@@ -3,7 +3,27 @@ using UnityEngine;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
private void Start()
{
StartGame();
}
public void StartGame()
{
if (gameMode == GameMode.freeForAll)
{
StartFreeForAll();
}
if (gameMode == GameMode.keepAway)
{
StartKeepAway();
}
if (gameMode == GameMode.obstacleCourse)
{
StartObstacleCourse();
}
}
public enum GameMode
{
freeForAll,
@@ -12,63 +32,33 @@ public class GameManager : MonoBehaviour
}
public static GameMode gameMode = GameMode.freeForAll;
public static string map = "Platformer With Headroom";
public static string map = "Platformer With Headroom"; //is called for in playermanager but should probably be removed.
public static List<GameObject> players = new List<GameObject>();
public Vector2 spawnPosition;
private Dictionary<GameObject, int> playerLives = new Dictionary<GameObject, int>();
public int maxLives = 3;
private void Start()
{
StartGame();
}
public void StartGame()
private void StartFreeForAll()
{
foreach (GameObject player in players)
{
if (gameMode == GameMode.freeForAll)
{
playerLives[player] = maxLives;
}
else
{
playerLives[player] = 1;
}
player.transform.position = spawnPosition;
}
}
public void PlayerDied(GameObject player)
private void StartKeepAway()
{
if (gameMode == GameMode.freeForAll)
foreach (GameObject player in players)
{
playerLives[player]--;
if (playerLives[player] <= 0)
{
GameOver(player);
}
else
{
RespawnPlayer(player);
}
player.transform.position = spawnPosition;
}
}
private void RespawnPlayer(GameObject player)
private void StartObstacleCourse()
{
RespawnOnTriggerEnter respawnScript = player.GetComponent<RespawnOnTriggerEnter>();
if (respawnScript != null)
foreach (GameObject player in players)
{
player.transform.position = respawnScript.spawnPoint;
player.GetComponent<Damageable>().ResetDamage();
player.transform.position = spawnPosition;
}
}
private void GameOver(GameObject player)
{
// Disable player controls and show game over screen
player.SetActive(false);
}
}

View File

@@ -295,7 +295,196 @@ PlayerSettings:
m_Width: 128
m_Height: 128
m_Kind: 0
m_BuildTargetPlatformIcons: []
m_BuildTargetPlatformIcons:
- m_BuildTarget: iPhone
m_Icons:
- m_Textures: []
m_Width: 180
m_Height: 180
m_Kind: 0
m_SubKind: iPhone
- m_Textures: []
m_Width: 120
m_Height: 120
m_Kind: 0
m_SubKind: iPhone
- m_Textures: []
m_Width: 167
m_Height: 167
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 152
m_Height: 152
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 76
m_Height: 76
m_Kind: 0
m_SubKind: iPad
- m_Textures: []
m_Width: 120
m_Height: 120
m_Kind: 3
m_SubKind: iPhone
- m_Textures: []
m_Width: 80
m_Height: 80
m_Kind: 3
m_SubKind: iPhone
- m_Textures: []
m_Width: 80
m_Height: 80
m_Kind: 3
m_SubKind: iPad
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 3
m_SubKind: iPad
- m_Textures: []
m_Width: 87
m_Height: 87
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 58
m_Height: 58
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 29
m_Height: 29
m_Kind: 1
m_SubKind: iPhone
- m_Textures: []
m_Width: 58
m_Height: 58
m_Kind: 1
m_SubKind: iPad
- m_Textures: []
m_Width: 29
m_Height: 29
m_Kind: 1
m_SubKind: iPad
- m_Textures: []
m_Width: 60
m_Height: 60
m_Kind: 2
m_SubKind: iPhone
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 2
m_SubKind: iPhone
- m_Textures: []
m_Width: 40
m_Height: 40
m_Kind: 2
m_SubKind: iPad
- m_Textures: []
m_Width: 20
m_Height: 20
m_Kind: 2
m_SubKind: iPad
- m_Textures: []
m_Width: 1024
m_Height: 1024
m_Kind: 4
m_SubKind: App Store
- m_BuildTarget: Android
m_Icons:
- m_Textures: []
m_Width: 432
m_Height: 432
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 324
m_Height: 324
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 216
m_Height: 216
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 162
m_Height: 162
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 108
m_Height: 108
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 81
m_Height: 81
m_Kind: 2
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
m_BuildTargetBatching: []
m_BuildTargetShaderSettings: []
m_BuildTargetGraphicsJobs: []