Пример #1
0
        public virtual string pickCameraSpawnPoint(string spawnGroups)
        {
            SimObject spawnpoint = null;

            String[] lspawngroups = spawnGroups.Split(' ');

            foreach (SimSet group in lspawngroups)
            {
                if (!group.isObject())
                {
                    continue;
                }
                spawnpoint = group.getRandom();
                if (spawnpoint.isObject())
                {
                    return(spawnpoint);
                }
            }
            SpawnSphere DefaultCameraSpawnSphere = "DefaultCameraSpawnSphere";

            if (!DefaultCameraSpawnSphere.isObject())
            {
                ObjectCreator spawn = new ObjectCreator("SpawnSphere", "DefaultCameraSpawnSphere");
                spawn["dataBlock"]      = "SpawnSphereMarker";
                spawn["spawnClass"]     = sGlobal["$Game::DefaultCameraClass"];
                spawn["spawnDatablock"] = sGlobal["$Game::DefaultCameraDataBlock"];
                SpawnSphere spawnobj = spawn.Create();

                ((SimSet)"MissionCleanup").pushToBack(spawnobj);
            }

            return(DefaultCameraSpawnSphere);
        }
Пример #2
0
        public virtual TransformF PointInSpawnSphere(Player objectToSpawn, SpawnSphere spawnSphere)
        {
            bool spawnLocationFound = false;
            int  attemptsToSpawn    = 0;

            TransformF spherLocationP3F = new TransformF();


            while (!spawnLocationFound && attemptsToSpawn < 5)
            {
                spherLocationP3F = spawnSphere.getTransform();

                Random r = new Random();

                float angleY  = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F);
                float angleXZ = (float)tMath.mDegToRad((r.NextDouble() * 100) * tMath.M_2PI_F);

                int radius = spawnSphere["radius"].AsInt();
                spherLocationP3F.mPositionX += (float)(Math.Cos(angleY) * Math.Sin(angleXZ) * (r.Next(radius * -1, radius)));
                spherLocationP3F.mPositionY += (float)(Math.Cos(angleXZ) * (r.Next(radius * -1, radius)));
                spawnLocationFound           = true;

                // Now have to check that another object doesn't already exist at this spot.
                // Use the bounding box of the object to check if where we are about to spawn in is
                // clear.


                TransformF boundingboxsize =
                    new TransformF(((SimDataBlock)objectToSpawn.getDataBlock())["boundingBox"]);
                float searchRadius = boundingboxsize.mPositionX;
                float boxSizeY     = boundingboxsize.mPositionY;
                if (boxSizeY > searchRadius)
                {
                    searchRadius = boxSizeY;
                }
                List <UInt32> objectsfound = console.ContainerRadiusSearch(spherLocationP3F.GetPosition(), searchRadius,
                                                                           (UInt32)SceneObjectTypesAsUint.PlayerObjectType, false);
                if (objectsfound.Count > 0)
                {
                    spawnLocationFound = false;
                }

                attemptsToSpawn++;
            }
            if (!spawnLocationFound)
            {
                spherLocationP3F = spawnSphere.getTransform();
                console.warn("WARNING: Could not spawn player after 5 times");
            }
            return(spherLocationP3F);
        }
Пример #3
0
        public virtual TransformF PointInSpawnSphere(Player objectToSpawn, SpawnSphere spawnSphere)
        {
            bool spawnLocationFound = false;
            int attemptsToSpawn = 0;

            TransformF spherLocationP3F = new TransformF();

            while (!spawnLocationFound && attemptsToSpawn < 5)
                {
                spherLocationP3F = spawnSphere.getTransform();

                Random r = new Random();

                float angleY = (float) tMath.mDegToRad((r.NextDouble()*100)*tMath.M_2PI_F);
                float angleXZ = (float) tMath.mDegToRad((r.NextDouble()*100)*tMath.M_2PI_F);

                int radius = spawnSphere["radius"].AsInt();
                spherLocationP3F.mPositionX += (float) (Math.Cos(angleY)*Math.Sin(angleXZ)*(r.Next(radius*-1, radius)));
                spherLocationP3F.mPositionY += (float) (Math.Cos(angleXZ)*(r.Next(radius*-1, radius)));
                spawnLocationFound = true;

                // Now have to check that another object doesn't already exist at this spot.
                // Use the bounding box of the object to check if where we are about to spawn in is
                // clear.

                TransformF boundingboxsize = new TransformF(((SimDataBlock) objectToSpawn.getDataBlock())["boundingBox"]);
                float searchRadius = boundingboxsize.mPositionX;
                float boxSizeY = boundingboxsize.mPositionY;
                if (boxSizeY > searchRadius)
                    searchRadius = boxSizeY;
                List<UInt32> objectsfound = console.ContainerRadiusSearch(spherLocationP3F.GetPosition(), searchRadius, (UInt32) SceneObjectTypesAsUint.PlayerObjectType, false);
                if (objectsfound.Count > 0)
                    spawnLocationFound = false;

                attemptsToSpawn++;
                }
            if (!spawnLocationFound)
                {
                spherLocationP3F = spawnSphere.getTransform();
                console.warn("WARNING: Could not spawn player after 5 times");
                }
            return spherLocationP3F;
        }