コード例 #1
0
ファイル: MobPatrol.cs プロジェクト: ltloibrights/AsyncRPG
        public override void Perform(MobUpdateContext context)
        {
            NavMesh navMesh= context.moveRequest.Room.runtime_nav_mesh;
            float max_range= 5.0f; // Compute max range from mob type
            uint[] navCells = navMesh.ComputeNavCellsInRadius(context.mob.Position, max_range, false);
            Random rng = context.mob.AIState.behavior_data.GetMobRandomNumberGenerator();
            RNGUtilities.DeterministicKnuthShuffle(rng, navCells);
            Point3d targetPosition = new Point3d(context.mob.Position);

            // Pick the first random nav cell in range that we have line of sight to
            foreach (uint navCellIndex in navCells)
            {
                Point3d testTarget = navMesh.ComputeNavCellCenter(navCellIndex);
                bool canSee = navMesh.PointCanSeeOtherPoint(context.mob.Position, testTarget);

                if (canSee)
                {
                    targetPosition = testTarget;
                    break;
                }
            }

            // Compute the side effect of actually moving the mob on the update context
            context.MoveMob(targetPosition);
            context.MobPostDialog("Soo bored...");
        }
コード例 #2
0
        public override void Perform(MobUpdateContext context)
        {
            NavMesh navMesh   = context.moveRequest.Room.runtime_nav_mesh;
            float   max_range = 5.0f; // Compute max range from mob type

            uint[] navCells = navMesh.ComputeNavCellsInRadius(context.mob.Position, max_range, false);
            Random rng      = context.mob.AIState.behavior_data.GetMobRandomNumberGenerator();

            RNGUtilities.DeterministicKnuthShuffle(rng, navCells);
            Point3d targetPosition = new Point3d(context.mob.Position);

            // Pick the first random nav cell in range that we have line of sight to
            foreach (uint navCellIndex in navCells)
            {
                Point3d testTarget = navMesh.ComputeNavCellCenter(navCellIndex);
                bool    canSee     = navMesh.PointCanSeeOtherPoint(context.mob.Position, testTarget);

                if (canSee)
                {
                    targetPosition = testTarget;
                    break;
                }
            }

            // Compute the side effect of actually moving the mob on the update context
            context.MoveMob(targetPosition);
            context.MobPostDialog("Soo bored...");
        }
コード例 #3
0
        public override bool CanActivate(MobUpdateContext context)
        {
            MobAIPerceptionState perception = context.mob.AIState.perception_data;
            EntityProp           prop       = perception.GetPlayerTargetProp();
            bool canActivate = (prop != null && prop.propStatus == EntityProp.ePropStatus.orphaned);

            return(canActivate);
        }
コード例 #4
0
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                (energyTankProp != null &&
                 energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                 energyTankProp.faction != GameConstants.eFaction.ai &&
                 energyTankProp.energy > 0);
        }
コード例 #5
0
        public void Update(
            MobUpdateContext context)
        {
            // Get the current behavior running, if any
            MobAIBehaviorState behaviorState = context.mob.AIState.behavior_data;

            behaviorState.active_behavior_stack = "";
            ActivateBehaviors(context, m_root);

            //currentBehavior.GetType().Name;
        }
コード例 #6
0
        public void Update(
            MobUpdateContext context)
        {
            // Get the current behavior running, if any
            MobAIBehaviorState behaviorState = context.mob.AIState.behavior_data;

            behaviorState.active_behavior_stack = "";
            ActivateBehaviors(context, m_root);

            //currentBehavior.GetType().Name;
        }
コード例 #7
0
        public override void Perform(MobUpdateContext context)
        {
            MobAIPerceptionState perception = context.mob.AIState.perception_data;
            EntityProp           prop       = perception.GetPlayerTargetProp();

            if (prop.distance >= WorldConstants.ROOM_TILE_SIZE)
            {
                context.MobPostDialog("I though I saw someone over here");
                context.MoveMob(prop.GetPosition());
            }
        }
コード例 #8
0
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                (energyTankProp != null &&
                 context.mob.MobType.Abilities.energy_tank_drain_per_turn > 0 &&
                 // Even if we can't use the energy, we can deny the player from having it
                 //energyTankProp.energy < context.mob.MobType.MaxEnergy &&
                 energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                 energyTankProp.faction == GameConstants.eFaction.ai &&
                 energyTankProp.energy > 0);
        }
