public MobBehavior GetFirstChildOfType(Type behaviorType)
        {
            MobBehavior matchingBehavior = null;

            if (behaviorType == null)
            {
                return(null);
            }
            else if (this.GetType() == behaviorType)
            {
                matchingBehavior = this;
            }
            else if (m_children != null)
            {
                foreach (MobBehavior childBehavior in m_children)
                {
                    matchingBehavior = childBehavior.GetFirstChildOfType(behaviorType);

                    if (matchingBehavior != null)
                    {
                        break;
                    }
                }
            }

            return(matchingBehavior);
        }
        public MobBehavior GetFirstChildOfName(String behaviorName)
        {
            MobBehavior matchingBehavior = null;

            if (behaviorName == "")
            {
                matchingBehavior = null;
            }
            else if (this.GetType().Name == behaviorName)
            {
                matchingBehavior = this;
            }
            else if (m_children != null)
            {
                foreach (MobBehavior childBehavior in m_children)
                {
                    matchingBehavior = childBehavior.GetFirstChildOfName(behaviorName);

                    if (matchingBehavior != null)
                    {
                        break;
                    }
                }
            }

            return(matchingBehavior);
        }
Example #3
0
 public MobSearchBehavior(MobBehavior parent) :
     base(parent)
 {
     m_children = new MobBehavior[] {
         new MobInvestigateEnemyStimuli(this),
         new MobInvestigateFriendlyStimuli(this),
     };
 }
Example #4
0
 public MobPatrolBehavior(MobBehavior parent) :
     base(parent)
 {
     m_children = new MobBehavior[] {
         new MobDrainEnergyTankBehavior(this),
         new MobHackEnergyTankBehavior(this),
         new MobAimlessWanderBehavior(this),
     };
 }
Example #5
0
 public MobCombatBehavior(MobBehavior parent) :
     base(parent)
 {
     m_children = new MobBehavior[] {
         new MobRepairFriendBehavior(this),
         new MobGiveEnergyToFriendBehavior(this),
         new MobSpawnHelperBotBehavior(this),
         new MobAttackEnemyBehavior(this)
     };
 }
 public MobSelfPreserveBehavior(MobBehavior parent) :
     base(parent)
 {
     m_children = new MobBehavior[] {
         new MobTakeEnergyFromTankBehavior(this),
         new MobRequestRepairBehavior(this),
         new MobRequestEnergyBehavior(this),
         new MobFleeBehavior(this)
     };
 }
Example #7
0
 public MobSelfPreserveBehavior(MobBehavior parent)
     : base(parent)
 {
     m_children = new MobBehavior[] {
         new MobTakeEnergyFromTankBehavior(this),
         new MobRequestRepairBehavior(this),
         new MobRequestEnergyBehavior(this),
         new MobFleeBehavior(this)
     };
 }
Example #8
0
        private bool ActivateBehaviors(
            MobUpdateContext context,
            MobBehavior behavior)
        {
            bool foundBehaviorToActivate = false;

            // Can the behavior be activated
            if (behavior.CanActivate(context))
            {
                foundBehaviorToActivate = true;

                // Perform the behavior we can activate
                behavior.Perform(context);

                // Add the behavior to the list of behaviors that was activated
                if (context.mob.AIState.behavior_data.active_behavior_stack.Length > 0)
                {
                    context.mob.AIState.behavior_data.active_behavior_stack += ".";
                }
                context.mob.AIState.behavior_data.active_behavior_stack += behavior.GetType().Name;

                // Try to activate children behaviors
                if (behavior.Children != null)
                {
                    foreach (MobBehavior childBehavior in behavior.Children)
                    {
                        // Stop searching if this child behavior could be activated
                        if (ActivateBehaviors(context, childBehavior))
                        {
                            break;
                        }
                    }
                }
            }

            return(foundBehaviorToActivate);
        }
Example #9
0
 private MobBehaviorTree()
 {
     m_root = new MobRootBehavior();
 }
Example #10
0
 public MobDrainEnergyTankBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #11
0
 public MobHackEnergyTankBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #12
0
 public MobBehavior(MobBehavior parent)
 {
     m_priority = -1;
     m_parent   = parent;
     m_children = null;
 }
Example #13
0
 private MobBehaviorTree()
 {
     m_root = new MobRootBehavior();
 }
Example #14
0
 public MobInvestigateEnemyStimuli(MobBehavior parent) :
     base(parent)
 {
 }
Example #15
0
 public MobTakeEnergyFromTankBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #16
0
 public MobRequestEnergyBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #17
0
 public MobDrainEnergyTankBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #18
0
 public MobPatrolBehavior(MobBehavior parent)
     : base(parent)
 {
     m_children = new MobBehavior[] {
         new MobDrainEnergyTankBehavior(this),
         new MobHackEnergyTankBehavior(this),
         new MobAimlessWanderBehavior(this),
     };
 }
Example #19
0
 public MobAimlessWanderBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #20
0
 public MobHackEnergyTankBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #21
0
        private bool ActivateBehaviors(
            MobUpdateContext context,
            MobBehavior behavior)
        {
            bool foundBehaviorToActivate = false;

            // Can the behavior be activated
            if (behavior.CanActivate(context))
            {
                foundBehaviorToActivate = true;

                // Perform the behavior we can activate
                behavior.Perform(context);

                // Add the behavior to the list of behaviors that was activated
                if (context.mob.AIState.behavior_data.active_behavior_stack.Length > 0)
                {
                    context.mob.AIState.behavior_data.active_behavior_stack += ".";
                }
                context.mob.AIState.behavior_data.active_behavior_stack += behavior.GetType().Name;

                // Try to activate children behaviors
                if (behavior.Children != null)
                {
                    foreach (MobBehavior childBehavior in behavior.Children)
                    {
                        // Stop searching if this child behavior could be activated
                        if (ActivateBehaviors(context, childBehavior))
                        {
                            break;
                        }
                    }
                }
            }

            return foundBehaviorToActivate;
        }
 public MobTakeEnergyFromTankBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #23
0
 public MobBehavior(MobBehavior parent)
 {
     m_priority = -1;
     m_parent = parent;
     m_children = null;
 }
 public MobRequestEnergyBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #25
0
 public MobFleeBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #26
0
 public MobInvestigateFriendlyStimuli(MobBehavior parent) :
     base(parent)
 {
 }
Example #27
0
 public MobRequestRepairBehavior(MobBehavior parent)
     : base(parent)
 {
 }
Example #28
0
 public MobRepairFriendBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #29
0
 public MobGiveEnergyToFriendBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #30
0
 public MobAttackEnemyBehavior(MobBehavior parent) :
     base(parent)
 {
 }
 public MobRequestRepairBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #32
0
 public MobSpawnHelperBotBehavior(MobBehavior parent) :
     base(parent)
 {
 }
 public MobFleeBehavior(MobBehavior parent) :
     base(parent)
 {
 }
Example #34
0
 public MobAimlessWanderBehavior(MobBehavior parent) :
     base(parent)
 {
 }