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

@ -0,0 +1,54 @@
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)
{
SwitchPlayers(player1, player1AI, player2, player2AI);
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);
player1 = playerB;
player1AI = playerBAI;
player2 = playerA;
player2AI = playerAAI;
foreach (Ability ability in playerA.stats.abilities)
{
ability.thisEntity = playerAAI;
}
foreach (Ability ability in playerBAI.stats.abilities)
{
ability.thisEntity = playerB;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3db97897f8dc0482a9a25edd2d1ef4a0