forked from Shardstone/trail-into-darkness
Added part of the encounter triggering system
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Jovian.ZoneSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -9,12 +8,11 @@ namespace Nox.Game {
|
||||
private readonly ICameraController cameraController;
|
||||
private readonly InputSystem_Actions inputActions;
|
||||
private readonly MapLocationsReference mapLocationsReference;
|
||||
private readonly ZoneSystem zoneSystem;
|
||||
private readonly EncounterHandler encounterHandler;
|
||||
private readonly AdventureSettings adventureSettings;
|
||||
|
||||
private readonly float maxDistance = 100f;
|
||||
private readonly AdventureData adventureData;
|
||||
|
||||
private AdventureData adventureData;
|
||||
private bool partyCanMove;
|
||||
private Vector3 targetPosition;
|
||||
private bool shouldHover;
|
||||
@@ -31,16 +29,15 @@ namespace Nox.Game {
|
||||
ICameraController cameraController,
|
||||
MapLocationsReference mapLocationsReference,
|
||||
Input.InputSettings inputSettings,
|
||||
ZoneSystem zoneSystem,
|
||||
EncounterHandler encounterHandler,
|
||||
AdventureData adventureData,
|
||||
AdventureSettings adventureSettings) {
|
||||
this.partyReference = partyReference;
|
||||
this.cameraController = cameraController;
|
||||
this.mapLocationsReference = mapLocationsReference;
|
||||
this.zoneSystem = zoneSystem;
|
||||
this.encounterHandler = encounterHandler;
|
||||
this.adventureData = adventureData;
|
||||
this.adventureSettings = adventureSettings;
|
||||
|
||||
inputActions = inputSettings.inputActions;
|
||||
}
|
||||
|
||||
@@ -77,10 +74,14 @@ namespace Nox.Game {
|
||||
if(!clickHit.collider.gameObject.transform.parent.TryGetComponent(out MapReference mapReference)) {
|
||||
return;
|
||||
}
|
||||
//if(mapReference.ValidateMoveLocation(hitInfoPoint)) {
|
||||
targetPosition = clickHit.point;
|
||||
partyCanMove = true;
|
||||
//}
|
||||
if(ValidateMoveLocation(clickHit)) {
|
||||
targetPosition = clickHit.point;
|
||||
partyCanMove = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateMoveLocation(object hitInfoPoint) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Tick() {
|
||||
@@ -109,9 +110,13 @@ namespace Nox.Game {
|
||||
VerifyPointsOfInterest();
|
||||
partyCanMove = false;
|
||||
}
|
||||
|
||||
adventureData.isPartyMoving = true;
|
||||
partyReference.transform.position = Vector3.MoveTowards(new Vector3(partyReference.transform.position.x, 0, partyReference.transform.position.z), targetPosition, Time.deltaTime * adventureSettings.partyBaseSpeed);
|
||||
VerifyZones(partyReference.transform.position);
|
||||
partyReference.transform.position = Vector3.MoveTowards(
|
||||
new Vector3(partyReference.transform.position.x, 0,
|
||||
partyReference.transform.position.z), targetPosition,
|
||||
Time.deltaTime * adventureSettings.partyBaseSpeed);
|
||||
encounterHandler?.CheckForEncounters(partyReference.transform.position);
|
||||
}
|
||||
|
||||
private void HandleHover() {
|
||||
@@ -128,20 +133,6 @@ namespace Nox.Game {
|
||||
currentSelectedPoi = null;
|
||||
}
|
||||
}
|
||||
private void VerifyZones(Vector3 position) {
|
||||
var zoneContext = zoneSystem.QueryZone(position);
|
||||
var currentZoneId = zoneContext.resolvedZoneId;
|
||||
|
||||
if(currentZoneId != previousZoneId) {
|
||||
if(!string.IsNullOrEmpty(currentZoneId)) {
|
||||
Debug.Log($"Entered zone: {currentZoneId} (encounter: {zoneContext.encounterTableId}, safe: {zoneContext.isSafe})");
|
||||
}
|
||||
else if(!string.IsNullOrEmpty(previousZoneId)) {
|
||||
Debug.Log($"Left zone: {previousZoneId}");
|
||||
}
|
||||
previousZoneId = currentZoneId;
|
||||
}
|
||||
}
|
||||
|
||||
private void VerifyPointsOfInterest() {
|
||||
foreach(var location in mapLocationsReference.mapLocations) {
|
||||
@@ -156,5 +147,4 @@ namespace Nox.Game {
|
||||
inputActions.Player.ClickOnMap.performed -= OnClickOnMap;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user