Skip to content

Commit

Permalink
#596 only activate pilot controls inside checkpoints that have pilot …
Browse files Browse the repository at this point in the history
…controls
  • Loading branch information
shieldgenerator7 committed Jul 21, 2024
1 parent dabd866 commit 097d839
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Assets/Scenes/Test/Tools.unity
Original file line number Diff line number Diff line change
Expand Up @@ -26554,7 +26554,7 @@ Transform:
m_GameObject: {fileID: 578159050}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: 0.0028429776, w: 0.99999595}
m_LocalPosition: {x: -0.0045670867, y: -2.9999979, z: 0}
m_LocalPosition: {x: -2.486029, y: -1.6791914, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
Expand Down Expand Up @@ -26962,8 +26962,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 942494481}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0.598836, w: 0.8008717}
m_LocalPosition: {x: -258.9172, y: 76.33528, z: 0}
m_LocalRotation: {x: 0, y: 0, z: -0.5786719, w: 0.81556046}
m_LocalPosition: {x: 269.24902, y: 94.2139, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
Expand All @@ -26984,8 +26984,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
ForceLaunchAbility: 6
SwapAbility: -1
WallClimbAbility: 0
AirSliceAbility: 0
WallClimbAbility: -1
AirSliceAbility: -1
ElectricBeamAbility: -1
LongTeleportAbility: -1
--- !u!1 &1079170519
Expand Down
4 changes: 3 additions & 1 deletion Assets/Scripts/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ private void Awake()
Managers.initInstance();
Managers.Player.init();
Managers.Camera.init();
Managers.PlayerPilot.init();
FindObjectsByType<PlayerPilotController>(FindObjectsSortMode.None).ToList().ForEach(
pilot => pilot.init()
);
Addressables.InitializeAsync();
}

Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Managers/Managers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static MenuManager Menu
public static PlayerRewindController PlayerRewind { get; private set; }

//Player Pilot Controller
public static PlayerPilotController PlayerPilot { get; private set; }
public static PlayerPilotController PlayerPilot { get; set; }

//Camera Controller
public static CameraController Camera { get; private set; }
Expand Down Expand Up @@ -179,7 +179,6 @@ void init()
Power = FindAnyObjectByType<PowerManager>();
Player = FindObjectsByType<PlayerController>(FindObjectsSortMode.None).First(pc => pc.gameObject.CompareTag("Player"));
PlayerRewind = FindAnyObjectByType<PlayerRewindController>();
PlayerPilot = FindAnyObjectByType<PlayerPilotController>();
Camera = FindAnyObjectByType<CameraController>();

//Init with game data
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/PlayerController/Input/GestureProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void processZoomLevelChange(float zoomLevel)
}
else if (zoomLevel > Managers.Camera.toZoomLevel(CameraController.CameraScalePoints.TIMEREWIND - 1))
{
if (CheckPointChecker.InCheckPoint)
if (CheckPointChecker.InCheckPoint && CheckPointChecker.current.GetComponentInParent<PlayerPilotController>())
{
Managers.Gesture.switchGestureProfile(GestureManager.GestureProfileType.PILOT);
}
Expand Down
12 changes: 10 additions & 2 deletions Assets/Scripts/PlayerController/Input/PilotGestureProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ public class PilotGestureProfile : GestureProfile
public override void activate()
{
base.activate();
Managers.PlayerPilot.activate(true);
PlayerPilotController pilot = CheckPointChecker.current?.GetComponentInParent<PlayerPilotController>();
if (pilot)
{
pilot.activate(true);
}
else
{
deactivate();
}
}
public override void deactivate()
{
base.deactivate();
Managers.PlayerPilot.activate(false);
CheckPointChecker.current?.GetComponentInParent<PlayerPilotController>()?.activate(false);
}

public override void processTapGesture(Vector3 curMPWorld)
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/PlayerController/PlayerPilotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ public void activate(bool active)
{
Managers.Player.Teleport.Range = playerController.Teleport.Range;
checkPointChecker?.clearPostTeleport(true);
Managers.PlayerPilot = this;
}
else
{
Managers.Player.Teleport.Range = Managers.Player.Teleport.baseRange;
CheckPointChecker.current = null;//dirty: the checkpoint system should handle this better
checkPointChecker?.trigger();
if (Managers.PlayerPilot == this)
{
Managers.PlayerPilot = null;
}
}
}

Expand Down

0 comments on commit 097d839

Please sign in to comment.