add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AIBehaviorInfo : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool behaviorEnabled = true;
|
||||
|
||||
public virtual void activateAIBehavior ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void deactivateAIBehavior ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateAI ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateAIBehaviorState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateAIAttackState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateInsideRangeDistance (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateAIBehaviorState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setDrawOrHolsterWeaponState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setAimWeaponState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setShootWeaponState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setHoldShootWeaponState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void dropWeapon ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkIfDrawWeaponsWhenResumingAI ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void resetBehaviorStates ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void resetAttackState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void stopAim ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void disableOnSpottedState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateWeaponsAvailableState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setBehaviorStatesPausedState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setSystemActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool carryingWeapon ()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void updateIfCarryingWeapon ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual void setUseRandomWalkEnabledState (bool state)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual void setOriginalUseRandomWalkEnabledState ()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual bool isAIBehaviorAttackInProcess ()
|
||||
{
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void checkNoWeaponsAvailableState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkIfDisableCurrentWeaponToChangeAttackMode (string newModeName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void changeCurrentAttackMode (string newModeName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setIsCurrentCharacterTurn (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setAIOnPlayerTeamState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setCurrentCharacterTurnTarget (GameObject newTarget)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void stopCurrentAttackInProcess ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkStateOnCharacterDead ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void stopAttackState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setAttackEnabledState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateCurrentTargetSelectedInfo ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void updateAIPassengerBehavior ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void getOffFromVehicle ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void removeStateOnVehicle ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setAICharacterOnVehicle (GameObject newVehicle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setCurrentPlayerControllerPartner (playerController newPlayerController)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ffa02f5dd4f9b340ae20bc74e509eba
|
||||
timeCreated: 1602681429
|
||||
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/AI/Custom AI Behavior/AI Behavior
|
||||
Info.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,950 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class AIAbilitiesSystemBrain : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool systemEnabled = true;
|
||||
|
||||
public float currentMinDistanceToAttack = 7;
|
||||
|
||||
[Space]
|
||||
[Header ("Attack Settings")]
|
||||
[Space]
|
||||
|
||||
public bool attackEnabled;
|
||||
|
||||
public Vector2 randomAttackRangeRate;
|
||||
|
||||
[Space]
|
||||
[Header ("Abilities Settings")]
|
||||
[Space]
|
||||
|
||||
public bool changeAbilityAfterTimeEnabled;
|
||||
|
||||
public bool changeAbilityRandomly;
|
||||
|
||||
public Vector2 randomChangeAbilityRate;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useCustomListToChangeAbility;
|
||||
|
||||
public List<string> customListToChangeAbility = new List<string> ();
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useCustomListToChangeAbilityInfoList;
|
||||
|
||||
public List<customListToChangeAbilityInfo> customListToChangeAbilityInfoList = new List<customListToChangeAbilityInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Abilities List")]
|
||||
[Space]
|
||||
|
||||
public int currentAbilityIndex;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<AIAbilityInfo> AIAbilityInfoList = new List<AIAbilityInfo> ();
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public int currentAbilityStateIndex;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<AIAbilityStatesInfo> AIAbilityStatesInfoList = new List<AIAbilityStatesInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool changeWaitToActivateAttackEnabled = true;
|
||||
|
||||
public bool useWaitToActivateAttackActiveCounter;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool systemActive;
|
||||
|
||||
public bool waitingForAttackActive;
|
||||
float currentRandomTimeToAttack;
|
||||
|
||||
public bool canUseAttackActive;
|
||||
|
||||
public bool attackStatePaused;
|
||||
|
||||
public bool insideMinDistanceToAttack;
|
||||
|
||||
public float currentAttackRate;
|
||||
|
||||
public bool abilityInProcess;
|
||||
|
||||
public bool onSpotted;
|
||||
|
||||
public bool checkingToChangeAbilityActive;
|
||||
|
||||
public bool waitToActivateAttackActive;
|
||||
|
||||
public int waitToActivateAttackActiveCounter = 0;
|
||||
|
||||
public bool turnBasedCombatActionActive;
|
||||
|
||||
public float currentPathDistanceToTarget;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnCombatActive;
|
||||
public UnityEvent eventOnCombatActive;
|
||||
public UnityEvent eventOnCombatDeactivate;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AINavMesh mainAINavmeshManager;
|
||||
public playerAbilitiesSystem mainPlayerAbilitiesSystem;
|
||||
public playerController mainPlayerController;
|
||||
|
||||
|
||||
float lastTimeAttack;
|
||||
|
||||
int currentAttackTypeIndex;
|
||||
|
||||
int currentAttackIndex;
|
||||
|
||||
int currentAttackTypeToAlternateIndex;
|
||||
|
||||
float currentPauseAttackStateDuration;
|
||||
float lastTimeAttackPauseWithDuration;
|
||||
|
||||
float randomWaitTime;
|
||||
|
||||
float lastTimeAttackActivated;
|
||||
|
||||
bool AIPaused;
|
||||
|
||||
AIAbilityInfo currentAIAbilityInfo;
|
||||
|
||||
bool currentAIAbilityInfoAssigned;
|
||||
|
||||
Coroutine abilityCoroutine;
|
||||
Coroutine pauseMainBehaviorCoroutine;
|
||||
|
||||
float lastTimeChangeAbility;
|
||||
|
||||
float timeToChangeAbility;
|
||||
|
||||
AIAbilityStatesInfo currentAIAbilityStatesInfo;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (systemActive) {
|
||||
systemActive = false;
|
||||
|
||||
setSystemActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAI ()
|
||||
{
|
||||
if (systemActive) {
|
||||
AIPaused = mainFindObjectivesSystem.isAIPaused ();
|
||||
|
||||
if (!AIPaused) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetStates ()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateInsideMinDistance (bool newInsideMinDistanceToAttack)
|
||||
{
|
||||
insideMinDistanceToAttack = newInsideMinDistanceToAttack;
|
||||
|
||||
if (insideMinDistanceToAttack) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBehavior ()
|
||||
{
|
||||
if (!systemActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AIPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (turnBasedCombatActionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkAttackState ();
|
||||
}
|
||||
|
||||
public void checkAttackState ()
|
||||
{
|
||||
if (!attackEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
insideMinDistanceToAttack = mainFindObjectivesSystem.insideMinDistanceToAttack;
|
||||
|
||||
if (!insideMinDistanceToAttack && currentAIAbilityInfoAssigned && !currentAIAbilityInfo.ignoreInsideMinDistanceToAttackTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPauseAttackStateDuration > 0) {
|
||||
if (Time.time > currentPauseAttackStateDuration + lastTimeAttackPauseWithDuration) {
|
||||
|
||||
attackStatePaused = false;
|
||||
|
||||
currentPauseAttackStateDuration = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (waitToActivateAttackActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (turnBasedCombatActionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canUseAttackActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mainFindObjectivesSystem.isOnSpotted ()) {
|
||||
if (!onSpotted) {
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
onSpotted = true;
|
||||
}
|
||||
} else {
|
||||
if (onSpotted) {
|
||||
|
||||
onSpotted = false;
|
||||
|
||||
checkingToChangeAbilityActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (onSpotted) {
|
||||
if (changeAbilityAfterTimeEnabled && !abilityInProcess) {
|
||||
if (!checkingToChangeAbilityActive) {
|
||||
lastTimeChangeAbility = Time.time;
|
||||
|
||||
checkingToChangeAbilityActive = true;
|
||||
|
||||
timeToChangeAbility = Random.Range (randomChangeAbilityRate.x, randomChangeAbilityRate.y);
|
||||
} else {
|
||||
if (Time.time > lastTimeChangeAbility + timeToChangeAbility) {
|
||||
setNextAbility ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Time.time > currentAttackRate + lastTimeAttackActivated && !abilityInProcess) {
|
||||
bool checkDistanceConditionResult = false;
|
||||
|
||||
mainFindObjectivesSystem.updateCurrentPathDistanceToTargetValue ();
|
||||
|
||||
currentPathDistanceToTarget = mainFindObjectivesSystem.currentPathDistanceToTarget;
|
||||
|
||||
if (currentPathDistanceToTarget < 1) {
|
||||
currentPathDistanceToTarget = mainFindObjectivesSystem.getDistanceToTarget ();
|
||||
}
|
||||
|
||||
if (currentPathDistanceToTarget <= currentMinDistanceToAttack) {
|
||||
if (currentAIAbilityInfo.checkVerticalDistanceToTarget) {
|
||||
float verticalDistanceToCurrentEnemyPosition = mainFindObjectivesSystem.getVerticalDistanceToCurrentEnemyPosition ();
|
||||
|
||||
if (verticalDistanceToCurrentEnemyPosition != 0) {
|
||||
if (verticalDistanceToCurrentEnemyPosition < currentAIAbilityInfo.maxVerticalDistanceToTarget) {
|
||||
checkDistanceConditionResult = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checkDistanceConditionResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkUseAbilityConditionResult = false;
|
||||
|
||||
if (checkDistanceConditionResult) {
|
||||
if (mainFindObjectivesSystem.checkIfMinimumAngleToAttack () &&
|
||||
!mainPlayerController.isActionActive () &&
|
||||
mainPlayerController.canPlayerMove ()) {
|
||||
|
||||
checkUseAbilityConditionResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkUseAbilityConditionResult) {
|
||||
|
||||
bool canActivateAbilityResult = true;
|
||||
|
||||
if (currentAIAbilityInfo.useCustomAbilityDistance) {
|
||||
if (currentPathDistanceToTarget > currentAIAbilityInfo.customAbilityDistance) {
|
||||
canActivateAbilityResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAbilityResult) {
|
||||
if (mainFindObjectivesSystem.isAIBehaviorAttackInProcess ()) {
|
||||
if (showDebugPrint) {
|
||||
print ("attack in process in current main behavior, cancelling ability action");
|
||||
}
|
||||
|
||||
canActivateAbilityResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAbilityResult) {
|
||||
if (mainFindObjectivesSystem.isAIPaused ()) {
|
||||
canActivateAbilityResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAbilityResult) {
|
||||
if (currentAIAbilityInfo.sendSignalToActivateAbilityEnabled) {
|
||||
if (mainPlayerAbilitiesSystem.checkIfAbilitiesOnUseOrCooldown (currentAIAbilityInfo.Name)) {
|
||||
canActivateAbilityResult = false;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("current ability to use is on cool down, cancelling its usage " + currentAIAbilityInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAbilityResult) {
|
||||
if (showDebugPrint) {
|
||||
print (currentPathDistanceToTarget + " " + mainAINavmeshManager.getCurrentTarget ().name);
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useProbabilityToUseAbility) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability > currentAIAbilityInfo.probabilityToUseAbility) {
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("probability to activate ability failed, cancelling");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
attackTarget ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activate ability attack " + currentAttackRate);
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useCustomRandomAttackRangeRate) {
|
||||
currentAttackRate = Random.Range (currentAIAbilityInfo.customRandomAttackRangeRate.x, currentAIAbilityInfo.customRandomAttackRangeRate.y);
|
||||
} else {
|
||||
currentAttackRate = Random.Range (randomAttackRangeRate.x, randomAttackRangeRate.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setChangeAbilityAfterTimeEnabledState (bool state)
|
||||
{
|
||||
changeAbilityAfterTimeEnabled = state;
|
||||
}
|
||||
|
||||
public void setNextAbility ()
|
||||
{
|
||||
bool newAbilityIndexFound = false;
|
||||
|
||||
int previuosAbilityIndex = currentAbilityIndex;
|
||||
|
||||
int newAbilityIndex = -1;
|
||||
|
||||
int loopCount = 0;
|
||||
|
||||
if (changeAbilityRandomly) {
|
||||
while (!newAbilityIndexFound) {
|
||||
|
||||
if (useCustomListToChangeAbility) {
|
||||
if (useCustomListToChangeAbilityInfoList) {
|
||||
int currentIndex = customListToChangeAbilityInfoList.FindIndex (s => s.isCustomListActive == true);
|
||||
|
||||
if (currentIndex > -1) {
|
||||
newAbilityIndex = Random.Range (0, customListToChangeAbilityInfoList [currentIndex].customListToChangeAbility.Count);
|
||||
|
||||
string temporalAbilityName = customListToChangeAbilityInfoList [currentIndex].customListToChangeAbility [newAbilityIndex];
|
||||
|
||||
newAbilityIndex = AIAbilityInfoList.FindIndex (s => s.Name.Equals (temporalAbilityName));
|
||||
|
||||
if (newAbilityIndex < 0) {
|
||||
newAbilityIndex = 0;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting new ability index " + newAbilityIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newAbilityIndex = Random.Range (0, customListToChangeAbility.Count);
|
||||
|
||||
string temporalAbilityName = customListToChangeAbility [newAbilityIndex];
|
||||
|
||||
newAbilityIndex = AIAbilityInfoList.FindIndex (s => s.Name.Equals (temporalAbilityName));
|
||||
|
||||
if (newAbilityIndex < 0) {
|
||||
newAbilityIndex = 0;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting new ability index " + newAbilityIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newAbilityIndex = Random.Range (0, AIAbilityInfoList.Count);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting new ability index " + newAbilityIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (newAbilityIndex != currentAbilityIndex) {
|
||||
if (AIAbilityInfoList [newAbilityIndex].useAbilityEnabled) {
|
||||
newAbilityIndexFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
loopCount++;
|
||||
|
||||
if (loopCount > AIAbilityInfoList.Count * 4) {
|
||||
newAbilityIndexFound = true;
|
||||
|
||||
newAbilityIndex = previuosAbilityIndex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newAbilityIndex = currentAbilityIndex;
|
||||
|
||||
while (!newAbilityIndexFound) {
|
||||
newAbilityIndex++;
|
||||
|
||||
if (newAbilityIndex >= AIAbilityInfoList.Count) {
|
||||
newAbilityIndex = 0;
|
||||
}
|
||||
|
||||
if (AIAbilityInfoList [newAbilityIndex].useAbilityEnabled) {
|
||||
newAbilityIndexFound = true;
|
||||
}
|
||||
|
||||
loopCount++;
|
||||
|
||||
if (loopCount > AIAbilityInfoList.Count * 4) {
|
||||
newAbilityIndexFound = true;
|
||||
|
||||
newAbilityIndex = previuosAbilityIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newAbilityIndex > -1) {
|
||||
setNewAbilityByName (AIAbilityInfoList [newAbilityIndex].Name);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("changing ability to " + AIAbilityInfoList [newAbilityIndex].Name);
|
||||
}
|
||||
}
|
||||
|
||||
checkingToChangeAbilityActive = false;
|
||||
}
|
||||
|
||||
public void updateAIAttackState (bool newCanUseAttackActiveState)
|
||||
{
|
||||
canUseAttackActive = newCanUseAttackActiveState;
|
||||
}
|
||||
|
||||
public void setSystemEnabledState (bool state)
|
||||
{
|
||||
if (systemEnabled == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
systemEnabled = state;
|
||||
|
||||
setSystemActiveState (systemEnabled);
|
||||
}
|
||||
|
||||
public void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!systemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (systemActive == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
systemActive = state;
|
||||
|
||||
if (systemActive) {
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
setNewAbilityByName (AIAbilityInfoList [currentAbilityIndex].Name);
|
||||
|
||||
setNewAbilityStateByName (AIAbilityStatesInfoList [currentAbilityStateIndex].Name);
|
||||
|
||||
if (currentAIAbilityInfo.useCustomRandomAttackRangeRate) {
|
||||
currentAttackRate = Random.Range (currentAIAbilityInfo.customRandomAttackRangeRate.x, currentAIAbilityInfo.customRandomAttackRangeRate.y);
|
||||
} else {
|
||||
currentAttackRate = Random.Range (randomAttackRangeRate.x, randomAttackRangeRate.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onSpotted = false;
|
||||
|
||||
checkingToChangeAbilityActive = false;
|
||||
|
||||
checkEventsOnCombatStateChange (systemActive);
|
||||
|
||||
waitToActivateAttackActive = false;
|
||||
|
||||
waitToActivateAttackActiveCounter = 0;
|
||||
}
|
||||
|
||||
void checkEventsOnCombatStateChange (bool state)
|
||||
{
|
||||
if (useEventsOnCombatActive) {
|
||||
if (state) {
|
||||
eventOnCombatActive.Invoke ();
|
||||
} else {
|
||||
eventOnCombatDeactivate.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseAttackDuringXTime (float newDuration)
|
||||
{
|
||||
currentPauseAttackStateDuration = newDuration;
|
||||
|
||||
lastTimeAttackPauseWithDuration = Time.time;
|
||||
|
||||
attackStatePaused = true;
|
||||
}
|
||||
|
||||
public void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
if (!changeWaitToActivateAttackEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (useWaitToActivateAttackActiveCounter) {
|
||||
if (state) {
|
||||
waitToActivateAttackActiveCounter++;
|
||||
} else {
|
||||
waitToActivateAttackActiveCounter--;
|
||||
|
||||
if (waitToActivateAttackActiveCounter < 0) {
|
||||
waitToActivateAttackActiveCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (waitToActivateAttackActiveCounter > 0) {
|
||||
if (waitToActivateAttackActive) {
|
||||
return;
|
||||
} else {
|
||||
state = true;
|
||||
}
|
||||
} else {
|
||||
if (!waitToActivateAttackActive) {
|
||||
return;
|
||||
} else {
|
||||
state = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
waitToActivateAttackActive = state;
|
||||
}
|
||||
|
||||
public void resetBehaviorStates ()
|
||||
{
|
||||
resetStates ();
|
||||
|
||||
waitingForAttackActive = false;
|
||||
|
||||
|
||||
|
||||
insideMinDistanceToAttack = false;
|
||||
}
|
||||
|
||||
public void attackTarget ()
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("activate ability attack");
|
||||
}
|
||||
|
||||
stopPauseMainAttackBehaviorCoroutine ();
|
||||
|
||||
pauseMainBehaviorCoroutine = StartCoroutine (pauseMainAttackBehaviorCoroutine ());
|
||||
|
||||
abilityInProcess = true;
|
||||
|
||||
if (currentAIAbilityInfo.abilityInputHoldType || currentAIAbilityInfo.abilityInputToggleType) {
|
||||
stopAbilityInputHoldCoroutine ();
|
||||
|
||||
abilityCoroutine = StartCoroutine (abilityInputHoldCoroutine ());
|
||||
} else {
|
||||
if (currentAIAbilityInfo.sendSignalToActivateAbilityEnabled) {
|
||||
mainPlayerAbilitiesSystem.inputSelectAndPressDownNewAbility (currentAIAbilityInfo.Name);
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useEventsOnAbility) {
|
||||
currentAIAbilityInfo.eventOnAbilityStart.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stopAbilityInputHoldCoroutine ()
|
||||
{
|
||||
if (abilityCoroutine != null) {
|
||||
StopCoroutine (abilityCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator abilityInputHoldCoroutine ()
|
||||
{
|
||||
if (currentAIAbilityInfo.sendSignalToActivateAbilityEnabled) {
|
||||
mainPlayerAbilitiesSystem.inputSelectAndPressDownNewSeparatedAbility (currentAIAbilityInfo.Name);
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useEventsOnAbility) {
|
||||
currentAIAbilityInfo.eventOnAbilityStart.Invoke ();
|
||||
}
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentAIAbilityInfo.timeToHoldAndReleaseAbilityInput);
|
||||
|
||||
yield return delay;
|
||||
|
||||
if (currentAIAbilityInfo.sendSignalToActivateAbilityEnabled) {
|
||||
if (currentAIAbilityInfo.abilityInputHoldType) {
|
||||
mainPlayerAbilitiesSystem.inputSelectAndPressUpNewSeparatedAbility ();
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.abilityInputToggleType) {
|
||||
mainPlayerAbilitiesSystem.inputSelectAndPressDownNewSeparatedAbility (currentAIAbilityInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useEventsOnAbility) {
|
||||
currentAIAbilityInfo.eventOnAbilityEnd.Invoke ();
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
void stopPauseMainAttackBehaviorCoroutine ()
|
||||
{
|
||||
if (pauseMainBehaviorCoroutine != null) {
|
||||
StopCoroutine (pauseMainBehaviorCoroutine);
|
||||
}
|
||||
|
||||
mainFindObjectivesSystem.setBehaviorStatesPausedState (false);
|
||||
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
abilityInProcess = false;
|
||||
}
|
||||
|
||||
IEnumerator pauseMainAttackBehaviorCoroutine ()
|
||||
{
|
||||
mainFindObjectivesSystem.setBehaviorStatesPausedState (true);
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentAIAbilityInfo.abilityDuration);
|
||||
|
||||
yield return delay;
|
||||
|
||||
mainFindObjectivesSystem.setBehaviorStatesPausedState (false);
|
||||
|
||||
abilityInProcess = false;
|
||||
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
public void resetAttackState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void disableOnSpottedState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setAndActivateAbilityByName (string abilityName)
|
||||
{
|
||||
setNewAbilityByName (abilityName);
|
||||
|
||||
attackTarget ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activate ability attack " + currentAttackRate);
|
||||
}
|
||||
|
||||
if (currentAIAbilityInfo.useCustomRandomAttackRangeRate) {
|
||||
currentAttackRate = Random.Range (currentAIAbilityInfo.customRandomAttackRangeRate.x, currentAIAbilityInfo.customRandomAttackRangeRate.y);
|
||||
} else {
|
||||
currentAttackRate = Random.Range (randomAttackRangeRate.x, randomAttackRangeRate.y);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewAbilityByName (string abilityName)
|
||||
{
|
||||
if (!systemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newAbilityIndex = AIAbilityInfoList.FindIndex (s => s.Name.Equals (abilityName));
|
||||
|
||||
if (newAbilityIndex > -1) {
|
||||
if (currentAIAbilityInfo != null) {
|
||||
currentAIAbilityInfo.isCurrentAbility = false;
|
||||
}
|
||||
|
||||
currentAIAbilityInfo = AIAbilityInfoList [newAbilityIndex];
|
||||
|
||||
currentAIAbilityInfo.isCurrentAbility = true;
|
||||
|
||||
currentAIAbilityInfoAssigned = true;
|
||||
|
||||
currentAbilityIndex = newAbilityIndex;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting current ability index " + currentAbilityIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewMinDistanceToAttack (float newValue)
|
||||
{
|
||||
currentMinDistanceToAttack = newValue;
|
||||
}
|
||||
|
||||
public void setNewAbilityStateByName (string abilityStateName)
|
||||
{
|
||||
if (!systemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newAbilityStateIndex = AIAbilityStatesInfoList.FindIndex (s => s.Name.Equals (abilityStateName));
|
||||
|
||||
if (newAbilityStateIndex > -1) {
|
||||
if (currentAIAbilityStatesInfo != null) {
|
||||
currentAIAbilityStatesInfo.isCurrentState = false;
|
||||
}
|
||||
|
||||
currentAIAbilityStatesInfo = AIAbilityStatesInfoList [newAbilityStateIndex];
|
||||
|
||||
currentAIAbilityStatesInfo.isCurrentState = true;
|
||||
|
||||
currentMinDistanceToAttack = currentAIAbilityStatesInfo.minDistanceToAttack;
|
||||
|
||||
currentAbilityStateIndex = newAbilityStateIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopCurrentAttackInProcess ()
|
||||
{
|
||||
if (abilityInProcess) {
|
||||
stopPauseMainAttackBehaviorCoroutine ();
|
||||
|
||||
stopAbilityInputHoldCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
turnBasedCombatActionActive = state;
|
||||
}
|
||||
|
||||
public bool isAbilityInProcess ()
|
||||
{
|
||||
return abilityInProcess;
|
||||
}
|
||||
|
||||
public void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setChangeAbilityRandomlyState (bool state)
|
||||
{
|
||||
changeAbilityRandomly = state;
|
||||
}
|
||||
|
||||
public void setUseCustomListToChangeAbilityState (bool state)
|
||||
{
|
||||
useCustomListToChangeAbility = state;
|
||||
}
|
||||
|
||||
public void setCustomListToChangeAbility (List<string> newList)
|
||||
{
|
||||
customListToChangeAbility = newList;
|
||||
}
|
||||
|
||||
public void setUseCustomListToChangeAbilityInfoListState (bool state)
|
||||
{
|
||||
useCustomListToChangeAbilityInfoList = state;
|
||||
}
|
||||
|
||||
public void setCustomListToChangeAbilityInfoListByName (string newName)
|
||||
{
|
||||
for (int i = 0; i < customListToChangeAbilityInfoList.Count; i++) {
|
||||
if (customListToChangeAbilityInfoList [i].Name.Equals (newName)) {
|
||||
customListToChangeAbilityInfoList [i].isCustomListActive = true;
|
||||
} else {
|
||||
customListToChangeAbilityInfoList [i].isCustomListActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttackEnabledState (bool state)
|
||||
{
|
||||
attackEnabled = state;
|
||||
}
|
||||
|
||||
public void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setAttackEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update AI Abilities Brain " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AIAbilityInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
|
||||
public bool useAbilityEnabled = true;
|
||||
|
||||
public bool isCurrentAbility;
|
||||
|
||||
public bool sendSignalToActivateAbilityEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useProbabilityToUseAbility;
|
||||
[Range (0, 100)] public float probabilityToUseAbility;
|
||||
|
||||
[Space]
|
||||
[Header ("Distance Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCustomAbilityDistance;
|
||||
public float customAbilityDistance;
|
||||
|
||||
public bool checkVerticalDistanceToTarget;
|
||||
public float maxVerticalDistanceToTarget;
|
||||
|
||||
public bool ignoreInsideMinDistanceToAttackTarget;
|
||||
|
||||
[Space]
|
||||
[Header ("Ability Settings")]
|
||||
[Space]
|
||||
|
||||
public bool abilityInputHoldType;
|
||||
|
||||
public bool abilityInputToggleType;
|
||||
|
||||
public float timeToHoldAndReleaseAbilityInput;
|
||||
|
||||
public float abilityDuration;
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Random Attack Range Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useCustomRandomAttackRangeRate;
|
||||
|
||||
public Vector2 customRandomAttackRangeRate;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnAbility;
|
||||
|
||||
public UnityEvent eventOnAbilityStart;
|
||||
|
||||
public UnityEvent eventOnAbilityEnd;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AIAbilityStatesInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public float minDistanceToAttack = 7;
|
||||
|
||||
public bool isCurrentState;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class customListToChangeAbilityInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool isCustomListActive;
|
||||
|
||||
public List<string> customListToChangeAbility = new List<string> ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d5e45b268828c3499ed6c35d1ce8818
|
||||
timeCreated: 1647942690
|
||||
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/AI/Custom AI Behavior/AIAbilitiesSystemBrain.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,297 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AIAimRotationManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool AIAimRotationEnabled = true;
|
||||
|
||||
public bool setAIAimRotationStateOnAwake;
|
||||
|
||||
public string AIAimRotationStateOnAwakeName;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Aim Rotation States List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<AIAimRotationInfo> AIAimRotationInfoList = new List<AIAimRotationInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool randomAimPositionOffsetActive;
|
||||
public string currentAIAimRotationInfoName;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerCamera mainPlayerCamera;
|
||||
public playerController mainPlayerController;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
|
||||
|
||||
float lastTimeRandomAimPositionOffsetActive = 0;
|
||||
|
||||
float currentWaitTimeRandomAimPositionOffset;
|
||||
float currentRandomAimPositionOffset;
|
||||
float currentRandomAimPositionOffsetDuration;
|
||||
|
||||
float currentMinRandomAimPositionOffset;
|
||||
|
||||
bool currentUseMinRandomAimPositionOffset;
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
Vector2 randomAimPositionOffsetRange;
|
||||
Vector2 randomAimPositionOffsetDurationRange;
|
||||
Vector2 randomAimPositionOffsetWaitRange;
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
if (setAIAimRotationStateOnAwake) {
|
||||
setAIAImRotationState (AIAimRotationStateOnAwakeName);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
|
||||
randomAimPositionOffsetActive = false;
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (!randomAimPositionOffsetActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainFindObjectivesSystem.isOnSpotted ()) {
|
||||
if (currentWaitTimeRandomAimPositionOffset != 0) {
|
||||
if (showDebugPrint) {
|
||||
print ("character is not attacking a target, reseting random aim position offset state");
|
||||
}
|
||||
|
||||
disableAndResetRandomAimPositionValues ();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentWaitTimeRandomAimPositionOffset == 0) {
|
||||
currentWaitTimeRandomAimPositionOffset = Random.Range (randomAimPositionOffsetWaitRange.x, randomAimPositionOffsetWaitRange.y);
|
||||
|
||||
currentRandomAimPositionOffset = Random.Range (randomAimPositionOffsetRange.x, randomAimPositionOffsetRange.y);
|
||||
|
||||
if (currentUseMinRandomAimPositionOffset) {
|
||||
if (currentMinRandomAimPositionOffset != 0) {
|
||||
if (currentRandomAimPositionOffset > 0) {
|
||||
if (currentRandomAimPositionOffset < currentMinRandomAimPositionOffset) {
|
||||
currentRandomAimPositionOffset = currentMinRandomAimPositionOffset;
|
||||
}
|
||||
} else {
|
||||
if (Mathf.Abs (currentRandomAimPositionOffset) < currentMinRandomAimPositionOffset) {
|
||||
currentRandomAimPositionOffset = -currentMinRandomAimPositionOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastTimeRandomAimPositionOffsetActive = Time.time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("select wait time " + currentWaitTimeRandomAimPositionOffset);
|
||||
}
|
||||
} else {
|
||||
if (Time.time > lastTimeRandomAimPositionOffsetActive + currentWaitTimeRandomAimPositionOffset) {
|
||||
if (currentRandomAimPositionOffsetDuration == 0) {
|
||||
currentRandomAimPositionOffsetDuration = Random.Range (randomAimPositionOffsetDurationRange.x, randomAimPositionOffsetDurationRange.y);
|
||||
|
||||
mainFindObjectivesSystem.addLookDirectionToTargetOffset (currentRandomAimPositionOffset);
|
||||
|
||||
lastTimeRandomAimPositionOffsetActive = Time.time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("select offset duration " + currentRandomAimPositionOffsetDuration);
|
||||
|
||||
print ("current random position offset " + currentRandomAimPositionOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRandomAimPositionOffsetDuration != 0) {
|
||||
if (Time.time > lastTimeRandomAimPositionOffsetActive + currentRandomAimPositionOffsetDuration) {
|
||||
disableAndResetRandomAimPositionValues ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void disableAndResetRandomAimPositionValues ()
|
||||
{
|
||||
mainFindObjectivesSystem.addLookDirectionToTargetOffset (0);
|
||||
|
||||
lastTimeRandomAimPositionOffsetActive = Time.time;
|
||||
|
||||
currentWaitTimeRandomAimPositionOffset = 0;
|
||||
|
||||
currentRandomAimPositionOffsetDuration = 0;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("reset values");
|
||||
}
|
||||
}
|
||||
|
||||
public void setAIAImRotationState (string stateName)
|
||||
{
|
||||
if (!AIAimRotationEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newIndex = AIAimRotationInfoList.FindIndex (s => s.Name.Equals (stateName));
|
||||
|
||||
if (newIndex > -1) {
|
||||
AIAimRotationInfo currentInfo = AIAimRotationInfoList [newIndex];
|
||||
|
||||
if (currentInfo.stateEnabled) {
|
||||
currentAIAimRotationInfoName = currentInfo.Name;
|
||||
|
||||
mainPlayerCamera.changeRotationSpeedValue (currentInfo.verticalAimRotationSpeed, currentInfo.horizontalAimRotationSpeed);
|
||||
|
||||
mainPlayerCamera.updateOriginalRotationSpeedValues ();
|
||||
|
||||
if (currentInfo.setRotateDirectlyTowardCameraOnStrafe) {
|
||||
mainPlayerController.setRotateDirectlyTowardCameraOnStrafeState (currentInfo.rotateDirectlyTowardCameraOnStrafe);
|
||||
}
|
||||
|
||||
if (currentInfo.setLookAtTargetSpeed) {
|
||||
mainFindObjectivesSystem.setLookAtTargetSpeedValue (currentInfo.lookAtTargetSpeed);
|
||||
}
|
||||
|
||||
if (currentInfo.setAutoTurnSpeed) {
|
||||
mainPlayerController.setAutoTurnSpeed (currentInfo.autoTurnSpeed);
|
||||
}
|
||||
|
||||
if (currentInfo.setAimTurnSpeed) {
|
||||
mainPlayerController.setAimTurnSpeed (currentInfo.aimTurnSpeed);
|
||||
}
|
||||
|
||||
if (randomAimPositionOffsetActive) {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
|
||||
if (currentInfo.addRandomAimPositionOffset) {
|
||||
randomAimPositionOffsetActive = true;
|
||||
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
|
||||
randomAimPositionOffsetRange = currentInfo.randomAimPositionOffsetRange;
|
||||
randomAimPositionOffsetDurationRange = currentInfo.randomAimPositionOffsetDurationRange;
|
||||
randomAimPositionOffsetWaitRange = currentInfo.randomAimPositionOffsetWaitRange;
|
||||
|
||||
currentMinRandomAimPositionOffset = currentInfo.minRandomAimPositionOffset;
|
||||
|
||||
currentUseMinRandomAimPositionOffset = currentInfo.useMinRandomAimPositionOffset;
|
||||
|
||||
lastTimeRandomAimPositionOffsetActive = 0;
|
||||
|
||||
currentWaitTimeRandomAimPositionOffset = 0;
|
||||
} else {
|
||||
mainFindObjectivesSystem.addLookDirectionToTargetOffset (0);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setting aim state " + currentAIAimRotationInfoName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAIAimRotationEnabledState (bool state)
|
||||
{
|
||||
AIAimRotationEnabled = state;
|
||||
}
|
||||
|
||||
public void setAIAimRotationEnabledStateFromEditor (bool state)
|
||||
{
|
||||
setAIAimRotationEnabledState (state);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update AI Aim Rotation Manager " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class AIAimRotationInfo
|
||||
{
|
||||
[Header ("Aiming Rotation Speed Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
public bool stateEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setAimRotationSpeed;
|
||||
public float verticalAimRotationSpeed;
|
||||
public float horizontalAimRotationSpeed;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setRotateDirectlyTowardCameraOnStrafe;
|
||||
public bool rotateDirectlyTowardCameraOnStrafe;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setLookAtTargetSpeed;
|
||||
public float lookAtTargetSpeed;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setAutoTurnSpeed;
|
||||
public float autoTurnSpeed;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool setAimTurnSpeed;
|
||||
public float aimTurnSpeed;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool addRandomAimPositionOffset;
|
||||
public Vector2 randomAimPositionOffsetDurationRange;
|
||||
public Vector2 randomAimPositionOffsetWaitRange;
|
||||
|
||||
[Space]
|
||||
|
||||
public Vector2 randomAimPositionOffsetRange;
|
||||
|
||||
public bool useMinRandomAimPositionOffset;
|
||||
public float minRandomAimPositionOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8ff7c64b9614fb40b7e893bfe0a7d4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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/AI/Custom AI Behavior/AIAimRotationManager.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a211c0e08aff4084091a706dc1375518
|
||||
timeCreated: 1620622963
|
||||
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/AI/Custom AI Behavior/AIFireWeaponsSystemBrain.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 654eeb5ecbdc8874bb991b0b9d93bde9
|
||||
timeCreated: 1647925717
|
||||
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/AI/Custom AI Behavior/AIPowersSystemBrain.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,888 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class AITurnBasedCombatSystemBrain : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool systemEnabled = true;
|
||||
|
||||
|
||||
public bool checkDistanceToTargetEnabled;
|
||||
|
||||
public float currentMinDistanceToAttack = 7;
|
||||
|
||||
public float defaultMatchOffset = 1;
|
||||
|
||||
[Space]
|
||||
[Header ("Attack Settings")]
|
||||
[Space]
|
||||
|
||||
public bool attackEnabled;
|
||||
|
||||
public float minWaitToActivateAttack = 0.5f;
|
||||
|
||||
public bool useProbabilityToUseAttack;
|
||||
[Range (0, 100)] public float probabilityToUseAttack;
|
||||
|
||||
public bool ignoreProbabilityToCheckCategory;
|
||||
public bool ignoreProbabilityToUseAttack;
|
||||
|
||||
public bool ignoreUseStatToUseAction;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool ignoreIfLastCategoryPreviouslySelected;
|
||||
|
||||
public bool ignoreIfLastAttackPreviouslySelected;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatAttackCategoryInfo> turnBasedCombatAttackCategoryInfoList = new List<turnBasedCombatAttackCategoryInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool systemActive;
|
||||
|
||||
public bool isCurrentCharacterTurn;
|
||||
|
||||
public bool AIOnPlayerTeam;
|
||||
|
||||
[Space]
|
||||
|
||||
public int lastAttackUsedIndex = -1;
|
||||
|
||||
public int lastCategoryIndex = -1;
|
||||
|
||||
public bool currentAttackInProcess;
|
||||
|
||||
public bool delayToActiveteAttackInProcess;
|
||||
|
||||
public string currentCommandName;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool waitingForAttackActive;
|
||||
float currentRandomTimeToAttack;
|
||||
|
||||
public bool canUseAttackActive;
|
||||
|
||||
public bool attackStatePaused;
|
||||
|
||||
public bool insideMinDistanceToAttack;
|
||||
|
||||
// public float currentAttackRate;
|
||||
|
||||
// public bool onSpotted;
|
||||
|
||||
public bool waitToActivateAttackActive;
|
||||
|
||||
public bool blockActive;
|
||||
|
||||
public GameObject currentTarget;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnCombatActive;
|
||||
public UnityEvent eventOnCombatActive;
|
||||
public UnityEvent eventOnCombatDeactivate;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventIfBlockActiveOnCurrentTurn;
|
||||
public UnityEvent eventIfBlockActiveOnCurrentTurn;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AINavMesh mainAINavmeshManager;
|
||||
|
||||
public playerController mainPlayerController;
|
||||
|
||||
public characterToReceiveOrders mainCharacterToReceiveOrders;
|
||||
|
||||
public turnBasedCombatActionsSystem mainTurnBasedCombatActionsSystem;
|
||||
|
||||
public matchPlayerToTargetSystem mainMatchPlayerToTargetSystem;
|
||||
|
||||
public playerStatsSystem mainPlayerStatsSystem;
|
||||
|
||||
public health mainHealth;
|
||||
|
||||
|
||||
float lastTimeAttack;
|
||||
|
||||
int currentAttackTypeIndex;
|
||||
|
||||
int currentAttackIndex;
|
||||
|
||||
int currentAttackTypeToAlternateIndex;
|
||||
|
||||
float currentPauseAttackStateDuration;
|
||||
float lastTimeAttackPauseWithDuration;
|
||||
|
||||
float randomWaitTime;
|
||||
|
||||
float lastTimeAttackActivated;
|
||||
|
||||
float currentPathDistanceToTarget;
|
||||
|
||||
bool AIPaused;
|
||||
|
||||
turnBasedCombatAttackInfo currentTurnBasedCombatAttackInfo;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (systemActive) {
|
||||
systemActive = false;
|
||||
|
||||
setSystemActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAI ()
|
||||
{
|
||||
if (systemActive) {
|
||||
AIPaused = mainFindObjectivesSystem.isAIPaused ();
|
||||
|
||||
if (!AIPaused) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkStateOnCharacterDead ()
|
||||
{
|
||||
if (systemActive) {
|
||||
if (isCurrentCharacterTurn) {
|
||||
if (mainPlayerController.checkIfPlayerDeadFromHealthComponent ()) {
|
||||
if (showDebugPrint) {
|
||||
print ("current character in turn has dead, moving turn to next character");
|
||||
}
|
||||
|
||||
setNextTurn ();
|
||||
|
||||
currentAttackInProcess = false;
|
||||
|
||||
isCurrentCharacterTurn = false;
|
||||
|
||||
delayToActiveteAttackInProcess = false;
|
||||
}
|
||||
} else {
|
||||
mainTurnBasedCombatActionsSystem.checkTeamsDeadStateAfterCharacterDeath ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetStates ()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateInsideMinDistance (bool newInsideMinDistanceToAttack)
|
||||
{
|
||||
insideMinDistanceToAttack = newInsideMinDistanceToAttack;
|
||||
|
||||
if (insideMinDistanceToAttack) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBehavior ()
|
||||
{
|
||||
if (!systemActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AIPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentPathDistanceToTarget = mainFindObjectivesSystem.currentPathDistanceToTarget;
|
||||
|
||||
checkAttackState ();
|
||||
}
|
||||
|
||||
public void checkAttackState ()
|
||||
{
|
||||
if (!attackEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkDistanceToTargetEnabled) {
|
||||
insideMinDistanceToAttack = mainFindObjectivesSystem.insideMinDistanceToAttack;
|
||||
|
||||
if (!insideMinDistanceToAttack) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPauseAttackStateDuration > 0) {
|
||||
if (Time.time > currentPauseAttackStateDuration + lastTimeAttackPauseWithDuration) {
|
||||
|
||||
attackStatePaused = false;
|
||||
|
||||
currentPauseAttackStateDuration = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (waitToActivateAttackActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!canUseAttackActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (mainFindObjectivesSystem.isOnSpotted ()) {
|
||||
// if (!onSpotted) {
|
||||
// lastTimeAttackActivated = Time.time;
|
||||
//
|
||||
// onSpotted = true;
|
||||
// }
|
||||
// } else {
|
||||
// if (onSpotted) {
|
||||
//
|
||||
// onSpotted = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (onSpotted) {
|
||||
|
||||
if (AIOnPlayerTeam) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCurrentCharacterTurn) {
|
||||
if (currentAttackInProcess) {
|
||||
if (!delayToActiveteAttackInProcess) {
|
||||
if (!mainCharacterToReceiveOrders.isOrderInProcess ()) {
|
||||
setNextTurn ();
|
||||
|
||||
currentAttackInProcess = false;
|
||||
|
||||
isCurrentCharacterTurn = false;
|
||||
|
||||
delayToActiveteAttackInProcess = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Time.time > minWaitToActivateAttack + lastTimeAttackActivated) {
|
||||
if (!mainPlayerController.isActionActive () || blockActive) {
|
||||
bool canActivateAttackResult = true;
|
||||
|
||||
if (checkDistanceToTargetEnabled) {
|
||||
if (!mainPlayerController.canPlayerMove () || currentPathDistanceToTarget > currentMinDistanceToAttack ||
|
||||
!mainFindObjectivesSystem.checkIfMinimumAngleToAttack ()) {
|
||||
canActivateAttackResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAttackResult) {
|
||||
if (mainFindObjectivesSystem.isAIBehaviorAttackInProcess ()) {
|
||||
if (showDebugPrint) {
|
||||
print ("attack in process in current main behavior, cancelling action");
|
||||
}
|
||||
|
||||
canActivateAttackResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAttackResult) {
|
||||
if (mainFindObjectivesSystem.isAIPaused ()) {
|
||||
canActivateAttackResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAttackResult) {
|
||||
if (mainTurnBasedCombatActionsSystem.isAdjustingCharacterPositionInProcess ()) {
|
||||
canActivateAttackResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateAttackResult) {
|
||||
if (useProbabilityToUseAttack) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability > probabilityToUseAttack) {
|
||||
lastTimeAttackActivated = Time.time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("probability to activate attack failed, cancelling");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
attackTarget ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAIAttackState (bool newCanUseAttackActiveState)
|
||||
{
|
||||
canUseAttackActive = newCanUseAttackActiveState;
|
||||
}
|
||||
|
||||
public void setSystemEnabledState (bool state)
|
||||
{
|
||||
if (systemEnabled == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
systemEnabled = state;
|
||||
|
||||
setSystemActiveState (systemEnabled);
|
||||
}
|
||||
|
||||
public void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!systemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (systemActive == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
systemActive = state;
|
||||
|
||||
if (systemActive) {
|
||||
|
||||
|
||||
} else {
|
||||
isCurrentCharacterTurn = false;
|
||||
|
||||
currentAttackInProcess = false;
|
||||
|
||||
delayToActiveteAttackInProcess = false;
|
||||
|
||||
blockActive = false;
|
||||
}
|
||||
|
||||
// onSpotted = false;
|
||||
|
||||
checkEventsOnCombatStateChange (systemActive);
|
||||
}
|
||||
|
||||
void checkEventsOnCombatStateChange (bool state)
|
||||
{
|
||||
if (useEventsOnCombatActive) {
|
||||
if (state) {
|
||||
eventOnCombatActive.Invoke ();
|
||||
} else {
|
||||
eventOnCombatDeactivate.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseAttackDuringXTime (float newDuration)
|
||||
{
|
||||
currentPauseAttackStateDuration = newDuration;
|
||||
|
||||
lastTimeAttackPauseWithDuration = Time.time;
|
||||
|
||||
attackStatePaused = true;
|
||||
}
|
||||
|
||||
public void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
waitToActivateAttackActive = state;
|
||||
}
|
||||
|
||||
public void resetBehaviorStates ()
|
||||
{
|
||||
resetStates ();
|
||||
|
||||
waitingForAttackActive = false;
|
||||
|
||||
|
||||
|
||||
insideMinDistanceToAttack = false;
|
||||
}
|
||||
|
||||
public void attackTarget ()
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("activate attack");
|
||||
}
|
||||
|
||||
|
||||
int randomAttackCategoryIndex = Random.Range (0, turnBasedCombatAttackCategoryInfoList.Count);
|
||||
|
||||
turnBasedCombatAttackCategoryInfo currentTurnBasedCombatAttackCategoryInfo = turnBasedCombatAttackCategoryInfoList [randomAttackCategoryIndex];
|
||||
|
||||
bool checkCategoryResult = false;
|
||||
|
||||
if (!ignoreIfLastCategoryPreviouslySelected) {
|
||||
if (lastCategoryIndex == randomAttackCategoryIndex) {
|
||||
checkCategoryResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("category selected on previous attack, selecting new one");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentTurnBasedCombatAttackCategoryInfo.attackCategoryEnabled) {
|
||||
checkCategoryResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("category not enabled, selecting new index " + currentTurnBasedCombatAttackCategoryInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignoreProbabilityToCheckCategory) {
|
||||
if (currentTurnBasedCombatAttackCategoryInfo.useProbabilityToCheckCategory) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability > currentTurnBasedCombatAttackCategoryInfo.probabilityToCheckCategory) {
|
||||
checkCategoryResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("category probability not reached, selecting new index " + currentProbability);
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("category probability reached, selecting command in category " + currentTurnBasedCombatAttackCategoryInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkCategoryResult) {
|
||||
bool nextIndexFound = false;
|
||||
|
||||
int loopCount = 0;
|
||||
|
||||
while (!nextIndexFound) {
|
||||
randomAttackCategoryIndex = Random.Range (0, turnBasedCombatAttackCategoryInfoList.Count);
|
||||
|
||||
currentTurnBasedCombatAttackCategoryInfo = turnBasedCombatAttackCategoryInfoList [randomAttackCategoryIndex];
|
||||
|
||||
if (currentTurnBasedCombatAttackCategoryInfo.attackCategoryEnabled) {
|
||||
if (ignoreProbabilityToCheckCategory) {
|
||||
nextIndexFound = true;
|
||||
} else {
|
||||
if (currentTurnBasedCombatAttackCategoryInfo.useProbabilityToCheckCategory) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability < currentTurnBasedCombatAttackCategoryInfo.probabilityToCheckCategory) {
|
||||
nextIndexFound = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("category probability reached");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nextIndexFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loopCount++;
|
||||
|
||||
if (loopCount > 100) {
|
||||
nextIndexFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastCategoryIndex != randomAttackCategoryIndex) {
|
||||
if (showDebugPrint) {
|
||||
print ("selecting new category, reseting las attack used index");
|
||||
}
|
||||
|
||||
if (lastAttackUsedIndex != -1) {
|
||||
lastAttackUsedIndex = -1;
|
||||
}
|
||||
|
||||
lastCategoryIndex = randomAttackCategoryIndex;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("category selected " + currentTurnBasedCombatAttackCategoryInfo.Name);
|
||||
}
|
||||
|
||||
int turnBasedCombatAttackInfoListCount = currentTurnBasedCombatAttackCategoryInfo.turnBasedCombatAttackInfoList.Count;
|
||||
|
||||
int randomAttackIndex = Random.Range (0, turnBasedCombatAttackInfoListCount);
|
||||
|
||||
currentTurnBasedCombatAttackInfo = currentTurnBasedCombatAttackCategoryInfo.turnBasedCombatAttackInfoList [randomAttackIndex];
|
||||
|
||||
bool checkAttackIndexResult = true;
|
||||
|
||||
if (!ignoreIfLastAttackPreviouslySelected) {
|
||||
if (randomAttackIndex == lastAttackUsedIndex) {
|
||||
checkAttackIndexResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("already used on last command " + currentTurnBasedCombatAttackInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentTurnBasedCombatAttackInfo.attackEnabled) {
|
||||
checkAttackIndexResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("command not enabled " + currentTurnBasedCombatAttackInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignoreProbabilityToUseAttack) {
|
||||
if (currentTurnBasedCombatAttackInfo.useProbabilityToUseAttack) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability > currentTurnBasedCombatAttackInfo.probabilityToUseAttack) {
|
||||
checkAttackIndexResult = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("command probability not reached " + currentTurnBasedCombatAttackInfo.Name + " " + currentProbability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (checkAttackIndexResult) {
|
||||
bool nextIndexFound = false;
|
||||
|
||||
int loopCount = 0;
|
||||
|
||||
while (!nextIndexFound) {
|
||||
|
||||
randomAttackIndex = Random.Range (0, turnBasedCombatAttackInfoListCount);
|
||||
|
||||
if (randomAttackIndex != lastAttackUsedIndex) {
|
||||
currentTurnBasedCombatAttackInfo = currentTurnBasedCombatAttackCategoryInfo.turnBasedCombatAttackInfoList [randomAttackIndex];
|
||||
|
||||
if (currentTurnBasedCombatAttackInfo.attackEnabled) {
|
||||
if (ignoreProbabilityToUseAttack) {
|
||||
bool canActivateCommandResult = true;
|
||||
|
||||
if (!ignoreUseStatToUseAction) {
|
||||
if (currentTurnBasedCombatAttackInfo.useStatToUseAction) {
|
||||
if (mainPlayerStatsSystem.getStatValue (currentTurnBasedCombatAttackInfo.statNameToUseAction) <
|
||||
currentTurnBasedCombatAttackInfo.statAmountToUseAction) {
|
||||
canActivateCommandResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateCommandResult) {
|
||||
lastAttackUsedIndex = randomAttackIndex;
|
||||
|
||||
nextIndexFound = true;
|
||||
}
|
||||
} else {
|
||||
if (currentTurnBasedCombatAttackInfo.useProbabilityToUseAttack) {
|
||||
float currentProbability = Random.Range (0, 100);
|
||||
|
||||
if (currentProbability < currentTurnBasedCombatAttackCategoryInfo.probabilityToCheckCategory) {
|
||||
bool canActivateCommandResult = true;
|
||||
|
||||
if (!ignoreUseStatToUseAction) {
|
||||
if (currentTurnBasedCombatAttackInfo.useStatToUseAction) {
|
||||
if (mainPlayerStatsSystem.getStatValue (currentTurnBasedCombatAttackInfo.statNameToUseAction) <
|
||||
currentTurnBasedCombatAttackInfo.statAmountToUseAction) {
|
||||
canActivateCommandResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateCommandResult) {
|
||||
lastAttackUsedIndex = randomAttackIndex;
|
||||
|
||||
nextIndexFound = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("command probability reached " + currentProbability);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bool canActivateCommandResult = true;
|
||||
|
||||
if (!ignoreUseStatToUseAction) {
|
||||
if (currentTurnBasedCombatAttackInfo.useStatToUseAction) {
|
||||
if (mainPlayerStatsSystem.getStatValue (currentTurnBasedCombatAttackInfo.statNameToUseAction) <
|
||||
currentTurnBasedCombatAttackInfo.statAmountToUseAction) {
|
||||
canActivateCommandResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canActivateCommandResult) {
|
||||
lastAttackUsedIndex = randomAttackIndex;
|
||||
|
||||
nextIndexFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loopCount++;
|
||||
|
||||
if (loopCount > 100) {
|
||||
lastAttackUsedIndex = randomAttackIndex;
|
||||
|
||||
nextIndexFound = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastAttackUsedIndex = randomAttackIndex;
|
||||
}
|
||||
|
||||
currentTurnBasedCombatAttackInfo = currentTurnBasedCombatAttackCategoryInfo.turnBasedCombatAttackInfoList [lastAttackUsedIndex];
|
||||
|
||||
activateAttack ();
|
||||
}
|
||||
|
||||
void activateAttack ()
|
||||
{
|
||||
if (!ignoreUseStatToUseAction) {
|
||||
if (currentTurnBasedCombatAttackInfo.useStatToUseAction) {
|
||||
mainPlayerStatsSystem.usePlayerStat (currentTurnBasedCombatAttackInfo.statNameToUseAction,
|
||||
currentTurnBasedCombatAttackInfo.statAmountToUseAction);
|
||||
|
||||
mainTurnBasedCombatActionsSystem.updateAllCharacterStatsUIValue ();
|
||||
}
|
||||
}
|
||||
|
||||
currentCommandName = currentTurnBasedCombatAttackInfo.Name;
|
||||
|
||||
mainTurnBasedCombatActionsSystem.setCurrentCommandNameUsed (currentCommandName);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("current command selected " + currentCommandName);
|
||||
}
|
||||
|
||||
if (currentTurnBasedCombatAttackInfo.useMatchPositionSystem) {
|
||||
activateMatchPosition (currentTurnBasedCombatAttackInfo.matchPositionOffset);
|
||||
}
|
||||
|
||||
delayToActiveteAttackInProcess = false;
|
||||
|
||||
if (currentTurnBasedCombatAttackInfo.useDelayToActivateAttack) {
|
||||
stopDelaytToActivateAttackCoroutine ();
|
||||
|
||||
activateAttackCoroutine = StartCoroutine (delaytToActivateAttackCoroutine (currentTurnBasedCombatAttackInfo.delayToActivateAttack));
|
||||
} else {
|
||||
mainCharacterToReceiveOrders.activateOrder (currentCommandName);
|
||||
}
|
||||
|
||||
currentAttackInProcess = true;
|
||||
}
|
||||
|
||||
Coroutine activateAttackCoroutine;
|
||||
|
||||
IEnumerator delaytToActivateAttackCoroutine (float currentDelay)
|
||||
{
|
||||
delayToActiveteAttackInProcess = true;
|
||||
|
||||
WaitForSeconds delay = new WaitForSeconds (currentDelay);
|
||||
|
||||
yield return delay;
|
||||
|
||||
mainCharacterToReceiveOrders.activateOrder (currentCommandName);
|
||||
|
||||
delayToActiveteAttackInProcess = false;
|
||||
}
|
||||
|
||||
void stopDelaytToActivateAttackCoroutine ()
|
||||
{
|
||||
if (activateAttackCoroutine != null) {
|
||||
StopCoroutine (activateAttackCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
public void activateAttackByName (string attackName)
|
||||
{
|
||||
int turnBasedCombatAttackCategoryInfoListCount = turnBasedCombatAttackCategoryInfoList.Count;
|
||||
|
||||
for (int i = 0; i < turnBasedCombatAttackCategoryInfoListCount; i++) {
|
||||
if (turnBasedCombatAttackCategoryInfoList [i].attackCategoryEnabled) {
|
||||
int turnBasedCombatAttackInfoListCount = turnBasedCombatAttackCategoryInfoList [i].turnBasedCombatAttackInfoList.Count;
|
||||
|
||||
for (int j = 0; j < turnBasedCombatAttackInfoListCount; j++) {
|
||||
if (turnBasedCombatAttackCategoryInfoList [i].turnBasedCombatAttackInfoList [j].attackEnabled) {
|
||||
if (turnBasedCombatAttackCategoryInfoList [i].turnBasedCombatAttackInfoList [j].Name.Equals (attackName)) {
|
||||
currentTurnBasedCombatAttackInfo = turnBasedCombatAttackCategoryInfoList [i].turnBasedCombatAttackInfoList [j];
|
||||
|
||||
lastAttackUsedIndex = j;
|
||||
lastCategoryIndex = i;
|
||||
|
||||
activateAttack ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlockActiveState (bool state)
|
||||
{
|
||||
blockActive = state;
|
||||
}
|
||||
|
||||
public void resetAttackState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void disableOnSpottedState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setNewMinDistanceToAttack (float newValue)
|
||||
{
|
||||
currentMinDistanceToAttack = newValue;
|
||||
}
|
||||
|
||||
public void setAIOnPlayerTeamState (bool state)
|
||||
{
|
||||
AIOnPlayerTeam = state;
|
||||
}
|
||||
|
||||
public void setIsCurrentCharacterTurn (bool state)
|
||||
{
|
||||
isCurrentCharacterTurn = state;
|
||||
|
||||
if (isCurrentCharacterTurn) {
|
||||
mainFindObjectivesSystem.setAIPausedState (false);
|
||||
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystem (currentTarget);
|
||||
|
||||
lastTimeAttackActivated = Time.time;
|
||||
} else {
|
||||
mainFindObjectivesSystem.setAIPausedState (true);
|
||||
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystem (null);
|
||||
}
|
||||
|
||||
if (isCurrentCharacterTurn) {
|
||||
if (useEventIfBlockActiveOnCurrentTurn) {
|
||||
blockActive = mainHealth.isBlockDamageActiveState ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("block was active, calling event to disable state to activate turn combat attack");
|
||||
}
|
||||
|
||||
if (blockActive) {
|
||||
eventIfBlockActiveOnCurrentTurn.Invoke ();
|
||||
|
||||
blockActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentCharacterTurnTarget (GameObject newTarget)
|
||||
{
|
||||
currentTarget = newTarget;
|
||||
}
|
||||
|
||||
public void setNextTurn ()
|
||||
{
|
||||
if (systemActive && isCurrentCharacterTurn) {
|
||||
mainTurnBasedCombatActionsSystem.setNextTurn ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentTurnBasedCombatAttackComplete ()
|
||||
{
|
||||
setNextTurn ();
|
||||
}
|
||||
|
||||
public void activateMatchPosition (float customMatchOffset)
|
||||
{
|
||||
float currentMatchOffset = defaultMatchOffset;
|
||||
|
||||
if (customMatchOffset > 0) {
|
||||
currentMatchOffset = customMatchOffset;
|
||||
}
|
||||
|
||||
mainMatchPlayerToTargetSystem.activateMatchPosition (currentMatchOffset);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatAttackCategoryInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool attackCategoryEnabled = true;
|
||||
|
||||
public bool useProbabilityToCheckCategory;
|
||||
[Range (0, 100)] public float probabilityToCheckCategory;
|
||||
|
||||
[Space]
|
||||
|
||||
public List<turnBasedCombatAttackInfo> turnBasedCombatAttackInfoList = new List<turnBasedCombatAttackInfo> ();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class turnBasedCombatAttackInfo
|
||||
{
|
||||
public string Name;
|
||||
|
||||
[Space]
|
||||
public bool attackEnabled = true;
|
||||
|
||||
public float duration;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useProbabilityToUseAttack;
|
||||
[Range (0, 100)] public float probabilityToUseAttack;
|
||||
|
||||
[Space]
|
||||
|
||||
public float minDistanceToUseAttack;
|
||||
|
||||
public bool isAttackFromDistance;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useDelayToActivateAttack;
|
||||
public float delayToActivateAttack;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMatchPositionSystem;
|
||||
public float matchPositionOffset = 1;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public bool useStatToUseAction;
|
||||
public string statNameToUseAction;
|
||||
public float statAmountToUseAction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 218d50b0abc0621409abcda448fe64ab
|
||||
timeCreated: 1697125492
|
||||
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/AI/Custom AI Behavior/AITurnBasedCombatSystemBrain.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class abilitiesAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AIAbilitiesSystemBrain mainAIAbilitiesSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIAbilitiesSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIAbilitiesSystemBrain.updateBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIAbilitiesSystemBrain.updateAIAttackState (canUseAttack);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIAbilitiesSystemBrain.setSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void stopCurrentAttackInProcess ()
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.stopCurrentAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.setTurnBasedCombatActionActiveState (state);
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.checkAIBehaviorStateOnCharacterSpawn ();
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.checkAIBehaviorStateOnCharacterDespawn ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0fec04c27195a649912f295c8b1f95e
|
||||
timeCreated: 1647925282
|
||||
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/AI/Custom AI Behavior/abilitiesAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class closeCombatAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AICloseCombatSystemBrain mainAICloseCombatSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.updateMainCloseCombatBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.updateMainCloseCombatAttack (canUseAttack);
|
||||
}
|
||||
|
||||
public override void updateInsideRangeDistance (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.updateInsideMinDistance (state);
|
||||
}
|
||||
|
||||
public override void resetBehaviorStates ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.resetBehaviorStates ();
|
||||
}
|
||||
|
||||
public override void setBehaviorStatesPausedState (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setBehaviorStatesPausedState (state);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.setCloseCombatSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void setUseRandomWalkEnabledState (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setUseRandomWalkEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setOriginalUseRandomWalkEnabledState ()
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setOriginalUseRandomWalkEnabledState ();
|
||||
}
|
||||
|
||||
public override bool isAIBehaviorAttackInProcess ()
|
||||
{
|
||||
return mainAICloseCombatSystemBrain.isAIBehaviorAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void stopCurrentAttackInProcess ()
|
||||
{
|
||||
mainAICloseCombatSystemBrain.stopCurrentAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setTurnBasedCombatActionActiveState (state);
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
mainAICloseCombatSystemBrain.checkAIBehaviorStateOnCharacterSpawn ();
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
mainAICloseCombatSystemBrain.checkAIBehaviorStateOnCharacterDespawn ();
|
||||
}
|
||||
|
||||
public override void changeCurrentAttackMode (string newModeName)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.changeCurrentAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void stopAttackState ()
|
||||
{
|
||||
mainAICloseCombatSystemBrain.stopAttackState ();
|
||||
}
|
||||
|
||||
public override void setAttackEnabledState (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setAttackEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
mainAICloseCombatSystemBrain.setAttackEnabledStateFromEditor (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9554527b49ffe2f4aafeba3c158d0a90
|
||||
timeCreated: 1602696760
|
||||
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/AI/Custom AI Behavior/closeCombatAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,785 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class handleVehicleAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool characterOnVehicle;
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Driver Settings")]
|
||||
[Space]
|
||||
|
||||
public bool searchVehicleEnabled = true;
|
||||
|
||||
public bool startGameSearchingForVehicle;
|
||||
|
||||
public bool setVehicleToStart;
|
||||
public GameObject vehicleToStart;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useMaxDistanceToGetVehicle;
|
||||
|
||||
public float maxDistanceToGetVehicle;
|
||||
|
||||
public float minDistanceToGetOnCurrentVehicle = 3.5f;
|
||||
|
||||
public bool ignoreCheckVehicleIfTargetToAttackFound;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool stopBehaviorUpdateOnGetOffFromVehicle = true;
|
||||
public bool stopBehaviorUpdateOnVehicleReached = true;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Driver Debug Info")]
|
||||
[Space]
|
||||
|
||||
public bool searchingVehicle;
|
||||
public bool vehicleToReachFound;
|
||||
|
||||
public bool currentVehicleAINavmeshLocated;
|
||||
|
||||
public bool getOffFromVehicleOnDestinyReached;
|
||||
|
||||
[Space]
|
||||
|
||||
public Transform currentVehicleToGet;
|
||||
public vehicleAINavMesh currentVehicleAINavMesh;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnNoVehicleToPickFromScene;
|
||||
public UnityEvent eventOnNoVehicleToPickFromScene;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Passenger Settings")]
|
||||
[Space]
|
||||
|
||||
public bool checkAIPassengerStateEnabled = true;
|
||||
|
||||
public bool ignoreCheckPartnerOnVehicle;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Passenger Debug Info")]
|
||||
[Space]
|
||||
|
||||
public vehicleHUDManager currentVehicleHUDManager;
|
||||
public vehicleHUDManager currentVehicleToAttack;
|
||||
public GameObject currentVehicle;
|
||||
public playerController playerControllerPartner;
|
||||
|
||||
public bool AICharacterWasntAbleToEnterOnPartnerVehicle;
|
||||
public bool partnerFound;
|
||||
|
||||
public bool followingPartnerDrivingOnFoot;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform AITransform;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AINavMesh mainAINavmeshManager;
|
||||
public playerController mainPlayerController;
|
||||
public usingDevicesSystem usingDevicesManager;
|
||||
|
||||
|
||||
Coroutine updateCoroutine;
|
||||
|
||||
bool followingTargetPreviously;
|
||||
|
||||
bool isVehicleFull = false;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (searchVehicleEnabled) {
|
||||
if (startGameSearchingForVehicle) {
|
||||
StartCoroutine (startGameSearchingForVehicleCoroutine ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
//DRIVER FUNCTIONS
|
||||
//------------------------------------------------------------
|
||||
|
||||
IEnumerator startGameSearchingForVehicleCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.3f);
|
||||
|
||||
activateAIBehavior ();
|
||||
}
|
||||
|
||||
public override void activateAIBehavior ()
|
||||
{
|
||||
if (searchVehicleEnabled) {
|
||||
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
public override void deactivateAIBehavior ()
|
||||
{
|
||||
if (searchVehicleEnabled) {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopUpdateCoroutine ()
|
||||
{
|
||||
if (updateCoroutine != null) {
|
||||
StopCoroutine (updateCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForSecondsRealtime (0.0001f);
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void setGetOffFromVehicleOnDestinyReachedState (bool state)
|
||||
{
|
||||
getOffFromVehicleOnDestinyReached = state;
|
||||
}
|
||||
|
||||
void updateSystem ()
|
||||
{
|
||||
if (characterOnVehicle) {
|
||||
if (currentVehicleAINavmeshLocated) {
|
||||
if (currentVehicleAINavMesh.isFollowingTarget ()) {
|
||||
followingTargetPreviously = true;
|
||||
} else {
|
||||
if (followingTargetPreviously) {
|
||||
getOffFromVehicle ();
|
||||
|
||||
if (stopBehaviorUpdateOnGetOffFromVehicle) {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
|
||||
setCharacterOnVehicleState (false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (searchingVehicle) {
|
||||
bool vehicleReached = false;
|
||||
|
||||
if (currentVehicleToGet != null) {
|
||||
if (GKC_Utils.distance (mainAINavmeshManager.transform.position, currentVehicleToGet.position) < minDistanceToGetOnCurrentVehicle) {
|
||||
if (showDebugPrint) {
|
||||
print ("picking vehicle " + currentVehicleToGet.name);
|
||||
}
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManager = currentVehicleToGet.GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManager != null) {
|
||||
IKDrivingSystem currentIKDrivingSystem = currentVehicleHUDManager.getIKDrivingSystem ();
|
||||
|
||||
if (currentIKDrivingSystem != null) {
|
||||
currentIKDrivingSystem.setDriverExternally (AITransform.gameObject);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("sending character to vehicle");
|
||||
}
|
||||
|
||||
mainAINavmeshManager.removeTarget ();
|
||||
}
|
||||
} else {
|
||||
GKCSimpleRiderSystem currentGKCSimpleRiderSystem = currentVehicleToGet.GetComponent<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (currentGKCSimpleRiderSystem != null) {
|
||||
currentGKCSimpleRiderSystem.setDriverExternally (AITransform.gameObject);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("sending character to vehicle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vehicleReached = true;
|
||||
}
|
||||
} else {
|
||||
vehicleReached = true;
|
||||
}
|
||||
|
||||
if (vehicleReached) {
|
||||
mainFindObjectivesSystem.setSearchingObjectState (false);
|
||||
|
||||
searchingVehicle = false;
|
||||
|
||||
currentVehicleToGet = null;
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreVisionRangeActiveState (true);
|
||||
|
||||
mainFindObjectivesSystem.resetAITargets ();
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreVisionRangeActiveState (false);
|
||||
|
||||
mainFindObjectivesSystem.setOriginalWanderEnabled ();
|
||||
|
||||
setCharacterOnVehicleState (true);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("vehicle picked, resuming state on AI");
|
||||
}
|
||||
|
||||
if (stopBehaviorUpdateOnVehicleReached) {
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checkToFindVehicle ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkToFindVehicle ()
|
||||
{
|
||||
if (characterOnVehicle) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ignoreCheckVehicleIfTargetToAttackFound) {
|
||||
if (mainFindObjectivesSystem.isOnSpotted ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setCharacterOnVehicleState (false);
|
||||
|
||||
bool vehicleFound = false;
|
||||
|
||||
bool ignoreSearchVehicleResult = false;
|
||||
|
||||
if (setVehicleToStart) {
|
||||
if (vehicleToStart != null) {
|
||||
Transform vehicleToStartTransform = null;
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManager = vehicleToStart.GetComponentInChildren<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManager != null) {
|
||||
vehicleToStartTransform = currentVehicleHUDManager.transform;
|
||||
|
||||
if (mainAINavmeshManager.updateCurrentNavMeshPath (vehicleToStartTransform.position)) {
|
||||
setVehicleToReachToDrive (vehicleToStartTransform);
|
||||
|
||||
ignoreSearchVehicleResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignoreSearchVehicleResult) {
|
||||
vehicleHUDManager [] vehicleHUDManagerList = FindObjectsOfType (typeof (vehicleHUDManager)) as vehicleHUDManager [];
|
||||
|
||||
List<Transform> vehiclesDetected = new List<Transform> ();
|
||||
|
||||
if (vehicleHUDManagerList.Length > 0) {
|
||||
for (int i = 0; i < vehicleHUDManagerList.Length; i++) {
|
||||
bool checkObjectResult = true;
|
||||
|
||||
if (vehicleHUDManagerList [i].getCurrentDriver () != null) {
|
||||
checkObjectResult = false;
|
||||
}
|
||||
|
||||
if (useMaxDistanceToGetVehicle) {
|
||||
float distance = GKC_Utils.distance (vehicleHUDManagerList [i].transform.position, AITransform.position);
|
||||
|
||||
if (distance > maxDistanceToGetVehicle) {
|
||||
checkObjectResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkObjectResult) {
|
||||
vehiclesDetected.Add (vehicleHUDManagerList [i].transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GKCSimpleRiderSystem [] GKCSimpleRiderSystemList = FindObjectsOfType (typeof (GKCSimpleRiderSystem)) as GKCSimpleRiderSystem [];
|
||||
|
||||
if (GKCSimpleRiderSystemList.Length > 0) {
|
||||
for (int i = 0; i < GKCSimpleRiderSystemList.Length; i++) {
|
||||
bool checkObjectResult = true;
|
||||
|
||||
if (GKCSimpleRiderSystemList [i].getCurrentDriver () != null) {
|
||||
checkObjectResult = false;
|
||||
}
|
||||
|
||||
if (useMaxDistanceToGetVehicle) {
|
||||
float distance = GKC_Utils.distance (GKCSimpleRiderSystemList [i].transform.position, AITransform.position);
|
||||
|
||||
if (distance > maxDistanceToGetVehicle) {
|
||||
checkObjectResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkObjectResult) {
|
||||
vehiclesDetected.Add (GKCSimpleRiderSystemList [i].transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vehiclesDetected.Count == 0) {
|
||||
if (showDebugPrint) {
|
||||
print ("no vehicles detected");
|
||||
}
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
}
|
||||
|
||||
if (vehiclesDetected.Count > 0) {
|
||||
|
||||
vehiclesDetected.Sort (delegate (Transform a, Transform b) {
|
||||
return Vector3.Distance (AITransform.position, a.transform.position).CompareTo (Vector3.Distance (AITransform.position, b.transform.position));
|
||||
});
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("vehicles found on scene " + vehiclesDetected.Count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < vehiclesDetected.Count; i++) {
|
||||
if (!vehicleFound) {
|
||||
|
||||
if (showDebugPrint) {
|
||||
vehicleHUDManager currentVehicleHUDManager = vehiclesDetected [i].GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManager != null) {
|
||||
print ("checking if vehicle with name " + currentVehicleHUDManager.getVehicleName () + " can be used");
|
||||
} else {
|
||||
GKCSimpleRiderSystem currentGKCSimpleRiderSystem = vehiclesDetected [i].GetComponent<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (currentGKCSimpleRiderSystem != null) {
|
||||
print ("checking if vehicle with name " + currentGKCSimpleRiderSystem.getVehicleName () + " can be used");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mainAINavmeshManager.updateCurrentNavMeshPath (vehiclesDetected [i].transform.position)) {
|
||||
setVehicleToReachToDrive (vehiclesDetected [i]);
|
||||
|
||||
vehicleFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print ("no vehicles found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vehicleFound) {
|
||||
if (showDebugPrint) {
|
||||
print ("vehicles found can't be reached, cancelling search");
|
||||
}
|
||||
|
||||
stopUpdateCoroutine ();
|
||||
|
||||
if (useEventOnNoVehicleToPickFromScene) {
|
||||
eventOnNoVehicleToPickFromScene.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setVehicleToReachToDrive (Transform vehicleTransform)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("vehicle to reach found ");
|
||||
}
|
||||
|
||||
mainFindObjectivesSystem.setDrawOrHolsterWeaponState (false);
|
||||
|
||||
mainFindObjectivesSystem.setSearchingObjectState (true);
|
||||
|
||||
mainFindObjectivesSystem.setWanderEnabledState (false);
|
||||
|
||||
currentVehicleToGet = vehicleTransform;
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManager = currentVehicleToGet.GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManager != null) {
|
||||
currentVehicleAINavMesh = currentVehicleHUDManager.getAIVehicleNavmesh ();
|
||||
|
||||
currentVehicleAINavmeshLocated = currentVehicleAINavMesh != null;
|
||||
}
|
||||
|
||||
mainAINavmeshManager.setTarget (vehicleTransform);
|
||||
|
||||
mainAINavmeshManager.setTargetType (false, true);
|
||||
|
||||
followingTargetPreviously = false;
|
||||
|
||||
mainAINavmeshManager.lookAtTaget (false);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("vehicle to use located, setting searching vehicle state on AI");
|
||||
}
|
||||
|
||||
searchingVehicle = true;
|
||||
}
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
//PASSENGER FUNCTIONS
|
||||
//------------------------------------------------------------
|
||||
|
||||
public override void updateAIPassengerBehavior ()
|
||||
{
|
||||
if (!checkAIPassengerStateEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!partnerFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerControllerPartner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainAINavmeshManager.isCharacterWaiting ()) {
|
||||
if (ignoreCheckPartnerOnVehicle) {
|
||||
if (playerControllerPartner.isPlayerDriving ()) {
|
||||
if (!followingPartnerDrivingOnFoot) {
|
||||
currentVehicle = playerControllerPartner.getCurrentVehicle ();
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManagerToGetOn = currentVehicle.GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManagerToGetOn != null) {
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (true, currentVehicleHUDManagerToGetOn.getVehicleRadius ());
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (true, currentVehicleHUDManagerToGetOn.getVehicleRadius ());
|
||||
} else {
|
||||
GKCSimpleRiderSystem currentGKCSimpleRiderSystemToGetOn = currentVehicle.GetComponent<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (currentGKCSimpleRiderSystemToGetOn != null) {
|
||||
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (true, currentGKCSimpleRiderSystemToGetOn.getVehicleRadius ());
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (true, currentGKCSimpleRiderSystemToGetOn.getVehicleRadius ());
|
||||
}
|
||||
}
|
||||
|
||||
followingPartnerDrivingOnFoot = true;
|
||||
} else {
|
||||
if (mainAINavmeshManager.isCharacterAttacking ()) {
|
||||
removeStateOnVehicle ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (followingPartnerDrivingOnFoot) {
|
||||
removeStateOnVehicle ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (playerControllerPartner.isPlayerDriving ()) {
|
||||
if (!characterOnVehicle && !mainAINavmeshManager.isCharacterAttacking ()) {
|
||||
|
||||
if (currentVehicle == null) {
|
||||
|
||||
isVehicleFull = false;
|
||||
|
||||
currentVehicle = playerControllerPartner.getCurrentVehicle ();
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManagerToGetOn = currentVehicle.GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManagerToGetOn != null) {
|
||||
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (true, currentVehicleHUDManagerToGetOn.getVehicleRadius ());
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (true, currentVehicleHUDManagerToGetOn.getVehicleRadius ());
|
||||
|
||||
mainFindObjectivesSystem.addNotEnemy (playerControllerPartner.gameObject);
|
||||
|
||||
isVehicleFull = currentVehicleHUDManagerToGetOn.isVehicleFull ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("partner is driving a GKC vehicle and the vehicle full result is " + isVehicleFull);
|
||||
}
|
||||
} else {
|
||||
GKCSimpleRiderSystem currentGKCSimpleRiderSystemToGetOn = currentVehicle.GetComponent<GKCSimpleRiderSystem> ();
|
||||
|
||||
print (currentGKCSimpleRiderSystemToGetOn != null);
|
||||
|
||||
if (currentGKCSimpleRiderSystemToGetOn != null) {
|
||||
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (true, currentGKCSimpleRiderSystemToGetOn.getVehicleRadius ());
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (true, currentGKCSimpleRiderSystemToGetOn.getVehicleRadius ());
|
||||
|
||||
mainFindObjectivesSystem.addNotEnemy (playerControllerPartner.gameObject);
|
||||
|
||||
isVehicleFull = currentGKCSimpleRiderSystemToGetOn.isVehicleFull () ||
|
||||
currentGKCSimpleRiderSystemToGetOn.isVehicleOnlyForOnePlayerActive ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("partner is driving a GKC rider and the vehicle full result is " + isVehicleFull);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mainAINavmeshManager.isFollowingTarget ()) {
|
||||
if (!AICharacterWasntAbleToEnterOnPartnerVehicle) {
|
||||
if (mainPlayerController.canCharacterGetOnVehicles ()) {
|
||||
if (isVehicleFull) {
|
||||
AICharacterWasntAbleToEnterOnPartnerVehicle = true;
|
||||
} else {
|
||||
enterOnVehicle (currentVehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mainAINavmeshManager.isCharacterAttacking ()) {
|
||||
getOffFromVehicle ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (characterOnVehicle) {
|
||||
getOffFromVehicle ();
|
||||
} else if (AICharacterWasntAbleToEnterOnPartnerVehicle) {
|
||||
removeStateOnVehicle ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIgnoreCheckPartnerOnVehicleState (bool state)
|
||||
{
|
||||
ignoreCheckPartnerOnVehicle = state;
|
||||
}
|
||||
|
||||
public void setCheckAIPassengerStateEnabledState (bool state)
|
||||
{
|
||||
checkAIPassengerStateEnabled = state;
|
||||
}
|
||||
|
||||
public void enterOnVehicle (GameObject newVehicleObject)
|
||||
{
|
||||
if (AICharacterWasntAbleToEnterOnPartnerVehicle) {
|
||||
if (showDebugPrint) {
|
||||
print ("AI wasn't able to enter on vehicle, cancelling");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("characterOnVehicle " + true);
|
||||
}
|
||||
|
||||
mainAINavmeshManager.pauseAI (true);
|
||||
|
||||
usingDevicesManager.addDeviceToList (newVehicleObject);
|
||||
|
||||
usingDevicesManager.getclosestDevice (false, false);
|
||||
|
||||
usingDevicesManager.setCurrentVehicle (newVehicleObject);
|
||||
|
||||
usingDevicesManager.useCurrentDevice (newVehicleObject);
|
||||
|
||||
if (mainPlayerController.isPlayerDriving ()) {
|
||||
setCharacterOnVehicleState (true);
|
||||
|
||||
AICharacterWasntAbleToEnterOnPartnerVehicle = false;
|
||||
} else {
|
||||
setCharacterOnVehicleState (false);
|
||||
|
||||
AICharacterWasntAbleToEnterOnPartnerVehicle = true;
|
||||
|
||||
mainAINavmeshManager.pauseAI (false);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (gameObject.name + " " + mainPlayerController.isPlayerDriving () + " " + characterOnVehicle);
|
||||
}
|
||||
}
|
||||
|
||||
public override void getOffFromVehicle ()
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("getOffFromVehicle " + gameObject.name);
|
||||
}
|
||||
|
||||
if (characterOnVehicle) {
|
||||
if (mainPlayerController.canCharacterGetOnVehicles ()) {
|
||||
if (currentVehicle != null) {
|
||||
usingDevicesManager.clearDeviceList ();
|
||||
|
||||
usingDevicesManager.addDeviceToList (currentVehicle);
|
||||
|
||||
usingDevicesManager.getclosestDevice (false, false);
|
||||
|
||||
usingDevicesManager.setCurrentVehicle (currentVehicle);
|
||||
|
||||
usingDevicesManager.useCurrentDevice (currentVehicle);
|
||||
} else {
|
||||
usingDevicesManager.useDevice ();
|
||||
}
|
||||
|
||||
mainAINavmeshManager.pauseAI (false);
|
||||
}
|
||||
|
||||
removeStateOnVehicle ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("remove AI from vehicle " + gameObject.name);
|
||||
}
|
||||
} else {
|
||||
if (AICharacterWasntAbleToEnterOnPartnerVehicle) {
|
||||
removeStateOnVehicle ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("remove state on vehicle " + gameObject.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setCharacterOnVehicleState (bool state)
|
||||
{
|
||||
characterOnVehicle = state;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (gameObject.name + " " + mainPlayerController.isPlayerDriving () + " " + characterOnVehicle);
|
||||
}
|
||||
}
|
||||
|
||||
public override void removeStateOnVehicle ()
|
||||
{
|
||||
currentVehicle = null;
|
||||
|
||||
setCharacterOnVehicleState (false);
|
||||
|
||||
followingPartnerDrivingOnFoot = false;
|
||||
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (false, 0);
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (false, 0);
|
||||
|
||||
AICharacterWasntAbleToEnterOnPartnerVehicle = false;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("removeStateOnVehicle " + gameObject.name);
|
||||
}
|
||||
}
|
||||
|
||||
public override void setAICharacterOnVehicle (GameObject newVehicle)
|
||||
{
|
||||
if (characterOnVehicle) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentVehicle = newVehicle;
|
||||
|
||||
bool isVehicleFull = false;
|
||||
|
||||
float vehicleRadius = 0;
|
||||
|
||||
vehicleHUDManager currentVehicleHUDManagerToGetOn = currentVehicle.GetComponent<vehicleHUDManager> ();
|
||||
|
||||
if (currentVehicleHUDManagerToGetOn != null) {
|
||||
isVehicleFull = currentVehicleHUDManagerToGetOn.isVehicleFull ();
|
||||
|
||||
vehicleRadius = currentVehicleHUDManagerToGetOn.getVehicleRadius ();
|
||||
} else {
|
||||
GKCSimpleRiderSystem currentGKCSimpleRiderSystem = currentVehicle.GetComponent<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (currentGKCSimpleRiderSystem != null) {
|
||||
isVehicleFull = currentGKCSimpleRiderSystem.isVehicleFull () ||
|
||||
currentGKCSimpleRiderSystem.isVehicleOnlyForOnePlayerActive ();
|
||||
|
||||
vehicleRadius = currentGKCSimpleRiderSystem.getVehicleRadius ();
|
||||
}
|
||||
}
|
||||
|
||||
mainFindObjectivesSystem.setExtraMinDistanceState (true, vehicleRadius);
|
||||
|
||||
mainAINavmeshManager.setExtraMinDistanceState (true, vehicleRadius);
|
||||
|
||||
if (!isVehicleFull) {
|
||||
if (mainPlayerController.canCharacterGetOnVehicles ()) {
|
||||
enterOnVehicle (currentVehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool isCharacterOnVehicle ()
|
||||
{
|
||||
return characterOnVehicle;
|
||||
}
|
||||
|
||||
public override void setCurrentPlayerControllerPartner (playerController newPlayerController)
|
||||
{
|
||||
playerControllerPartner = newPlayerController;
|
||||
|
||||
partnerFound = playerControllerPartner != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8ae889d28a01d04b9bd99f4bf7ecabe
|
||||
timeCreated: 1685693567
|
||||
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/AI/Custom AI Behavior/handleVehicleAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,163 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class meleeAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AIMeleeCombatSystemBrain mainAIMeleeCombatSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.updateMainMeleeBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.updateMainMeleeAttack (canUseAttack);
|
||||
}
|
||||
|
||||
public override void updateInsideRangeDistance (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.updateInsideMinDistance (state);
|
||||
}
|
||||
|
||||
public override void resetBehaviorStates ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.resetBehaviorStates ();
|
||||
}
|
||||
|
||||
public override void dropWeapon ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.dropWeapon ();
|
||||
}
|
||||
|
||||
public override void setBehaviorStatesPausedState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setBehaviorStatesPausedState (state);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIMeleeCombatSystemBrain.setCombatSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override bool carryingWeapon ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mainAIMeleeCombatSystemBrain.isWeaponEquiped ();
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void setUseRandomWalkEnabledState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setUseRandomWalkEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setOriginalUseRandomWalkEnabledState ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setOriginalUseRandomWalkEnabledState ();
|
||||
}
|
||||
|
||||
public override bool isAIBehaviorAttackInProcess ()
|
||||
{
|
||||
return mainAIMeleeCombatSystemBrain.isAIBehaviorAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void checkNoWeaponsAvailableState ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.checkNoMeleeWeaponsAvailableState ();
|
||||
}
|
||||
|
||||
public override void setDrawOrHolsterWeaponState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setDrawOrHolsterWeaponState (state);
|
||||
}
|
||||
|
||||
public override void stopCurrentAttackInProcess ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.stopCurrentAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setTurnBasedCombatActionActiveState (state);
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.checkAIBehaviorStateOnCharacterSpawn ();
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.checkAIBehaviorStateOnCharacterDespawn ();
|
||||
}
|
||||
|
||||
public override void checkIfDisableCurrentWeaponToChangeAttackMode (string newModeName)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.checkIfDisableCurrentWeaponToChangeAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void changeCurrentAttackMode (string newModeName)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.changeCurrentAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void stopAttackState ()
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.stopAttackState ();
|
||||
}
|
||||
|
||||
public override void setAttackEnabledState (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setAttackEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
mainAIMeleeCombatSystemBrain.setAttackEnabledStateFromEditor (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81cf24bd116a6d449a07c6403799938e
|
||||
timeCreated: 1602681548
|
||||
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/AI/Custom AI Behavior/meleeAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,147 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class powersAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AIPowersSystemBrain mainAIPowersSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.updateBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.updateAIAttackState (canUseAttack);
|
||||
}
|
||||
|
||||
public override void updateInsideRangeDistance (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.updateInsideMinDistance (state);
|
||||
}
|
||||
|
||||
public override void resetBehaviorStates ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.resetBehaviorStates ();
|
||||
}
|
||||
|
||||
public override void resetAttackState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.resetAttackState ();
|
||||
}
|
||||
|
||||
public override void stopAim ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.stopAim ();
|
||||
}
|
||||
|
||||
public override void disableOnSpottedState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.disableOnSpottedState ();
|
||||
}
|
||||
|
||||
public override void setBehaviorStatesPausedState (bool state)
|
||||
{
|
||||
mainAIPowersSystemBrain.setBehaviorStatesPausedState (state);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIPowersSystemBrain.setSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAIPowersSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void stopCurrentAttackInProcess ()
|
||||
{
|
||||
mainAIPowersSystemBrain.stopCurrentAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
mainAIPowersSystemBrain.setTurnBasedCombatActionActiveState (state);
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
mainAIPowersSystemBrain.checkAIBehaviorStateOnCharacterSpawn ();
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
mainAIPowersSystemBrain.checkAIBehaviorStateOnCharacterDespawn ();
|
||||
}
|
||||
|
||||
public override void checkIfDisableCurrentWeaponToChangeAttackMode (string newModeName)
|
||||
{
|
||||
mainAIPowersSystemBrain.checkIfDisableCurrentWeaponToChangeAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void changeCurrentAttackMode (string newModeName)
|
||||
{
|
||||
mainAIPowersSystemBrain.changeCurrentAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void stopAttackState ()
|
||||
{
|
||||
mainAIPowersSystemBrain.stopAttackState ();
|
||||
}
|
||||
|
||||
public override void setAttackEnabledState (bool state)
|
||||
{
|
||||
mainAIPowersSystemBrain.setAttackEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
mainAIPowersSystemBrain.setAttackEnabledStateFromEditor (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47fcc7f83ae851a418a51ce7cafa2017
|
||||
timeCreated: 1602696153
|
||||
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/AI/Custom AI Behavior/powersAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,167 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class shootBowSimpleAIAction : simpleAIAction
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public float shootWeaponDuration = 2;
|
||||
|
||||
public bool useAmountOfProjectilesToShoot;
|
||||
|
||||
public int amountOfProjectilesToShoot;
|
||||
|
||||
public bool useFireRate;
|
||||
public float fireRate;
|
||||
|
||||
// public string quickModeActionName = "Fire Arrow Bow Attack";
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool aimingWeapon;
|
||||
public bool shootingWeapon;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
// public quickPlayerModeChangeSystem mainQuickPlayerModeChangeSystem;
|
||||
public bowSystem mainBowSystem;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
float lastTimeAiming;
|
||||
float lastTimeShoot;
|
||||
|
||||
|
||||
public override void startAIAction ()
|
||||
{
|
||||
base.startAIAction ();
|
||||
|
||||
if (actionActive) {
|
||||
if (actionUsedByPlayer) {
|
||||
|
||||
} else {
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystemAsCustomTargetToLook ();
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreLookAtDirectionActiveState (true);
|
||||
}
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (true);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (true);
|
||||
|
||||
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
mainBowSystem.resetLastAmountOfFiredProjectiles ();
|
||||
}
|
||||
|
||||
mainBowSystem.setArrowsManagedByInventoryState (false);
|
||||
|
||||
mainBowSystem.inputSetAimBowState (true);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("aim bow");
|
||||
}
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.lookAtTemporalObjectToLookAtTarget ();
|
||||
}
|
||||
|
||||
lastTimeAiming = Time.time;
|
||||
|
||||
aimingWeapon = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateSystem ()
|
||||
{
|
||||
if (!actionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aimingWeapon) {
|
||||
if (shootingWeapon) {
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
if (mainBowSystem.getLastAmountOfFiredProjectiles () >= amountOfProjectilesToShoot) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Time.time > lastTimeAiming + shootWeaponDuration) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (useFireRate) {
|
||||
if (Time.time > lastTimeShoot + fireRate) {
|
||||
setShootWeaponState (true);
|
||||
|
||||
lastTimeShoot = Time.time;
|
||||
}
|
||||
} else {
|
||||
setShootWeaponState (true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!actionUsedByPlayer) {
|
||||
mainFindObjectivesSystem.lookAtCurrentPlaceToShoot ();
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (true);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShootWeaponState (bool state)
|
||||
{
|
||||
// mainQuickPlayerModeChangeSystem.inputActivateMode (quickModeActionName);
|
||||
|
||||
mainBowSystem.inputFireArrow ();
|
||||
|
||||
shootingWeapon = state;
|
||||
}
|
||||
|
||||
public override void resetStatesOnActionEnd ()
|
||||
{
|
||||
if (shootingWeapon) {
|
||||
shootingWeapon = false;
|
||||
|
||||
// mainQuickPlayerModeChangeSystem.inputActiveModePressUp (quickModeActionName);
|
||||
|
||||
mainBowSystem.inputSetAimBowState (false);
|
||||
|
||||
if (mainBowSystem.isAimingBowActive ()) {
|
||||
mainBowSystem.cancelBowLoadedStateIfActive ();
|
||||
}
|
||||
}
|
||||
|
||||
mainBowSystem.setOriginalArrowsManagedByInventoryState ();
|
||||
|
||||
shootingWeapon = false;
|
||||
|
||||
aimingWeapon = false;
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (false);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (false);
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.setLookAtTargetStateInput (false);
|
||||
} else {
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (false);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreLookAtDirectionActiveState (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b98ed6677a8ccbf4fbc510d0e33f6443
|
||||
timeCreated: 1697852319
|
||||
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/AI/Custom AI Behavior/shootBowSimpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,177 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class shootFireWeaponSimpleAIAction : simpleAIAction
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public float shootWeaponDuration = 2;
|
||||
|
||||
public bool useAmountOfProjectilesToShoot;
|
||||
|
||||
public int amountOfProjectilesToShoot;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool aimingWeapon;
|
||||
public bool shootingWeapon;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerWeaponsManager mainPlayerWeaponsManager;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
float lastTimeShooting;
|
||||
|
||||
|
||||
public override void startAIAction ()
|
||||
{
|
||||
base.startAIAction ();
|
||||
|
||||
if (actionActive) {
|
||||
if (actionUsedByPlayer) {
|
||||
|
||||
} else {
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystemAsCustomTargetToLook ();
|
||||
}
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (true);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (true);
|
||||
|
||||
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
mainPlayerWeaponsManager.resetLastAmountOfFiredProjectiles ();
|
||||
}
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerWeaponsManager.inputAimWeapon ();
|
||||
} else {
|
||||
mainPlayerWeaponsManager.aimCurrentWeaponWhenItIsReady (true);
|
||||
}
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.lookAtTemporalObjectToLookAtTarget ();
|
||||
}
|
||||
|
||||
aimingWeapon = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateSystem ()
|
||||
{
|
||||
if (!actionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aimingWeapon) {
|
||||
if (shootingWeapon) {
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
if (mainPlayerWeaponsManager.getLastAmountOfFiredProjectiles () >= amountOfProjectilesToShoot) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Time.time > lastTimeShooting + shootWeaponDuration) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!mainPlayerWeaponsManager.currentWeaponIsMoving () &&
|
||||
mainPlayerWeaponsManager.reloadingActionNotActive () &&
|
||||
mainPlayerWeaponsManager.isPlayerCarringWeapon () &&
|
||||
|
||||
!mainPlayerWeaponsManager.isActionActiveInPlayer () &&
|
||||
mainPlayerWeaponsManager.canPlayerMove ()) {
|
||||
|
||||
setShootWeaponState (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!actionUsedByPlayer) {
|
||||
mainFindObjectivesSystem.lookAtCurrentPlaceToShoot ();
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (true);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShootWeaponState (bool state)
|
||||
{
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerWeaponsManager.inputHoldOrReleaseShootWeapon (true);
|
||||
} else {
|
||||
mainPlayerWeaponsManager.shootWeapon (state);
|
||||
}
|
||||
|
||||
shootingWeapon = state;
|
||||
|
||||
if (shootingWeapon) {
|
||||
lastTimeShooting = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
public override void resetStatesOnActionEnd ()
|
||||
{
|
||||
if (shootingWeapon) {
|
||||
shootingWeapon = false;
|
||||
|
||||
mainPlayerWeaponsManager.inputHoldOrReleaseShootWeapon (false);
|
||||
|
||||
if (mainPlayerWeaponsManager.isCharacterShooting ()) {
|
||||
mainPlayerWeaponsManager.resetWeaponFiringAndAimingIfPlayerDisabled ();
|
||||
|
||||
mainPlayerWeaponsManager.setHoldShootWeaponState (false);
|
||||
}
|
||||
}
|
||||
|
||||
if (aimingWeapon) {
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerWeaponsManager.inputAimWeapon ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (mainPlayerWeaponsManager.isAimingWeapons ());
|
||||
}
|
||||
|
||||
if (mainPlayerWeaponsManager.isAimingWeapons ()) {
|
||||
mainPlayerWeaponsManager.setAimWeaponState (false);
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (mainPlayerWeaponsManager.isAimingWeapons ());
|
||||
}
|
||||
} else {
|
||||
mainPlayerWeaponsManager.aimCurrentWeaponWhenItIsReady (false);
|
||||
mainPlayerWeaponsManager.stopAimCurrentWeaponWhenItIsReady (true);
|
||||
}
|
||||
}
|
||||
|
||||
shootingWeapon = false;
|
||||
|
||||
aimingWeapon = false;
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (false);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (false);
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.setLookAtTargetStateInput (false);
|
||||
} else {
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (false);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 239553e2cc120f94f990ab1a8b4f2e39
|
||||
timeCreated: 1697774223
|
||||
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/AI/Custom AI Behavior/shootFireWeaponSimpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,145 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class shootPowerSimpleAIAction : simpleAIAction
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public float shootPowerDuration = 2;
|
||||
|
||||
public bool useAmountOfProjectilesToShoot;
|
||||
|
||||
public int amountOfProjectilesToShoot;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool aimingPower;
|
||||
public bool shootingPower;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public otherPowers mainOtherPowers;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
float lastTimeAiming;
|
||||
|
||||
|
||||
public override void startAIAction ()
|
||||
{
|
||||
base.startAIAction ();
|
||||
|
||||
if (actionActive) {
|
||||
if (actionUsedByPlayer) {
|
||||
|
||||
} else {
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystemAsCustomTargetToLook ();
|
||||
}
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (true);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (true);
|
||||
|
||||
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
mainOtherPowers.resetLastAmountOfFiredProjectiles ();
|
||||
}
|
||||
|
||||
if (!mainOtherPowers.isAimingPower ()) {
|
||||
mainOtherPowers.inputSetAimPowerState (true);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("aim power");
|
||||
}
|
||||
}
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.lookAtTemporalObjectToLookAtTarget ();
|
||||
}
|
||||
|
||||
lastTimeAiming = Time.time;
|
||||
|
||||
aimingPower = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void updateSystem ()
|
||||
{
|
||||
if (!actionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aimingPower) {
|
||||
if (shootingPower) {
|
||||
if (useAmountOfProjectilesToShoot) {
|
||||
if (mainOtherPowers.getLastAmountOfFiredProjectiles () >= amountOfProjectilesToShoot) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (Time.time > lastTimeAiming + shootPowerDuration) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setShootWeaponState (true);
|
||||
}
|
||||
|
||||
if (!actionUsedByPlayer) {
|
||||
mainFindObjectivesSystem.lookAtCurrentPlaceToShoot ();
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (true);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShootWeaponState (bool state)
|
||||
{
|
||||
mainOtherPowers.inputHoldOrReleaseShootPower (true);
|
||||
mainOtherPowers.inputHoldShootPower ();
|
||||
mainOtherPowers.inputHoldOrReleaseShootPower (false);
|
||||
|
||||
shootingPower = state;
|
||||
}
|
||||
|
||||
public override void resetStatesOnActionEnd ()
|
||||
{
|
||||
if (shootingPower) {
|
||||
shootingPower = false;
|
||||
|
||||
mainOtherPowers.inputHoldOrReleaseShootPower (false);
|
||||
}
|
||||
|
||||
if (aimingPower) {
|
||||
mainOtherPowers.inputSetAimPowerState (false);
|
||||
}
|
||||
|
||||
shootingPower = false;
|
||||
|
||||
aimingPower = false;
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (false);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (false);
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.setLookAtTargetStateInput (false);
|
||||
} else {
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (false);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cb91008317460c42837ec7cc2329854
|
||||
timeCreated: 1697852180
|
||||
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/AI/Custom AI Behavior/shootPowerSimpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class simpleAIAction : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool actionEnabled = true;
|
||||
|
||||
public bool actionUsedByPlayer;
|
||||
|
||||
public float actionDuration;
|
||||
|
||||
public bool useUpdateSystemCoroutine;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool actionActive;
|
||||
|
||||
public Transform currentTarget;
|
||||
|
||||
[Space]
|
||||
[Header ("Event Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventOnStartAction;
|
||||
public UnityEvent eventOnStartAction;
|
||||
|
||||
public bool useEventOnEndAction;
|
||||
public UnityEvent eventOnEndAction;
|
||||
|
||||
[HideInInspector] public Coroutine actionCoroutine;
|
||||
|
||||
|
||||
public virtual void startAIAction ()
|
||||
{
|
||||
if (actionEnabled) {
|
||||
activateCoroutine ();
|
||||
|
||||
actionActive = true;
|
||||
|
||||
if (useEventOnStartAction) {
|
||||
eventOnStartAction.Invoke ();
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("startAIAction");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void endAIAction ()
|
||||
{
|
||||
if (actionEnabled) {
|
||||
if (actionActive) {
|
||||
if (useEventOnEndAction) {
|
||||
eventOnEndAction.Invoke ();
|
||||
}
|
||||
|
||||
actionActive = false;
|
||||
|
||||
stopActionCoroutine ();
|
||||
|
||||
resetStatesOnActionEnd ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("endAIAction");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void stopActionCoroutine ()
|
||||
{
|
||||
if (actionCoroutine != null) {
|
||||
StopCoroutine (actionCoroutine);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void activateCoroutine ()
|
||||
{
|
||||
if (useUpdateSystemCoroutine) {
|
||||
actionCoroutine = StartCoroutine (updateSystemCoroutine ());
|
||||
} else {
|
||||
actionCoroutine = StartCoroutine (updateActionCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator updateActionCoroutine ()
|
||||
{
|
||||
WaitForSeconds delay = new WaitForSeconds (actionDuration);
|
||||
|
||||
yield return delay;
|
||||
|
||||
endAIAction ();
|
||||
}
|
||||
|
||||
IEnumerator updateSystemCoroutine ()
|
||||
{
|
||||
var waitTime = new WaitForFixedUpdate ();
|
||||
|
||||
while (true) {
|
||||
updateSystem ();
|
||||
|
||||
yield return waitTime;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void updateSystem ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void resetStatesOnActionEnd ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void setCustomTarget (Transform newTarget)
|
||||
{
|
||||
currentTarget = newTarget;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6bc013e2b7fa79448156f8558f8c7c3
|
||||
timeCreated: 1697766910
|
||||
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/AI/Custom AI Behavior/simpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class turnBasedCombatAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AITurnBasedCombatSystemBrain mainAITurnBasedCombatSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAITurnBasedCombatSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAITurnBasedCombatSystemBrain.updateBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAITurnBasedCombatSystemBrain.updateAIAttackState (canUseAttack);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAITurnBasedCombatSystemBrain.setSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void setIsCurrentCharacterTurn (bool state)
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.setIsCurrentCharacterTurn (state);
|
||||
}
|
||||
|
||||
public override void setCurrentCharacterTurnTarget (GameObject newTarget)
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.setCurrentCharacterTurnTarget (newTarget);
|
||||
}
|
||||
|
||||
public override void checkStateOnCharacterDead ()
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.checkStateOnCharacterDead ();
|
||||
}
|
||||
|
||||
public override void setAIOnPlayerTeamState (bool state)
|
||||
{
|
||||
mainAITurnBasedCombatSystemBrain.setAIOnPlayerTeamState (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b03a21007268c64893be5e402637954
|
||||
timeCreated: 1697125565
|
||||
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/AI/Custom AI Behavior/turnBasedCombatAIBehavior.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class useAbilitySimpleAIAction : simpleAIAction
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public string currentAbilityName;
|
||||
|
||||
public float minWaitTimeToFinishAbility = 0.4f;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool abilityInProcess;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public AIAbilitiesSystemBrain mainAIAbilitiesSystemBrain;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
float lastTimeAbilityUsed;
|
||||
|
||||
|
||||
public void setCurrentAbilityName (string abilityName)
|
||||
{
|
||||
currentAbilityName = abilityName;
|
||||
}
|
||||
|
||||
public void setCurrentAbilityNameAndStartAIAction (string abilityName)
|
||||
{
|
||||
setCurrentAbilityName (abilityName);
|
||||
|
||||
startAIAction ();
|
||||
}
|
||||
|
||||
public override void startAIAction ()
|
||||
{
|
||||
base.startAIAction ();
|
||||
|
||||
if (actionActive) {
|
||||
if (actionUsedByPlayer) {
|
||||
|
||||
} else {
|
||||
mainFindObjectivesSystem.setPossibleTargetForTurnBasedCombatSystemAsCustomTargetToLook ();
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreLookAtDirectionActiveState (true);
|
||||
}
|
||||
|
||||
mainPlayerCamera.pauseOrPlayCamera (true);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (true);
|
||||
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.lookAtTemporalObjectToLookAtTarget ();
|
||||
}
|
||||
|
||||
lastTimeAbilityUsed = Time.time;
|
||||
|
||||
mainAIAbilitiesSystemBrain.setAndActivateAbilityByName (currentAbilityName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateSystem ()
|
||||
{
|
||||
if (!actionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!mainAIAbilitiesSystemBrain.isAbilityInProcess () && Time.time > minWaitTimeToFinishAbility + lastTimeAbilityUsed) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!actionUsedByPlayer) {
|
||||
mainFindObjectivesSystem.lookAtCurrentPlaceToShoot ();
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (true);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void resetStatesOnActionEnd ()
|
||||
{
|
||||
mainPlayerCamera.pauseOrPlayCamera (false);
|
||||
|
||||
mainPlayerCamera.changeCameraRotationState (false);
|
||||
|
||||
if (actionUsedByPlayer) {
|
||||
mainPlayerCamera.setLookAtTargetStateInput (false);
|
||||
} else {
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (false);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
|
||||
mainFindObjectivesSystem.setIgnoreLookAtDirectionActiveState (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e07e1a8339d07154f91d18eec901c732
|
||||
timeCreated: 1698491769
|
||||
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/AI/Custom AI Behavior/useAbilitySimpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,154 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class useCustomAbilitySimpleAIAction : simpleAIAction
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public string currentAbilityName;
|
||||
|
||||
public float minWaitTimeToFinishAbility = 0.4f;
|
||||
|
||||
public float waitTimeToUseAbility = 0.5f;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setMoveNavMeshPaused;
|
||||
public float moveNamveshPausedDuration;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool abilityInProcess;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public AIAbilitiesSystemBrain mainAIAbilitiesSystemBrain;
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AINavMesh mainAINavmesh;
|
||||
|
||||
|
||||
float lastTimeAbilityUsed;
|
||||
|
||||
bool targetInfoAssigned;
|
||||
|
||||
bool abilityActivated;
|
||||
|
||||
Coroutine setMoveNavMeshPausedCoroutine;
|
||||
|
||||
|
||||
public void setCurrentAbilityName (string abilityName)
|
||||
{
|
||||
currentAbilityName = abilityName;
|
||||
}
|
||||
|
||||
public void setCurrentAbilityNameAndStartAIAction (string abilityName)
|
||||
{
|
||||
setCurrentAbilityName (abilityName);
|
||||
|
||||
startAIAction ();
|
||||
}
|
||||
|
||||
public override void startAIAction ()
|
||||
{
|
||||
base.startAIAction ();
|
||||
|
||||
if (actionActive) {
|
||||
abilityActivated = false;
|
||||
|
||||
targetInfoAssigned = false;
|
||||
|
||||
lastTimeAbilityUsed = Time.time;
|
||||
|
||||
abilityInProcess = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateSystem ()
|
||||
{
|
||||
if (!actionActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!mainAIAbilitiesSystemBrain.isAbilityInProcess () && Time.time > minWaitTimeToFinishAbility + lastTimeAbilityUsed) {
|
||||
endAIAction ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (setMoveNavMeshPaused) {
|
||||
mainAINavmesh.setMoveNavMeshPausedDuringActionState (true);
|
||||
|
||||
if (moveNamveshPausedDuration > 0) {
|
||||
if (setMoveNavMeshPausedCoroutine != null) {
|
||||
StopCoroutine (setMoveNavMeshPausedCoroutine);
|
||||
}
|
||||
|
||||
setMoveNavMeshPausedCoroutine = StartCoroutine (updateSetMoveNavMeshPausedCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
if (targetInfoAssigned) {
|
||||
|
||||
mainFindObjectivesSystem.lookAtCurrentPlaceToShoot ();
|
||||
|
||||
mainAINavmesh.lookAtTaget (true);
|
||||
|
||||
mainAINavmesh.moveNavMesh (Vector3.zero, false, false);
|
||||
} else {
|
||||
if (currentTarget != null) {
|
||||
mainFindObjectivesSystem.setCustomTargetToLook (currentTarget.gameObject);
|
||||
|
||||
targetInfoAssigned = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!abilityActivated) {
|
||||
if (Time.time > waitTimeToUseAbility + lastTimeAbilityUsed) {
|
||||
mainAIAbilitiesSystemBrain.setAndActivateAbilityByName (currentAbilityName);
|
||||
|
||||
abilityActivated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void resetStatesOnActionEnd ()
|
||||
{
|
||||
mainAIAbilitiesSystemBrain.setAndActivateAbilityByName (currentAbilityName);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.lookAtTaget (false);
|
||||
|
||||
mainFindObjectivesSystem.AINavMeshManager.moveNavMesh (Vector3.zero, false, false);
|
||||
|
||||
mainFindObjectivesSystem.resetAITargets ();
|
||||
|
||||
if (setMoveNavMeshPaused) {
|
||||
if (moveNamveshPausedDuration <= 0) {
|
||||
mainAINavmesh.setMoveNavMeshPausedDuringActionState (false);
|
||||
}
|
||||
}
|
||||
|
||||
abilityInProcess = false;
|
||||
|
||||
currentTarget = null;
|
||||
|
||||
abilityActivated = false;
|
||||
}
|
||||
|
||||
IEnumerator updateSetMoveNavMeshPausedCoroutine ()
|
||||
{
|
||||
WaitForSeconds delay = new WaitForSeconds (moveNamveshPausedDuration);
|
||||
|
||||
yield return delay;
|
||||
|
||||
mainAINavmesh.setMoveNavMeshPausedDuringActionState (false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94efe0c995040aa48a6388b55a8c5ee5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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/AI/Custom AI Behavior/useCustomAbilitySimpleAIAction.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,218 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class weaponsAIBehavior : AIBehaviorInfo
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public AIFireWeaponsSystemBrain mainAIFireWeaponsSystemBrain;
|
||||
|
||||
public override void updateAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateAI ();
|
||||
}
|
||||
|
||||
public override void updateAIBehaviorState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateMainFireWeaponsBehavior ();
|
||||
}
|
||||
|
||||
public override void updateAIAttackState (bool canUseAttack)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateMainFireWeaponsAttack (canUseAttack);
|
||||
}
|
||||
|
||||
public override void updateInsideRangeDistance (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateInsideMinDistance (state);
|
||||
}
|
||||
|
||||
public override void resetBehaviorStates ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.resetBehaviorStates ();
|
||||
}
|
||||
|
||||
public override void dropWeapon ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.dropWeapon ();
|
||||
}
|
||||
|
||||
public override void resetAttackState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.resetAttackState ();
|
||||
}
|
||||
|
||||
public override void stopAim ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.stopAim ();
|
||||
}
|
||||
|
||||
public override void checkIfDrawWeaponsWhenResumingAI ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.checkIfDrawWeaponsWhenResumingAI ();
|
||||
}
|
||||
|
||||
public override void disableOnSpottedState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.disableOnSpottedState ();
|
||||
}
|
||||
|
||||
public override void updateWeaponsAvailableState ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateWeaponsAvailableState ();
|
||||
}
|
||||
|
||||
public override void setBehaviorStatesPausedState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setBehaviorStatesPausedState (state);
|
||||
}
|
||||
|
||||
public override void setSystemActiveState (bool state)
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.setWeaponsSystemActiveState (state);
|
||||
}
|
||||
|
||||
public override bool carryingWeapon ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mainAIFireWeaponsSystemBrain.isWeaponEquiped ();
|
||||
}
|
||||
|
||||
public override void updateIfCarryingWeapon ()
|
||||
{
|
||||
if (!behaviorEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mainAIFireWeaponsSystemBrain.updateIfCarryingWeapon ();
|
||||
}
|
||||
|
||||
public override void setWaitToActivateAttackActiveState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setWaitToActivateAttackActiveState (state);
|
||||
}
|
||||
|
||||
public override void setUseRandomWalkEnabledState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setUseRandomWalkEnabledState (state);
|
||||
}
|
||||
|
||||
public override void setOriginalUseRandomWalkEnabledState ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setOriginalUseRandomWalkEnabledState ();
|
||||
}
|
||||
|
||||
public override void checkNoWeaponsAvailableState ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.checkNoFireWeaponsAvailableState ();
|
||||
}
|
||||
|
||||
public override void setDrawOrHolsterWeaponState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setDrawOrHolsterWeaponState (state);
|
||||
}
|
||||
|
||||
public override void stopCurrentAttackInProcess ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.stopCurrentAttackInProcess ();
|
||||
}
|
||||
|
||||
public override void setTurnBasedCombatActionActiveState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setTurnBasedCombatActionActiveState (state);
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterSpawn ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.checkAIBehaviorStateOnCharacterSpawn ();
|
||||
}
|
||||
|
||||
public override void checkAIBehaviorStateOnCharacterDespawn ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.checkAIBehaviorStateOnCharacterDespawn ();
|
||||
}
|
||||
|
||||
public override void checkIfDisableCurrentWeaponToChangeAttackMode (string newModeName)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.checkIfDisableCurrentWeaponToChangeAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void changeCurrentAttackMode (string newModeName)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.changeCurrentAttackMode (newModeName);
|
||||
}
|
||||
|
||||
public override void stopAttackState ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.stopAttackState ();
|
||||
}
|
||||
|
||||
public override void setAttackEnabledState (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setAttackEnabledState (state);
|
||||
}
|
||||
|
||||
public override void updateCurrentTargetSelectedInfo ()
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.updateCurrentTargetSelectedInfo ();
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public override void setAttackEnabledStateFromEditor (bool state)
|
||||
{
|
||||
mainAIFireWeaponsSystemBrain.setAttackEnabledStateFromEditor (state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d48a5d443c77d3644a079d8e69b1569b
|
||||
timeCreated: 1602683372
|
||||
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/AI/Custom AI Behavior/weaponsAIBehavior.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user