Exemple #1
0
        public bool CreateBarbarianTribeNear(byte level, int campCount, uint x, uint y, byte radius)
        {
            Position barbarianCampPosition;

            int tries = 0;

            do
            {
                tileLocator.RandomPoint(new Position(x, y), radius, true, out barbarianCampPosition);

                if (barbarianTribeConfigurator.IsLocationAvailable(barbarianCampPosition))
                {
                    break;
                }

                if (tries++ > 150)
                {
                    return(false);
                }

                if (tries > 0 && radius == 0)
                {
                    return(false);
                }
            }while (true);

            IBarbarianTribe barbarianTribe = barbarianTribeFactory.CreateBarbarianTribe(idGenerator.GetNext(), level, barbarianCampPosition, campCount);

            if (barbarianTribe != null)
            {
                Add(barbarianTribe);
            }

            return(true);
        }