Beispiel #1
0
        public override LivingObject[] SetupWorldForNewPlayer(Player player)
        {
            const int NUM_DWARVES = 1;

            // XXX entry location
            var env = this.World.AllObjects.OfType <Dwarrowdelf.Server.EnvironmentObject>().First();

            var list = new List <LivingObject>();

            for (int i = 0; i < NUM_DWARVES; ++i)
            {
                IntPoint3 p;
                do
                {
                    p = new IntPoint3(m_random.Next(env.Width), m_random.Next(env.Height), env.HomeLocation.Z);
                } while (!EnvironmentHelpers.CanEnter(env, p));

                var l = CreateDwarf(i);

                if (!l.MoveTo(env, p))
                {
                    throw new Exception();
                }

                list.Add(l);
            }

            return(list.ToArray());
        }
Beispiel #2
0
        IntPoint3 GetRandomSurfaceLocation(Environment env, int zLevel)
        {
            IntPoint3 p;
            int       iter = 0;

            do
            {
                if (iter++ > 10000)
                {
                    throw new Exception();
                }

                p = new IntPoint3(m_random.Next(env.Width), m_random.Next(env.Height), zLevel);
            } while (!EnvironmentHelpers.CanEnter(env, p));

            return(p);
        }