Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 6
0
 public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
 {
     if (executionType == vFSMComponentExecutionType.OnStateEnter)
     {
         fsmBehaviour.aiController.SetDetectionTags(tags);
     }
 }
Esempio n. 7
0
        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);
                }
            }
        }
Esempio n. 8
0
 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);
     }
 }
Esempio n. 10
0
            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;
                }
            }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 14
0
 public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
 {
     if (executionType == vFSMComponentExecutionType.OnStateEnter)
     {
         fsmBehaviour.aiController.RemoveCurrentTarget();
     }
 }
Esempio n. 15
0
 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);
                 }
             }
         }
     }
 }
Esempio n. 16
0
 public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
 {
     if (fsmBehaviour.aiController.isDead && !recoverWhenIsDead)
     {
         return;
     }
     AddHealth(fsmBehaviour);
 }
Esempio n. 17
0
 public override bool Decide(vIFSMBehaviourController fsmBehaviour)
 {
     if (fsmBehaviour != null && fsmBehaviour.aiController != null && fsmBehaviour.aiController.currentTarget.transform)
     {
         return(fsmBehaviour.aiController.currentTarget.isLost);
     }
     return(true);
 }
Esempio n. 18
0
 public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
 {
     if (fsmBehaviour.aiController.HasComponent <vAICompanion>())
     {
         fsmBehaviour.aiController.SetSpeed(speed);
         MoveToFriendPosition(fsmBehaviour.aiController.GetAIComponent <vAICompanion>());
     }
 }
Esempio n. 19
0
 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);
 }
Esempio n. 21
0
 public override bool Decide(vIFSMBehaviourController fsmBehaviour)
 {
     if (fsmBehaviour.aiController.currentTarget.transform != null)
     {
         return(targetTags.Contains(fsmBehaviour.aiController.currentTarget.transform.gameObject.tag));
     }
     return(true);
 }
Esempio n. 22
0
 public override bool Decide(vIFSMBehaviourController fsmBehaviour)
 {
     if (fsmBehaviour.aiController == null)
     {
         return(false);
     }
     return(fsmBehaviour.aiController.currentTarget.transform != null);
 }
Esempio n. 23
0
 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);
 }
Esempio n. 25
0
 public override bool Decide(vIFSMBehaviourController fsmBehaviour)
 {
     if (!(fsmBehaviour.aiController is vIControlAICombat))
     {
         return(false);
     }
     return((fsmBehaviour.aiController as vIControlAICombat).isInCombat);
 }
Esempio n. 26
0
 public override bool Decide(vIFSMBehaviourController fsmBehaviour)
 {
     if (fsmBehaviour.aiController != null)
     {
         fsmBehaviour.aiController.FindTarget();
         return(fsmBehaviour.aiController.currentTarget.transform != null);
     }
     return(true);
 }
Esempio n. 27
0
 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);
 }
Esempio n. 28
0
        public override void UpdateState(vIFSMBehaviourController fsmBehaviour)
        {
            if (fsmBehaviour.aiController is vIControlAICombat)
            {
                UpdateCombatState(fsmBehaviour.aiController as vIControlAICombat);
            }

            base.UpdateState(fsmBehaviour);
        }
Esempio n. 29
0
            IEnumerator EnableFSM(vIFSMBehaviourController vIFSM)
            {
                if (vIFSM != null)
                {
                    yield return(new WaitForSeconds(delayToEnableFSM));

                    vIFSM.isStopped = false;
                }
            }
Esempio n. 30
0
 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;
     }
 }