コード例 #9
0
ファイル: MobPatrol.cs プロジェクト: ltloibrights/AsyncRPG
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                energyTankProp != null &&
                context.mob.MobType.Abilities.energy_tank_drain_per_turn > 0 &&
                // Even if we can't use the energy, we can deny the player from having it
                //energyTankProp.energy < context.mob.MobType.MaxEnergy &&
                energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                energyTankProp.faction == GameConstants.eFaction.ai &&
                energyTankProp.energy > 0;
        }
コード例 #10
0
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank     = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                // We can only drain up to what we can take and whats left in the energy tank
                int drainAmount =
                    Math.Min(energyTank.Energy, context.mob.MobType.Abilities.energy_tank_drain_per_turn);

                context.MobDrainEnergyTank(energyTank, drainAmount);
                context.MobPostDialog("Sweet Sweet Energy...");
            }
            else
            {
                context.MoveMob(energyTank.Position);
                context.MobPostDialog("What?! Someone hacked this! Grrr...");
            }

            // Update the energy on the prop
            energyTankProp.energy = energyTank.Energy;
        }
コード例 #11
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);
        }
コード例 #12
0
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank     = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.player)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Which team owns one less energy tank? Team Player!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.neutral)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Energy Tank claimed for the AI Team!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Oh! I guess we already owned this energy tank");
            }

            // Update the faction on the prop
            energyTankProp.faction = energyTank.Faction;
        }
コード例 #13
0
 public override bool CanActivate(MobUpdateContext context)
 {
     return(false);
 }
コード例 #14
0
 public override bool CanActivate(MobUpdateContext context)
 {
     return false;
 }
コード例 #15
0
ファイル: MobBehavior.cs プロジェクト: ltloibrights/AsyncRPG
 public virtual bool CanActivate(MobUpdateContext context)
 {
     return true;
 }
コード例 #16
0
ファイル: MobBehavior.cs プロジェクト: ltloibrights/AsyncRPG
 public virtual void Perform(MobUpdateContext context)
 {
     // Nothing to do
 }
コード例 #17
0
 public void Update(
     MobUpdateContext context)
 {
     MobBehaviorTree.GetInstance().Update(context);
 }
コード例 #18
0
 public virtual bool CanActivate(MobUpdateContext context)
 {
     return(true);
 }
コード例 #19
0
 public virtual void Perform(MobUpdateContext context)
 {
     // Nothing to do
 }
コード例 #20
0
ファイル: MobPatrol.cs プロジェクト: ltloibrights/AsyncRPG
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                // We can only drain up to what we can take and whats left in the energy tank
                int drainAmount =
                    Math.Min(energyTank.Energy, context.mob.MobType.Abilities.energy_tank_drain_per_turn);

                context.MobDrainEnergyTank(energyTank, drainAmount);
                context.MobPostDialog("Sweet Sweet Energy...");
            }
            else
            {
                context.MoveMob(energyTank.Position);
                context.MobPostDialog("What?! Someone hacked this! Grrr...");
            }

            // Update the energy on the prop
            energyTankProp.energy = energyTank.Energy;
        }
コード例 #21
0
 public void Update(
     MobUpdateContext context)
 {
     MobBehaviorTree.GetInstance().Update(context);
 }
コード例 #22
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;
        }
コード例 #23
0
ファイル: MobPatrol.cs プロジェクト: ltloibrights/AsyncRPG
        public override void Perform(MobUpdateContext context)
        {
            EntityProp energyTankProp = context.mob.AIState.perception_data.GetEnergyTankTargetProp();
            EnergyTank energyTank = context.moveRequest.EnergyTanks.Find(e => e.ID == energyTankProp.target_object_id);

            if (energyTank.Faction == GameConstants.eFaction.player)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Which team owns one less energy tank? Team Player!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.neutral)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Energy Tank claimed for the AI Team!");
            }
            else if (energyTank.Faction == GameConstants.eFaction.ai)
            {
                context.MobHackEnergyTank(energyTank);
                context.MobPostDialog("Oh! I guess we already owned this energy tank");
            }

            // Update the faction on the prop
            energyTankProp.faction = energyTank.Faction;
        }
コード例 #24
0
ファイル: MobPatrol.cs プロジェクト: ltloibrights/AsyncRPG
        public override bool CanActivate(MobUpdateContext context)
        {
            EntityProp energyTankProp= context.mob.AIState.perception_data.GetEnergyTankTargetProp();

            return
                energyTankProp != null &&
                energyTankProp.propStatus >= EntityProp.ePropStatus.assumed &&
                energyTankProp.faction != GameConstants.eFaction.ai &&
                energyTankProp.energy > 0;
        }