public bool Validate(vIFSMBehaviourController fsmBehaviour) { if (trueValue) { isValid = /*if a*/ decision ? /*if b*/ decision.Decide(fsmBehaviour) : /*else b*/ true; } else { isValid = !(/*if a*/ decision ? /*if b*/ decision.Decide(fsmBehaviour) : /*else b*/ false); } #if UNITY_EDITOR if (validationByController == null) { validationByController = new Dictionary <vIFSMBehaviourController, bool>(); } if (validationByController.ContainsKey(fsmBehaviour)) { validationByController[fsmBehaviour] = isValid; } else { validationByController.Add(fsmBehaviour, isValid); } #endif return(isValid); }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.aiController is vIControlAIShooter) { ControlAttack(fsmBehaviour, fsmBehaviour.aiController as vIControlAIShooter); } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (executionType == vFSMComponentExecutionType.OnStateEnter) { fsmBehaviour.aiController.SetLineOfSight(fieldOfView, minDistanceToDetect, maxDistanceToDetect, lostTargetDistance); } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour != null && fsmBehaviour.aiController.currentTarget.transform && fsmBehaviour.aiController.targetInLineOfSight) { fsmBehaviour.aiController.RotateTo(fsmBehaviour.aiController.lastTargetPosition); } }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController != null) { if (fsmBehaviour.aiController.HasComponent <vAINoiseListener>()) { var noiseListener = fsmBehaviour.aiController.GetAIComponent <vAINoiseListener>(); vNoise noise = null; if (findNewNoise) { if (specificType) { noise = noiseListener.GetNearNoiseByTypes(noiseTypes); } else { noise = noiseListener.GetNearNoise(); } } else { noise = noiseListener.lastListenedNoise; } if (noise != null) { return(CompareDistance(Vector3.Distance(fsmBehaviour.aiController.transform.position, noise.position), distance)); } } } return(true); }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (executionType == vFSMComponentExecutionType.OnStateEnter) { fsmBehaviour.aiController.SetDetectionTags(tags); } }
protected virtual void DoWander(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour == null) { return; } if (fsmBehaviour.aiController.isDead) { return; } if (fsmBehaviour.aiController.isInDestination || Vector3.Distance(fsmBehaviour.aiController.targetDestination, fsmBehaviour.aiController.transform.position) <= 0.5f + fsmBehaviour.aiController.stopingDistance) { fsmBehaviour.aiController.SetSpeed(speed); var angle = Random.Range(-90f, 90f); var dir = Quaternion.AngleAxis(angle, Vector3.up) * fsmBehaviour.aiController.transform.forward; var movePoint = fsmBehaviour.aiController.transform.position + dir.normalized * (Random.Range(1f, 4f) + fsmBehaviour.aiController.stopingDistance); if (wanderInStrafe) { fsmBehaviour.aiController.StrafeMoveTo(movePoint, dir.normalized); } else { fsmBehaviour.aiController.MoveTo(movePoint); } } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (executionType == vFSMComponentExecutionType.OnStateEnter) { fsmBehaviour.aiController.SetObstaclesLayer(newLayer); } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.aiController.receivedDamage.lastSender) { fsmBehaviour.aiController.SetCurrentTarget(fsmBehaviour.aiController.receivedDamage.lastSender); } }
public void DoActions(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType) { switch (executionType) { case vFSMComponentExecutionType.OnStateEnter: for (int i = 0; i < actionsEnter.Count; i++) { actionsEnter[i].DoAction(fsmBehaviour, vFSMComponentExecutionType.OnStateEnter); } break; case vFSMComponentExecutionType.OnStateExit: for (int i = 0; i < actionsExit.Count; i++) { actionsExit[i].DoAction(fsmBehaviour, vFSMComponentExecutionType.OnStateExit); } break; case vFSMComponentExecutionType.OnStateUpdate: for (int i = 0; i < actionsUpdate.Count; i++) { actionsUpdate[i].DoAction(fsmBehaviour, vFSMComponentExecutionType.OnStateUpdate); } break; } }
protected virtual bool CheckValue(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour == null) { return(false); } float healthPercentage = (fsmBehaviour.aiController.currentHealth / fsmBehaviour.aiController.MaxHealth) * 100f; switch (checkValue) { case vCheckValue.Equals: return(healthPercentage == value); case vCheckValue.Less: return(healthPercentage < value); case vCheckValue.Greater: return(healthPercentage > value); case vCheckValue.NoEqual: return(healthPercentage != value); } return(false); }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.messageReceiver) { fsmBehaviour.messageReceiver.Send(listenerName, message); } }
protected virtual void FindTarget(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour != null) { fsmBehaviour.aiController.FindTarget(checkForObstacles); } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (executionType == vFSMComponentExecutionType.OnStateEnter) { fsmBehaviour.aiController.RemoveCurrentTarget(); } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.aiController != null) { if (fsmBehaviour.aiController.HasComponent <vAINoiseListener>()) { fsmBehaviour.aiController.SetSpeed(speed); var noiseListener = fsmBehaviour.aiController.GetAIComponent <vAINoiseListener>(); vNoise noise = null; if (findNewNoise) { if (specificType) { noise = noiseListener.GetNearNoiseByTypes(noiseTypes); } else { noise = noiseListener.GetNearNoise(); } } else { noise = noiseListener.lastListenedNoise; } if (noise != null) { fsmBehaviour.aiController.MoveTo(noise.position); if (lookToNoisePosition) { fsmBehaviour.aiController.LookTo(noise.position, offsetLookHeight: 0); } } } } }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.aiController.isDead && !recoverWhenIsDead) { return; } AddHealth(fsmBehaviour); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour != null && fsmBehaviour.aiController != null && fsmBehaviour.aiController.currentTarget.transform) { return(fsmBehaviour.aiController.currentTarget.isLost); } return(true); }
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour.aiController.HasComponent <vAICompanion>()) { fsmBehaviour.aiController.SetSpeed(speed); MoveToFriendPosition(fsmBehaviour.aiController.GetAIComponent <vAICompanion>()); } }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController == null || !fsmBehaviour.aiController.currentTarget.isFighter) { return(false); } return(fsmBehaviour.aiController.currentTarget.isAttacking); }
public void Draw(vIFSMBehaviourController target, GUISkin skin) { if (target == null) { return; } DrawFSMStateInfo(target, skin); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController.currentTarget.transform != null) { return(targetTags.Contains(fsmBehaviour.aiController.currentTarget.transform.gameObject.tag)); } return(true); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController == null) { return(false); } return(fsmBehaviour.aiController.currentTarget.transform != null); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController == null || !fsmBehaviour.aiController.currentTarget.isCharacter) { return(false); } return(fsmBehaviour.aiController.currentTarget.character.isCrouching); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController.HasComponent <vAICompanion>()) { return(fsmBehaviour.aiController.GetAIComponent <vAICompanion>().forceFollow); } return(true); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (!(fsmBehaviour.aiController is vIControlAICombat)) { return(false); } return((fsmBehaviour.aiController as vIControlAICombat).isInCombat); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController != null) { fsmBehaviour.aiController.FindTarget(); return(fsmBehaviour.aiController.currentTarget.transform != null); } return(true); }
public override bool Decide(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController is vIControlAIShooter) { vIControlAIShooter shooter = (fsmBehaviour.aiController as vIControlAIShooter); return(shooter.shooterManager ? shooter.shooterManager.isShooting || shooter.isAttacking : false); } return(true); }
public override void UpdateState(vIFSMBehaviourController fsmBehaviour) { if (fsmBehaviour.aiController is vIControlAICombat) { UpdateCombatState(fsmBehaviour.aiController as vIControlAICombat); } base.UpdateState(fsmBehaviour); }
IEnumerator EnableFSM(vIFSMBehaviourController vIFSM) { if (vIFSM != null) { yield return(new WaitForSeconds(delayToEnableFSM)); vIFSM.isStopped = false; } }
public override void OnStateExit(vIFSMBehaviourController fsmBehaviour) { base.OnStateExit(fsmBehaviour); if (fsmBehaviour.aiController is vIControlAICombat) { var aiCombat = (fsmBehaviour.aiController as vIControlAICombat); aiCombat.ResetAttackTime(); aiCombat.isInCombat = false; } }