Inheritance: ActorMission
Esempio n. 1
0
        /// <summary>
        /// Generates enemies on the map.
        /// </summary>
        /// <param name="enemyCount"></param>
        /// <param name="enemyType"></param>
        /// <returns></returns>
        public MapBlock[,] GenerateEnemies(MapBlock[,] blocks, int enemyCount, string enemyType, out DRObjects.Actor[] actors, int level, int equipmentCost = 0)
        {
            ItemFactory.ItemFactory fact = new ItemFactory.ItemFactory();
            List<Actor> actorList = new List<Actor>();

            //We'll just pick blocks at random until we fail 50 times in a row or run out of enemies to place
            int failureCount = 0;

            for (int i = 0; i < enemyCount; i++)
            {
                if (failureCount == 50)
                {
                    break;
                }

                int x = random.Next(blocks.GetLength(0));
                int y = random.Next(blocks.GetLength(1));

                //Is the block free
                if (blocks[x, y].MayContainItems)
                {
                    int returnedID = -1;
                    //Put the enemy in there

                    //Get the basic Actor object

                    double multiplier = GameState.Random.Next(75, 125);

                    multiplier /= 100; //So we get a number between 0.75 and 1.25

                    Actor actor = ActorGeneration.CreateActor(enemyType, null, null, (int)(level * multiplier), (int)(equipmentCost * multiplier), null, out returnedID);

                    var mapObject = fact.CreateItem("enemies", returnedID);

                    (mapObject as LocalCharacter).Actor = actor;

                    //Create the Actor
                    actor.GlobalCoordinates = null; //useless for now
                    actor.IsPlayerCharacter = false;
                    actor.MapCharacter = mapObject;

                    actorList.Add(actor);

                    blocks[x, y].ForcePutItemOnBlock(mapObject);

                    int missionType = random.Next(3);

                    if (missionType == 0)
                    {
                        //33% of them will Wander -
                        WanderMission mission = new WanderMission();
                        mission.WanderPoint = new MapCoordinate(x, y, 0, MapType.LOCAL);
                        mission.WanderRectangle = new Rectangle(0, 0, blocks.GetLength(0), blocks.GetLength(1));

                        actor.MissionStack.Push(mission);
                    }
                    else if (missionType == 1)
                    {
                        //33% will idle
                        IdleMission mission = new IdleMission();
                        actor.MissionStack.Push(mission);
                    }
                    else
                    {
                        //The rest will patrol
                        PatrolMission mission = new PatrolMission();
                        //Don't give them the point. We;ll choose it later
                        actor.MissionStack.Push(mission);
                    }

                    failureCount = 0;//reset
                }
                else
                {
                    failureCount++;
                    i--; //And again
                }
            }

            //return the map
            actors = actorList.ToArray();
            return blocks;
        }
Esempio n. 2
0
        public static ActionFeedback[] PatrolMission(PatrolMission mission, Actor actor)
        {
            //Create a move to mission which moves the actor to the point of interest
            PointOfInterest poi = GameState.LocalMap.PointsOfInterest[GameState.Random.Next(GameState.LocalMap.PointsOfInterest.Count)];

            //Push the patrol on the stack
            actor.MissionStack.Push(mission);

            //Log it
            Console.WriteLine("Actor " + actor.ToString() + " is going to" + poi.Coordinate.ToString());

            actor.CurrentMission = new WalkToMission()
            {
                TargetCoordinate = poi.Coordinate
            };

            return new ActionFeedback[] { };
        }