more abilities and fixes

This commit is contained in:
Sylvia 2026-06-12 03:54:49 -07:00
parent cb4470f2d6
commit fc2329a873
31 changed files with 268 additions and 52 deletions

View file

@ -1,49 +0,0 @@
using System;
using Unity.Cinemachine;
using UnityEngine;
public class PlayerSwitcher : MonoBehaviour
{
[SerializeField] private CinemachineCamera cam;
[Header("Players")]
[SerializeField] private Player player1;
[SerializeField] private AutomatedPlayer player1AI;
[SerializeField] private Player player2;
[SerializeField] private AutomatedPlayer player2AI;
[Header("Switch Cooldowns")]
[SerializeField] private float switchCooldown;
private float currentSwitchCooldown;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) && currentSwitchCooldown <= 0f)
{
if (player1.isActiveAndEnabled)
{
SwitchPlayers(player1, player1AI, player2, player2AI);
}
else
{
SwitchPlayers(player2, player2AI, player1, player1AI);
}
currentSwitchCooldown = switchCooldown;
}
if (currentSwitchCooldown > 0f)
{
currentSwitchCooldown -= Time.deltaTime;
}
}
public void SwitchPlayers(Player playerA, AutomatedPlayer playerAAI, Player playerB, AutomatedPlayer playerBAI)
{
cam.Follow = playerB.transform;
playerAAI.enabled = true;
playerA.enabled = false;
playerB.enabled = true;
playerBAI.enabled = false;
(playerB.transform.position, playerAAI.transform.position) = (playerAAI.transform.position, playerB.transform.position);
}
}