コード例 #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 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());
            }
        }
コード例 #4
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;
        }
コード例 #5
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;
        }