bug fixes
This commit is contained in:
@@ -11,7 +11,6 @@ public class Damageable : MonoBehaviour
|
||||
public float damage = 0f;
|
||||
public float maxDamage = 1000f;
|
||||
public int lives = 3;
|
||||
//private GameManager gameManager;
|
||||
private Animator animator;
|
||||
|
||||
public bool damageSelfDebug = false;
|
||||
@@ -20,7 +19,6 @@ public class Damageable : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//gameManager = GameManager.Instance;
|
||||
animator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
@@ -37,7 +35,7 @@ public class Damageable : MonoBehaviour
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Punch Hurtbox"))
|
||||
{
|
||||
print($"{name}: Ouch");
|
||||
//print($"{name}: Ouch");
|
||||
Damage(collision.transform.parent.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -92,13 +90,11 @@ public class Damageable : MonoBehaviour
|
||||
}
|
||||
|
||||
private void Die()
|
||||
{
|
||||
//Debug.Log($"{name}: MAKE THIS WORK.");
|
||||
{;
|
||||
if (GameManager.Instance != null)
|
||||
{
|
||||
animator.SetTrigger("die");
|
||||
dying = true;
|
||||
//StartCoroutine(HandleDeath()); // Handled by an animation event instead.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
@@ -77,6 +78,7 @@ public class GameManager : MonoBehaviour
|
||||
if (player.lives <= 0)
|
||||
{
|
||||
GameOver(player.gameObject);
|
||||
Destroy(player.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,7 +108,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
private void GameOver(GameObject player)
|
||||
{
|
||||
// Add game over screen
|
||||
Destroy(player);
|
||||
player.SetActive(false);
|
||||
if (AlivePlayers().Count <= 1)
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
// This won scene thing is just duct taped on for the presentation.
|
||||
|
||||
public class PlayerCameraMovement : MonoBehaviour
|
||||
{
|
||||
private Vector3 start;
|
||||
@@ -22,28 +21,38 @@ public class PlayerCameraMovement : MonoBehaviour
|
||||
{
|
||||
if (winScene)
|
||||
{
|
||||
if (playerThatWon == null) playerThatWon = GameManager.players[0];
|
||||
target = playerThatWon.transform.position;
|
||||
transform.position = Vector3.Lerp(transform.position, new Vector3(target.x, target.y, target.z - 10), speed * Time.deltaTime);
|
||||
if (playerThatWon == null || !playerThatWon.activeInHierarchy)
|
||||
{
|
||||
playerThatWon = FindWinner();
|
||||
}
|
||||
|
||||
if (playerThatWon != null)
|
||||
{
|
||||
target = playerThatWon.transform.position;
|
||||
transform.position = Vector3.Lerp(transform.position, new Vector3(target.x, target.y, target.z - 10), speed * Time.deltaTime);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
List<GameObject> players = GameManager.players;
|
||||
|
||||
if (players.Count == 0) return;
|
||||
|
||||
Vector3 playerAverage = Vector3.zero;
|
||||
int activePlayers = 0;
|
||||
foreach (GameObject player in players)
|
||||
{
|
||||
if (player.GetComponent<Damageable>().dying) continue;
|
||||
if (player == null || !player.activeInHierarchy) continue;
|
||||
Damageable damageable = player.GetComponent<Damageable>();
|
||||
if (damageable != null && damageable.dying) continue;
|
||||
playerAverage += player.transform.position;
|
||||
activePlayers++;
|
||||
}
|
||||
playerAverage /= players.Count;
|
||||
|
||||
if (activePlayers == 0) return;
|
||||
|
||||
playerAverage /= activePlayers;
|
||||
|
||||
target = start * weight + playerAverage * (1 - weight);
|
||||
transform.position = Vector3.Lerp(transform.position, new Vector3(target.x, target.y, transform.position.z), speed * Time.deltaTime);
|
||||
transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z);
|
||||
}
|
||||
|
||||
public void WinScene(GameObject player)
|
||||
@@ -51,4 +60,16 @@ public class PlayerCameraMovement : MonoBehaviour
|
||||
winScene = true;
|
||||
playerThatWon = player;
|
||||
}
|
||||
|
||||
private GameObject FindWinner()
|
||||
{
|
||||
foreach (GameObject player in GameManager.players)
|
||||
{
|
||||
if (player != null && player.activeInHierarchy)
|
||||
{
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ public class PlayerManager : MonoBehaviour
|
||||
public List<Color> playerColors;
|
||||
public GameObject playerSelect;
|
||||
private bool gameStarted = false;
|
||||
private bool isStartPressed = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -40,6 +39,7 @@ public class PlayerManager : MonoBehaviour
|
||||
Colorize(GameManager.players.Count - 1);
|
||||
}
|
||||
|
||||
|
||||
private void OnPlayerLeft(PlayerInput playerInput)
|
||||
{
|
||||
Destroy(playerInput.gameObject);
|
||||
@@ -65,15 +65,8 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isStartPressed)
|
||||
{
|
||||
gameStarted = true;
|
||||
HubManager.Instance.LoadScene(GameManager.map);
|
||||
}
|
||||
else
|
||||
{
|
||||
isStartPressed = true;
|
||||
}
|
||||
gameStarted = true;
|
||||
HubManager.Instance.LoadScene(GameManager.map);
|
||||
}
|
||||
|
||||
private void Colorize(int index)
|
||||
|
||||
Reference in New Issue
Block a user