add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,504 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class turnBasedCombatActionsSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public int characterTargetPriority;
|
||||
|
||||
public Transform mainTransform;
|
||||
|
||||
public Transform playerCameraTrnsform;
|
||||
|
||||
[Space]
|
||||
[Header ("Extra Turns Settings")]
|
||||
[Space]
|
||||
|
||||
public bool canUseExtraTurns;
|
||||
public int amountOfExtraTurns;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public string menuPanelName = "Turn Combat System";
|
||||
|
||||
public float movementSpeed = 10;
|
||||
|
||||
[Space]
|
||||
[Header ("Commands Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useBlockedCommandList;
|
||||
public List<string> blockedCommandList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useBlockedCommandCategoryList;
|
||||
public List<string> blockedCommandCategoryList = new List<string> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Stats Settings")]
|
||||
[Space]
|
||||
|
||||
public List<string> characterStatsToShowList = new List<string> ();
|
||||
|
||||
public bool addAmountToCharacterStatsOnCombat;
|
||||
public List<simpleStatInfo> simpleStatInfoList = new List<simpleStatInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Target Selection Settings")]
|
||||
[Space]
|
||||
|
||||
public bool selectTargetInOrder = true;
|
||||
public bool selectRandomTarget;
|
||||
public bool selectTargetByCharacterPriority;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool turnBasedCombatActionActive;
|
||||
|
||||
public Vector3 currentCombatPosition;
|
||||
public Vector3 currentCombatRotation;
|
||||
|
||||
public bool adjustingCharacterPositionInProcess;
|
||||
|
||||
public bool freeCombatActive;
|
||||
|
||||
public bool mainTurnBasedCombatSystemAssigned;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public remoteEventSystem mainRemoteEventSystem;
|
||||
|
||||
public characterToReceiveOrders mainCharacterToReceiveOrders;
|
||||
|
||||
public turnBasedCombatSystem mainTurnBasedCombatSystem;
|
||||
|
||||
public AITurnBasedCombatSystemBrain mainAITurnBasedCombatSystemBrain;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCombatActive;
|
||||
public UnityEvent eventOnCombatActive;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCombatDeactivate;
|
||||
public UnityEvent eventOnCombatDeactivate;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventsIfCharacterAliveAfterCombat;
|
||||
public UnityEvent eventsIfCharacterAliveAfterCombat;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventsIfCharacterDeadAfterCombat;
|
||||
public UnityEvent eventsIfCharacterDeadAfterCombat;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnCharacterCurrentTurnStart;
|
||||
public UnityEvent eventsOnCharacterCurrentTurnStart;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCurrentCharacterTurn;
|
||||
public UnityEvent eventOnCurrentCharacterTurn;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnCurrentTeamTurn;
|
||||
public UnityEvent eventOnCurrentTeamTurn;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnEachTurn;
|
||||
public UnityEvent eventOnEachTurn;
|
||||
|
||||
|
||||
Coroutine movementCoroutine;
|
||||
|
||||
|
||||
public void setCanUseExtraTurnsState (bool state)
|
||||
{
|
||||
canUseExtraTurns = state;
|
||||
}
|
||||
|
||||
public void setAmountOfExtraTurnsValue (int amount)
|
||||
{
|
||||
amountOfExtraTurns = amount;
|
||||
}
|
||||
|
||||
public bool isCanUseExtraTurnsActive ()
|
||||
{
|
||||
return canUseExtraTurns;
|
||||
}
|
||||
|
||||
public int getAmountOfExtraTurns ()
|
||||
{
|
||||
return amountOfExtraTurns;
|
||||
}
|
||||
|
||||
public bool isTurnBasedCombatActionActive ()
|
||||
{
|
||||
return turnBasedCombatActionActive;
|
||||
}
|
||||
|
||||
public void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
turnBasedCombatActionActive = state;
|
||||
|
||||
if (turnBasedCombatActionActive) {
|
||||
initializeMainTurnBasedCombatSystem ();
|
||||
|
||||
if (useEventOnCombatActive) {
|
||||
eventOnCombatActive.Invoke ();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if (useEventOnCombatDeactivate) {
|
||||
eventOnCombatDeactivate.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentCombatPositionAndRotationValues (Vector3 currentCombatPositionValues, Vector3 currentCombatRotationValues)
|
||||
{
|
||||
currentCombatPosition = currentCombatPositionValues;
|
||||
currentCombatRotation = currentCombatRotationValues;
|
||||
}
|
||||
|
||||
public void resetToCurrrentCombatPositionAndRotation (bool setPositionAtOnce)
|
||||
{
|
||||
if (setPositionAtOnce) {
|
||||
setCharacterPositionAtonce (currentCombatPosition, currentCombatRotation, true);
|
||||
} else {
|
||||
activateCharacterMovement (currentCombatPosition, currentCombatRotation, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCharacterPositionAtonce (Vector3 targetPosition, Vector3 targetRotation, bool adjustPlayerCameraTransform)
|
||||
{
|
||||
stopMovement ();
|
||||
|
||||
mainTransform.localPosition = targetPosition;
|
||||
mainTransform.localRotation = Quaternion.Euler (targetRotation);
|
||||
|
||||
if (adjustPlayerCameraTransform) {
|
||||
playerCameraTrnsform.localPosition = targetPosition;
|
||||
playerCameraTrnsform.localRotation = Quaternion.Euler (targetRotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateCharacterMovement (Vector3 targetPosition, Vector3 targetRotation, bool adjustPlayerCameraTransform)
|
||||
{
|
||||
stopMovement ();
|
||||
|
||||
movementCoroutine = StartCoroutine (activateCharacterMovementCoroutine (targetPosition, targetRotation, adjustPlayerCameraTransform));
|
||||
}
|
||||
|
||||
IEnumerator activateCharacterMovementCoroutine (Vector3 targetPosition, Vector3 targetEuler, bool adjustPlayerCameraTransform)
|
||||
{
|
||||
adjustingCharacterPositionInProcess = true;
|
||||
|
||||
float dist = GKC_Utils.distance (mainTransform.position, targetPosition);
|
||||
|
||||
float duration = dist / movementSpeed;
|
||||
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float positionDifference = 0;
|
||||
|
||||
Quaternion targetRotation = Quaternion.Euler (targetEuler);
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / duration;
|
||||
|
||||
mainTransform.localPosition = Vector3.Lerp (mainTransform.localPosition, targetPosition, t);
|
||||
mainTransform.localRotation = Quaternion.Lerp (mainTransform.localRotation, targetRotation, t);
|
||||
|
||||
if (adjustPlayerCameraTransform) {
|
||||
playerCameraTrnsform.localPosition = Vector3.Lerp (playerCameraTrnsform.localPosition, targetPosition, t);
|
||||
playerCameraTrnsform.localRotation = Quaternion.Lerp (playerCameraTrnsform.localRotation, targetRotation, t);
|
||||
}
|
||||
|
||||
angleDifference = Quaternion.Angle (mainTransform.localRotation, targetRotation);
|
||||
|
||||
positionDifference = GKC_Utils.distance (mainTransform.localPosition, targetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if ((positionDifference < 0.01f && angleDifference < 0.2f) || movementTimer > (duration + 0.4f)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
adjustingCharacterPositionInProcess = false;
|
||||
}
|
||||
|
||||
public void stopMovement ()
|
||||
{
|
||||
if (movementCoroutine != null) {
|
||||
StopCoroutine (movementCoroutine);
|
||||
}
|
||||
|
||||
adjustingCharacterPositionInProcess = false;
|
||||
}
|
||||
|
||||
public void activateOrder (string orderName)
|
||||
{
|
||||
mainCharacterToReceiveOrders.activateOrder (orderName);
|
||||
}
|
||||
|
||||
public void activateOrderToAIBrain (string orderName)
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.activateAttackByName (orderName);
|
||||
}
|
||||
|
||||
void initializeMainTurnBasedCombatSystem ()
|
||||
{
|
||||
if (!mainTurnBasedCombatSystemAssigned) {
|
||||
|
||||
mainTurnBasedCombatSystemAssigned = mainTurnBasedCombatSystem != null;
|
||||
|
||||
if (!mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem = turnBasedCombatSystem.Instance;
|
||||
|
||||
mainTurnBasedCombatSystemAssigned = mainTurnBasedCombatSystem != null;
|
||||
}
|
||||
|
||||
if (!mainTurnBasedCombatSystemAssigned) {
|
||||
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (turnBasedCombatSystem.getMainManagerName (), typeof(turnBasedCombatSystem), true);
|
||||
|
||||
mainTurnBasedCombatSystem = turnBasedCombatSystem.Instance;
|
||||
|
||||
mainTurnBasedCombatSystemAssigned = mainTurnBasedCombatSystem != null;
|
||||
}
|
||||
|
||||
if (!mainTurnBasedCombatSystemAssigned) {
|
||||
|
||||
mainTurnBasedCombatSystem = FindObjectOfType<turnBasedCombatSystem> ();
|
||||
|
||||
mainTurnBasedCombatSystemAssigned = mainTurnBasedCombatSystem != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool isAdjustingCharacterPositionInProcess ()
|
||||
{
|
||||
return adjustingCharacterPositionInProcess;
|
||||
}
|
||||
|
||||
public void checkEventsForAliveOrDeadAfterCombat (bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (useEventsIfCharacterAliveAfterCombat) {
|
||||
eventsIfCharacterAliveAfterCombat.Invoke ();
|
||||
}
|
||||
} else {
|
||||
if (useEventsIfCharacterDeadAfterCombat) {
|
||||
eventsIfCharacterDeadAfterCombat.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventsOnCharacterCurrentTurnStart ()
|
||||
{
|
||||
if (useEventsOnCharacterCurrentTurnStart) {
|
||||
eventsOnCharacterCurrentTurnStart.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnCurrentCharacterTurn ()
|
||||
{
|
||||
if (useEventOnCurrentCharacterTurn) {
|
||||
eventOnCurrentCharacterTurn.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnCurrentTeamTurn ()
|
||||
{
|
||||
if (useEventOnCurrentTeamTurn) {
|
||||
eventOnCurrentTeamTurn.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnEachTurn ()
|
||||
{
|
||||
if (useEventOnEachTurn) {
|
||||
eventOnEachTurn.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkTurnBasedCombatOnDamageReceived ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
updateAllCharacterStatsUIValue ();
|
||||
|
||||
activateEffect ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllCharacterStatsUIValue ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.updateAllCharacterStatsUIValue ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextTurn ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.setNextTurn ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentCommandNameUsed (string commandName)
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.setCurrentCommandNameUsed (commandName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEffect (string effectName)
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.activateEffect (effectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFreeCombatActiveState (bool state)
|
||||
{
|
||||
freeCombatActive = state;
|
||||
}
|
||||
|
||||
public bool checkIfCommandCanBeUsed (string commandName)
|
||||
{
|
||||
if (useBlockedCommandList) {
|
||||
return !blockedCommandList.Contains (commandName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool checkIfCommandCategoryCanBeUsed (string commandCategoryName)
|
||||
{
|
||||
if (useBlockedCommandCategoryList) {
|
||||
return !blockedCommandCategoryList.Contains (commandCategoryName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkTeamsDeadStateAfterCharacterDeath ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.checkTeamsDeadStateAfterCharacterDeath (mainTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkCharacterStateAfterResurrect ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.checkCharacterStateAfterResurrect (mainTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPlayerStateOnDeathDuringCombat ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.checkPlayerStateOnDeathDuringCombat ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//INPUT FUNCTIONS
|
||||
public void inputConfirmCommand ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.inputConfirmCommand ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputCancelCommand ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.inputCancelCommand ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputSelectNextTarget ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.inputSelectNextTarget ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputSelectPreviousTarget ()
|
||||
{
|
||||
if (turnBasedCombatActionActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.inputSelectPreviousTarget ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputToggleCombatMode ()
|
||||
{
|
||||
if (turnBasedCombatActionActive || freeCombatActive) {
|
||||
if (mainTurnBasedCombatSystemAssigned) {
|
||||
mainTurnBasedCombatSystem.inputToggleCombatMode ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class simpleStatInfo
|
||||
{
|
||||
public string statName;
|
||||
public float statAmountToAdd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dbdb3d8c3b369946887aada5bb6a3d2
|
||||
timeCreated: 1696851506
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatActionsSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class turnBasedCombatChararcterUIInfoObject : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public turnBasedCombatChararcterUIInfo mainTurnBasedCombatChararcterUIInfo;
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatChararcterUIInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
public GameObject characterUIGameObject;
|
||||
|
||||
public GameObject characterUIOwner;
|
||||
|
||||
public Text characterNameText;
|
||||
|
||||
public List<turnBasedCombatStatUIInfo> turnBasedCombatStatUIInfoList = new List<turnBasedCombatStatUIInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatStatUIInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool statAssigned;
|
||||
|
||||
public bool useStatNameText;
|
||||
|
||||
public Text statNameText;
|
||||
|
||||
public bool useStatAmountText;
|
||||
|
||||
public Text statAmountText;
|
||||
|
||||
public Slider statSlider;
|
||||
|
||||
public GameObject statObject;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class statNameLettersInfo
|
||||
{
|
||||
public string Name;
|
||||
public string statLetters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0c3f8f7b2659964ab49b3d028d92778
|
||||
timeCreated: 1697469621
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatChararcterUIInfoObject.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,879 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class turnBasedCombatSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool turnBasedCombatEnabled = true;
|
||||
|
||||
public float minWaitTimeToActiveCombatOnSpotted = 2;
|
||||
|
||||
public float minExtraWaitToReactivateCombatAfterRun = 3;
|
||||
|
||||
public LayerMask layerToAdjustToGround = 1 << 0 | 1 << 23;
|
||||
|
||||
public float minDistanceToPlayerToStartCombat = 10;
|
||||
|
||||
[Space]
|
||||
[Header ("Camera Settings")]
|
||||
[Space]
|
||||
|
||||
public string defaultCameraStateNameOnTurnBasedCombatActive = "Default Turn Based Combat Camera";
|
||||
public string defaultCameraStateNameOnReturnCameraToPlayer = "Return Camera To Player";
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatCameraInfo> turnBasedCombatCameraInfoList = new List<turnBasedCombatCameraInfo> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatTeamPositionsInfoData> turnBasedCombatTeamPositionsInfoDataList = new List<turnBasedCombatTeamPositionsInfoData> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Effect Settings")]
|
||||
[Space]
|
||||
|
||||
public string defaultEffectName = "Default Effect";
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatEffectInfo> turnBasedCombatEffectInfoList = new List<turnBasedCombatEffectInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Respawn Position Settings")]
|
||||
[Space]
|
||||
|
||||
public List<Transform> positionToRespawnList = new List<Transform> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool turnBasedCombatActive;
|
||||
|
||||
public bool checkingMinWaitTimeToActiveCombatOnSpotted;
|
||||
|
||||
public bool freeCombatActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject mainPlayer;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public playerCamera playerCameraManager;
|
||||
|
||||
public turnBasedCombatUISystem mainTurnBasedCombatUISystem;
|
||||
|
||||
public AIAroundManager mainAIAroundManager;
|
||||
|
||||
public friendListManager mainFriendListManager;
|
||||
|
||||
[HideInInspector] public GameObject newCharacterTeamLeader;
|
||||
|
||||
[HideInInspector] public string teamPositionDataName;
|
||||
[HideInInspector] public List<GameObject> newCharacterTeamInfoList = new List<GameObject> ();
|
||||
[HideInInspector] public bool newTeamAlwaysSelectFirst;
|
||||
[HideInInspector] public bool useRewardSystem;
|
||||
[HideInInspector] public objectExperienceSystem mainRewardSystem;
|
||||
|
||||
[HideInInspector] public bool useCustomCameraStateOnNewTeam;
|
||||
|
||||
[HideInInspector] public string customCameraStateOnNewTeam;
|
||||
|
||||
[HideInInspector] public List<turnBasedCombatTeamInfo> turnBasedCombatTeamInfoOnSceneList = new List<turnBasedCombatTeamInfo> ();
|
||||
|
||||
|
||||
Transform cameraParentTransform;
|
||||
Vector3 mainCameraTargetPosition;
|
||||
Quaternion mainCameraTargetRotation;
|
||||
|
||||
Coroutine cameraState;
|
||||
|
||||
playerComponentsManager mainPlayerComponentsManager;
|
||||
|
||||
turnBasedCombatCameraInfo currentTurnBasedCombatCameraInfo;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
float lastTimeCheckingMinWaitTimeToActiveCombatOnSpotted;
|
||||
|
||||
bool mainTurnBasedCombatUISystemLocated;
|
||||
|
||||
bool useCustomCameraState;
|
||||
|
||||
string customCameraState;
|
||||
|
||||
float lastTimeCombatRunActive = -1;
|
||||
|
||||
List<GameObject> currentPlayerFriendList = new List<GameObject> ();
|
||||
|
||||
int minTeamAmountToCheck;
|
||||
|
||||
|
||||
public const string mainManagerName = "Turn Combat System";
|
||||
|
||||
public static string getMainManagerName ()
|
||||
{
|
||||
return mainManagerName;
|
||||
}
|
||||
|
||||
private static turnBasedCombatSystem _turnBasedCombatSystemInstance;
|
||||
|
||||
public static turnBasedCombatSystem Instance { get { return _turnBasedCombatSystemInstance; } }
|
||||
|
||||
bool instanceInitialized;
|
||||
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (instanceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_turnBasedCombatSystemInstance != null && _turnBasedCombatSystemInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_turnBasedCombatSystemInstance = this;
|
||||
|
||||
instanceInitialized = true;
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (mainPlayer == null) {
|
||||
findMainPlayer ();
|
||||
}
|
||||
}
|
||||
|
||||
void findMainPlayer ()
|
||||
{
|
||||
if (mainPlayer == null) {
|
||||
mainPlayer = GKC_Utils.findMainPlayerOnScene ();
|
||||
}
|
||||
|
||||
if (mainPlayer != null) {
|
||||
setCurrentPlayer (mainPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public void adjustTurnBasedCombatPositionToPlayer ()
|
||||
{
|
||||
if (mainPlayer == null) {
|
||||
findMainPlayer ();
|
||||
}
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
Vector3 targetPosition = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < positionToRespawnList.Count; i++) {
|
||||
if (positionToRespawnList [i] != null) {
|
||||
positionToRespawnList [i].SetParent (null);
|
||||
}
|
||||
|
||||
targetPosition = positionToRespawnList [i].position + positionToRespawnList [i].up * 3;
|
||||
|
||||
if (Physics.Raycast (targetPosition, -Vector3.up, out hit, 200, layerToAdjustToGround)) {
|
||||
targetPosition = hit.point;
|
||||
}
|
||||
|
||||
positionToRespawnList [i].position = targetPosition;
|
||||
}
|
||||
|
||||
targetPosition = mainPlayer.transform.position + mainPlayer.transform.up * 3;
|
||||
|
||||
if (Physics.Raycast (targetPosition, -Vector3.up, out hit, 200, layerToAdjustToGround)) {
|
||||
targetPosition = hit.point;
|
||||
}
|
||||
|
||||
transform.position = targetPosition;
|
||||
transform.rotation = playerCameraManager.transform.rotation;
|
||||
}
|
||||
|
||||
public void enableWaitTimeToActivateTurnBasedCombat ()
|
||||
{
|
||||
if (!turnBasedCombatEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (freeCombatActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkingMinWaitTimeToActiveCombatOnSpotted) {
|
||||
checkingMinWaitTimeToActiveCombatOnSpotted = true;
|
||||
|
||||
lastTimeCheckingMinWaitTimeToActiveCombatOnSpotted = Time.time;
|
||||
|
||||
if (currentPlayerFriendList != null) {
|
||||
currentPlayerFriendList.Clear ();
|
||||
}
|
||||
|
||||
currentPlayerFriendList = mainFriendListManager.getAllFriendList ();
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
public void disableWaitTimeToActivateTurnBasedCombat ()
|
||||
{
|
||||
if (!turnBasedCombatEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (freeCombatActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkingMinWaitTimeToActiveCombatOnSpotted) {
|
||||
checkingMinWaitTimeToActiveCombatOnSpotted = false;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
if (checkingMinWaitTimeToActiveCombatOnSpotted) {
|
||||
bool checkStateResult = true;
|
||||
|
||||
if (lastTimeCombatRunActive != -1) {
|
||||
if (Time.time < minExtraWaitToReactivateCombatAfterRun + lastTimeCombatRunActive) {
|
||||
checkStateResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkStateResult) {
|
||||
if (Time.time > lastTimeCheckingMinWaitTimeToActiveCombatOnSpotted + minWaitTimeToActiveCombatOnSpotted) {
|
||||
bool checkActivateCombatResult = false;
|
||||
|
||||
if (mainAIAroundManager.checkIfPlayerDetectedByAIAround (mainPlayer)) {
|
||||
|
||||
float distanceToPlayer = mainAIAroundManager.getMinDistanceToPlayer (mainPlayer.transform, false);
|
||||
|
||||
if (distanceToPlayer < minDistanceToPlayerToStartCombat) {
|
||||
checkActivateCombatResult = true;
|
||||
}
|
||||
} else {
|
||||
if (currentPlayerFriendList != null) {
|
||||
int currentPlayerFriendListCount = currentPlayerFriendList.Count;
|
||||
|
||||
for (int i = 0; i < currentPlayerFriendListCount; i++) {
|
||||
if (mainAIAroundManager.checkIfPlayerDetectedByAIAround (currentPlayerFriendList [i])) {
|
||||
|
||||
float distanceToPlayer = mainAIAroundManager.getMinDistanceToPlayer (mainPlayer.transform, true);
|
||||
|
||||
if (distanceToPlayer < minDistanceToPlayerToStartCombat) {
|
||||
checkActivateCombatResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkActivateCombatResult) {
|
||||
checkingMinWaitTimeToActiveCombatOnSpotted = false;
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
activateTurnBasedCombat ();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLastTimeCombatRunActive (float value)
|
||||
{
|
||||
lastTimeCombatRunActive = value;
|
||||
}
|
||||
|
||||
public void clearCharactersAround ()
|
||||
{
|
||||
mainAIAroundManager.clearCharactersAround ();
|
||||
}
|
||||
|
||||
public void activateTurnBasedCombat ()
|
||||
{
|
||||
activateOrDeactivateTurnBasedCombat (true);
|
||||
}
|
||||
|
||||
public void deactivateTurnBasedCombat ()
|
||||
{
|
||||
activateOrDeactivateTurnBasedCombat (false);
|
||||
}
|
||||
|
||||
void activateOrDeactivateTurnBasedCombat (bool state)
|
||||
{
|
||||
if (!mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystemLocated = mainTurnBasedCombatUISystem != null;
|
||||
|
||||
if (!mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem = FindObjectOfType<turnBasedCombatUISystem> ();
|
||||
|
||||
mainTurnBasedCombatUISystemLocated = mainTurnBasedCombatUISystem != null;
|
||||
}
|
||||
}
|
||||
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
if (state) {
|
||||
mainTurnBasedCombatUISystem.checkMainPlayerStateBeforeActivateCombat ();
|
||||
}
|
||||
|
||||
mainTurnBasedCombatUISystem.openOrCloseMenuPanel (state);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnBasedCombatActiveState (bool state)
|
||||
{
|
||||
if (turnBasedCombatEnabled) {
|
||||
turnBasedCombatActive = state;
|
||||
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainPlayer == null) {
|
||||
findMainPlayer ();
|
||||
}
|
||||
|
||||
if (mainPlayer != null) {
|
||||
if (useCustomCameraState) {
|
||||
setCameraState (customCameraState);
|
||||
} else {
|
||||
setCameraState (defaultCameraStateNameOnTurnBasedCombatActive);
|
||||
}
|
||||
|
||||
} else {
|
||||
print ("WARNING: Main Player not found on scene");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPlayerFriendList != null) {
|
||||
currentPlayerFriendList.Clear ();
|
||||
}
|
||||
|
||||
currentPlayerFriendList = mainFriendListManager.getAllFriendList ();
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
} else {
|
||||
setCameraState (defaultCameraStateNameOnReturnCameraToPlayer);
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMinTeamAmountToCheck (int newAmount)
|
||||
{
|
||||
minTeamAmountToCheck = newAmount;
|
||||
}
|
||||
|
||||
void setCameraState (string cameraStateName)
|
||||
{
|
||||
int cameraStateIndex = turnBasedCombatCameraInfoList.FindIndex (s => s.Name.Equals (cameraStateName));
|
||||
|
||||
if (cameraStateIndex == -1) {
|
||||
for (int i = 0; i < turnBasedCombatCameraInfoList.Count; i++) {
|
||||
if (cameraStateIndex == -1) {
|
||||
if (turnBasedCombatCameraInfoList [i].minTeamAmountToCheck != 0 &&
|
||||
turnBasedCombatCameraInfoList [i].minTeamAmountToCheck >= minTeamAmountToCheck) {
|
||||
cameraStateIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cameraStateIndex > -1) {
|
||||
|
||||
currentTurnBasedCombatCameraInfo = turnBasedCombatCameraInfoList [cameraStateIndex];
|
||||
|
||||
mainCameraTargetRotation = Quaternion.identity;
|
||||
mainCameraTargetPosition = Vector3.zero;
|
||||
|
||||
if (currentTurnBasedCombatCameraInfo.setCameraBackToPlayer) {
|
||||
if (cameraParentTransform != null) {
|
||||
mainCamera.transform.SetParent (cameraParentTransform);
|
||||
|
||||
cameraParentTransform = null;
|
||||
}
|
||||
} else {
|
||||
if (cameraParentTransform == null) {
|
||||
cameraParentTransform = mainCamera.transform.parent;
|
||||
}
|
||||
|
||||
mainCamera.transform.SetParent (currentTurnBasedCombatCameraInfo.cameraPosition);
|
||||
}
|
||||
|
||||
if (currentTurnBasedCombatCameraInfo.smoothCameraMovement) {
|
||||
stopMovement ();
|
||||
|
||||
cameraState = StartCoroutine (adjustCamera ());
|
||||
} else {
|
||||
mainCamera.transform.localRotation = mainCameraTargetRotation;
|
||||
mainCamera.transform.localPosition = mainCameraTargetPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator adjustCamera ()
|
||||
{
|
||||
Transform mainCameraTransform = mainCamera.transform;
|
||||
|
||||
if (currentTurnBasedCombatCameraInfo.useFixedLerpMovement) {
|
||||
float i = 0;
|
||||
//store the current rotation of the camera
|
||||
Quaternion currentQ = mainCameraTransform.localRotation;
|
||||
//store the current position of the camera
|
||||
Vector3 currentPos = mainCameraTransform.localPosition;
|
||||
|
||||
//translate position and rotation camera
|
||||
while (i < 1) {
|
||||
i += Time.deltaTime * currentTurnBasedCombatCameraInfo.fixedLerpMovementSpeed;
|
||||
|
||||
mainCameraTransform.localRotation = Quaternion.Lerp (currentQ, mainCameraTargetRotation, i);
|
||||
mainCameraTransform.localPosition = Vector3.Lerp (currentPos, mainCameraTargetPosition, i);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
float dist = GKC_Utils.distance (mainCameraTransform.localPosition, mainCameraTargetPosition);
|
||||
|
||||
float duration = dist / currentTurnBasedCombatCameraInfo.regularMovementSpeed;
|
||||
|
||||
float t = 0;
|
||||
|
||||
float movementTimer = 0;
|
||||
|
||||
bool targetReached = false;
|
||||
|
||||
float angleDifference = 0;
|
||||
|
||||
float positionDifference = 0;
|
||||
|
||||
while (!targetReached) {
|
||||
t += Time.deltaTime / duration;
|
||||
|
||||
mainCameraTransform.localPosition = Vector3.Lerp (mainCameraTransform.localPosition, mainCameraTargetPosition, t);
|
||||
mainCameraTransform.localRotation = Quaternion.Lerp (mainCameraTransform.localRotation, mainCameraTargetRotation, t);
|
||||
|
||||
angleDifference = Quaternion.Angle (mainCameraTransform.localRotation, mainCameraTargetRotation);
|
||||
|
||||
positionDifference = GKC_Utils.distance (mainCameraTransform.localPosition, mainCameraTargetPosition);
|
||||
|
||||
movementTimer += Time.deltaTime;
|
||||
|
||||
if ((positionDifference < 0.01f && angleDifference < 0.2f) || movementTimer > (duration + 1)) {
|
||||
targetReached = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopMovement ()
|
||||
{
|
||||
if (cameraState != null) {
|
||||
StopCoroutine (cameraState);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPlayer (GameObject player)
|
||||
{
|
||||
mainPlayer = player;
|
||||
|
||||
if (mainPlayer != null) {
|
||||
mainPlayerComponentsManager = mainPlayer.GetComponent<playerComponentsManager> ();
|
||||
|
||||
playerCameraManager = mainPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
mainCamera = playerCameraManager.getMainCamera ();
|
||||
|
||||
mainAIAroundManager = mainPlayerComponentsManager.getAIAroundManager ();
|
||||
|
||||
mainFriendListManager = mainPlayerComponentsManager.getFriendListManager ();
|
||||
}
|
||||
}
|
||||
|
||||
public turnBasedCombatTeamPositionsInfoData getTurnBasedCombatTeamPositionsInfoData (int teamSize, string teamPositionInfoName, bool isPlayerTeam)
|
||||
{
|
||||
int currentIndex = -1;
|
||||
|
||||
if (teamPositionInfoName != "") {
|
||||
currentIndex = turnBasedCombatTeamPositionsInfoDataList.FindIndex (s => s.Name.Equals (teamPositionInfoName));
|
||||
|
||||
if (currentIndex > -1) {
|
||||
bool getDataResult = true;
|
||||
|
||||
if (turnBasedCombatTeamPositionsInfoDataList [currentIndex].turnBasedCombatCharacterPositionsInfoList.Count < teamSize) {
|
||||
getDataResult = false;
|
||||
}
|
||||
|
||||
if (getDataResult) {
|
||||
return turnBasedCombatTeamPositionsInfoDataList [currentIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int turnBasedCombatTeamPositionsInfoDataListCount = turnBasedCombatTeamPositionsInfoDataList.Count;
|
||||
|
||||
for (int i = 0; i < turnBasedCombatTeamPositionsInfoDataListCount; i++) {
|
||||
if (turnBasedCombatTeamPositionsInfoDataList [i].turnBasedCombatCharacterPositionsInfoList.Count == teamSize) {
|
||||
|
||||
if (turnBasedCombatTeamPositionsInfoDataList [i].usedForPlayerTeam == isPlayerTeam) {
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentIndex > -1) {
|
||||
return turnBasedCombatTeamPositionsInfoDataList [currentIndex];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setUseCustomCameraState (bool state, string cameraStateName)
|
||||
{
|
||||
useCustomCameraState = state;
|
||||
|
||||
customCameraState = cameraStateName;
|
||||
}
|
||||
|
||||
public List<Transform> getPositionToRespawnList ()
|
||||
{
|
||||
return positionToRespawnList;
|
||||
}
|
||||
|
||||
public Vector3 getClosestRespawnPosition (Vector3 currentPosition)
|
||||
{
|
||||
float minDistance = Mathf.Infinity;
|
||||
|
||||
int positionToRespawnListCount = positionToRespawnList.Count;
|
||||
|
||||
int closestPointIndex = -1;
|
||||
|
||||
for (int i = 0; i < positionToRespawnListCount; i++) {
|
||||
float currentDistance = GKC_Utils.distance (positionToRespawnList [i].position, currentPosition);
|
||||
|
||||
if (currentDistance < minDistance) {
|
||||
minDistance = currentDistance;
|
||||
|
||||
closestPointIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestPointIndex != -1) {
|
||||
return positionToRespawnList [closestPointIndex].position;
|
||||
}
|
||||
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
public void updateAllCharacterStatsUIValue ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.updateAllCharacterStatsUIValue ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNextTurn ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.setNextTurn ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentCommandNameUsed (string commandName)
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.setCurrentCommandNameUsed (commandName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void activateEffect (string effectName)
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (effectName == "") {
|
||||
effectName = defaultEffectName;
|
||||
}
|
||||
|
||||
int effectIndex = turnBasedCombatEffectInfoList.FindIndex (s => s.Name.Equals (effectName));
|
||||
|
||||
if (effectIndex > -1) {
|
||||
turnBasedCombatEffectInfo currentTurnBasedCombatEffectInfo = turnBasedCombatEffectInfoList [effectIndex];
|
||||
|
||||
if (currentTurnBasedCombatEffectInfo.effectEnabled) {
|
||||
currentTurnBasedCombatEffectInfo.eventOnEffect.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFreeCombatActiveState (bool state)
|
||||
{
|
||||
freeCombatActive = state;
|
||||
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.setFreeCombatActiveStateOnAllCharacters (state);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkTeamsDeadStateAfterCharacterDeath (Transform characterTransform)
|
||||
{
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.checkTeamsDeadStateAfterCharacterDeath (characterTransform);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkCharacterStateAfterResurrect (Transform characterTransform)
|
||||
{
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.checkCharacterStateAfterResurrect (characterTransform);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPlayerStateOnDeathDuringCombat ()
|
||||
{
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.checkPlayerStateOnDeathDuringCombat ();
|
||||
}
|
||||
}
|
||||
|
||||
//INPUT FUNCTIONS
|
||||
public void inputConfirmCommand ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.inputConfirmCommand ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputCancelCommand ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.inputCancelCommand ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputSelectNextTarget ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.inputSelectNextTarget ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputSelectPreviousTarget ()
|
||||
{
|
||||
if (turnBasedCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.inputSelectPreviousTarget ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void inputToggleCombatMode ()
|
||||
{
|
||||
if (turnBasedCombatActive || freeCombatActive) {
|
||||
if (mainTurnBasedCombatUISystemLocated) {
|
||||
mainTurnBasedCombatUISystem.inputToggleCombatMode ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void configureNewTeamInfo ()
|
||||
{
|
||||
bool teamConfiguredProperly = false;
|
||||
|
||||
if (newCharacterTeamLeader != null && newCharacterTeamInfoList.Count > 0) {
|
||||
|
||||
List<GameObject> characterGameobjectTeamList = new List<GameObject> ();
|
||||
|
||||
int newCharacterTeamInfoListCount = newCharacterTeamInfoList.Count;
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = newCharacterTeamLeader.GetComponentInChildren<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
newCharacterTeamLeader = currentPlayerComponentsManager.gameObject;
|
||||
}
|
||||
|
||||
for (int i = 0; i < newCharacterTeamInfoListCount; i++) {
|
||||
if (newCharacterTeamInfoList [i] != null) {
|
||||
currentPlayerComponentsManager = newCharacterTeamInfoList [i].GetComponentInChildren<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
characterGameobjectTeamList.Add (currentPlayerComponentsManager.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int characterGameobjectTeamListCount = characterGameobjectTeamList.Count;
|
||||
|
||||
for (int i = 0; i < characterGameobjectTeamListCount; i++) {
|
||||
|
||||
currentPlayerComponentsManager = characterGameobjectTeamList [i].GetComponentInChildren<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
GameObject currentCharacterGameObject = currentPlayerComponentsManager.gameObject;
|
||||
|
||||
turnBasedCombatTeamInfo currentTurnBasedCombatTeamInfo = currentPlayerComponentsManager.getTurnBasedCombatTeamInfo ();
|
||||
|
||||
currentTurnBasedCombatTeamInfo.clearCharacterTeamList ();
|
||||
|
||||
currentTurnBasedCombatTeamInfo.setCharacterTeamList (characterGameobjectTeamList);
|
||||
|
||||
currentTurnBasedCombatTeamInfo.isTeamLeader = (currentCharacterGameObject == newCharacterTeamLeader);
|
||||
|
||||
print ("is leader " + currentTurnBasedCombatTeamInfo.isTeamLeader);
|
||||
|
||||
currentTurnBasedCombatTeamInfo.teamPositionDataName = teamPositionDataName;
|
||||
|
||||
currentTurnBasedCombatTeamInfo.thisTeamAlwaysSelectFirst = newTeamAlwaysSelectFirst;
|
||||
|
||||
currentTurnBasedCombatTeamInfo.useCustomCameraState = useCustomCameraStateOnNewTeam;
|
||||
|
||||
currentTurnBasedCombatTeamInfo.customCameraState = customCameraStateOnNewTeam;
|
||||
|
||||
if (useRewardSystem) {
|
||||
currentTurnBasedCombatTeamInfo.useRewardSystem = true;
|
||||
|
||||
if (mainRewardSystem != null) {
|
||||
currentTurnBasedCombatTeamInfo.mainRewardSystem = mainRewardSystem;
|
||||
}
|
||||
}
|
||||
|
||||
GKC_Utils.updateComponent (currentTurnBasedCombatTeamInfo);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Turn Based Team Combat System", currentTurnBasedCombatTeamInfo.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
teamConfiguredProperly = true;
|
||||
}
|
||||
|
||||
if (teamConfiguredProperly) {
|
||||
newCharacterTeamLeader = null;
|
||||
|
||||
teamPositionDataName = "";
|
||||
|
||||
newTeamAlwaysSelectFirst = false;
|
||||
|
||||
useCustomCameraStateOnNewTeam = false;
|
||||
|
||||
customCameraStateOnNewTeam = "";
|
||||
|
||||
useRewardSystem = false;
|
||||
|
||||
mainRewardSystem = null;
|
||||
|
||||
newCharacterTeamInfoList.Clear ();
|
||||
|
||||
print ("New Turn Based Combat Team Configured");
|
||||
|
||||
updateComponent ();
|
||||
} else {
|
||||
print ("WARNING: make sure all team info is configured properly on the inspector");
|
||||
}
|
||||
}
|
||||
|
||||
public void showAllTeamsInScene ()
|
||||
{
|
||||
turnBasedCombatTeamInfoOnSceneList.Clear ();
|
||||
|
||||
turnBasedCombatTeamInfo[] turnBasedCombatTeamInfoList = FindObjectsOfType<turnBasedCombatTeamInfo> ();
|
||||
|
||||
foreach (turnBasedCombatTeamInfo currentTurnBasedCombatTeamInfo in turnBasedCombatTeamInfoList) {
|
||||
if (currentTurnBasedCombatTeamInfo.isTeamLeaderValue ()) {
|
||||
turnBasedCombatTeamInfoOnSceneList.Add (currentTurnBasedCombatTeamInfo);
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Turn Based Combat System", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatCameraInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public Transform cameraPosition;
|
||||
|
||||
[Space]
|
||||
|
||||
public int minTeamAmountToCheck;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useFixedLerpMovement = true;
|
||||
public float fixedLerpMovementSpeed = 2;
|
||||
|
||||
public float regularMovementSpeed = 2;
|
||||
|
||||
public bool smoothCameraMovement = true;
|
||||
|
||||
public bool setCameraBackToPlayer;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatEffectInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool effectEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnEffect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e8bba992836f424aa15ef404fc656cc
|
||||
timeCreated: 1696846817
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class turnBasedCombatTeamInfo : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool isTeamLeader;
|
||||
|
||||
public bool useTeamPositionDataName;
|
||||
|
||||
public string teamPositionDataName;
|
||||
|
||||
public bool thisTeamAlwaysSelectFirst;
|
||||
|
||||
public bool useCustomCameraState;
|
||||
|
||||
public string customCameraState;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Team List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<GameObject> characterTeamList = new List<GameObject> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Rewads Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnTeamDefeated;
|
||||
public UnityEvent eventOnTeamDefeated;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventOnRewardForOpponentTeam;
|
||||
public eventParameters.eventToCallWithGameObject eventOnRewardForOpponentTeam;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useRewardSystem;
|
||||
|
||||
public objectExperienceSystem mainRewardSystem;
|
||||
|
||||
|
||||
public bool isTeamLeaderValue ()
|
||||
{
|
||||
return isTeamLeader;
|
||||
}
|
||||
|
||||
public void removeDeadCharactersFromTeam ()
|
||||
{
|
||||
for (int i = characterTeamList.Count - 1; i >= 0; i--) {
|
||||
if (characterTeamList [i] == null || applyDamage.checkIfDead (characterTeamList [i])) {
|
||||
characterTeamList.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCharacterTeamList ()
|
||||
{
|
||||
characterTeamList.Clear ();
|
||||
}
|
||||
|
||||
public List<GameObject> getCharacterTeamList ()
|
||||
{
|
||||
return characterTeamList;
|
||||
}
|
||||
|
||||
public void setCharacterTeamList (List<GameObject> newList)
|
||||
{
|
||||
characterTeamList = newList;
|
||||
}
|
||||
|
||||
public void addCharacterToTeamList (GameObject newCharacter)
|
||||
{
|
||||
if (!characterTeamList.Contains (newCharacter)) {
|
||||
characterTeamList.Add (newCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCharacterToTeamList (GameObject newCharacter)
|
||||
{
|
||||
if (characterTeamList.Contains (newCharacter)) {
|
||||
characterTeamList.Remove (newCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventsOnTeamDefeated ()
|
||||
{
|
||||
if (useEventOnTeamDefeated) {
|
||||
eventOnTeamDefeated.Invoke ();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkEventOnRewardForOpponentTeam (List<GameObject> opponentTeamList)
|
||||
{
|
||||
if (useEventOnRewardForOpponentTeam) {
|
||||
if (opponentTeamList.Count > 0) {
|
||||
for (int i = 0; i < opponentTeamList.Count; i++) {
|
||||
eventOnRewardForOpponentTeam.Invoke (opponentTeamList [i]);
|
||||
|
||||
if (useRewardSystem) {
|
||||
if (mainRewardSystem != null) {
|
||||
mainRewardSystem.sendExperienceToAttacker (opponentTeamList [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c37cf067accb6c4a93037572b2ce67a
|
||||
timeCreated: 1696864965
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatTeamInfo.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (fileName = "Turn Based Combat Team Positions Info Data", menuName = "GKC/Create Turn Based Combat Team Positions Info Data", order = 51)]
|
||||
public class turnBasedCombatTeamPositionsInfoData : ScriptableObject
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public int ID;
|
||||
|
||||
public bool usedForPlayerTeam;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatCharacterPositionsInfo> turnBasedCombatCharacterPositionsInfoList = new List<turnBasedCombatCharacterPositionsInfo> ();
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatCharacterPositionsInfo
|
||||
{
|
||||
public Vector3 positionValue;
|
||||
public Vector3 rotationValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2056434ef117294cb6a2ca7454af7e1
|
||||
timeCreated: 1696864702
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatTeamPositionsInfoData.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d313f363b56f5ab42bda13e1032368bf
|
||||
timeCreated: 1696846558
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Turn Based Combat/turnBasedCombatUISystem.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user