コード例 #1
0
        /// <summary>
        /// Generates a random set of dwarves in the given chunk.
        /// </summary>
        public void CreateInitialDwarves()
        {
            if (InitialEmbark == null)
            {
                InitialEmbark = EmbarkmentLibrary.DefaultEmbarkment;
            }

            var cameraCoordinate = GlobalVoxelCoordinate.FromVector3(Camera.Position);
            // Find the height of the world at the camera
            var cameraVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(
                                                                   ChunkManager.ChunkData, new GlobalVoxelCoordinate(cameraCoordinate.X,
                                                                                                                     VoxelConstants.ChunkSizeY - 1, cameraCoordinate.Z)));
            var h = (float)(cameraVoxel.Coordinate.Y + 1);


            // This is done just to make sure the camera is in the correct place.
            Camera.UpdateBasisVectors();
            Camera.UpdateProjectionMatrix();
            Camera.UpdateViewMatrix();

            foreach (string ent in InitialEmbark.Party)
            {
                Vector3 dorfPos = new Vector3(Camera.Position.X + (float)MathFunctions.Random.NextDouble(), h + 10,
                                              Camera.Position.Z + (float)MathFunctions.Random.NextDouble());
                Physics creat = (Physics)EntityFactory.CreateEntity <Physics>(ent, dorfPos);
                creat.Velocity = new Vector3(1, 0, 0);
            }

            Camera.Target   = new Vector3(Camera.Position.X, h, Camera.Position.Z + 10);
            Camera.Position = new Vector3(Camera.Target.X, Camera.Target.Y + 20, Camera.Position.Z - 10);
        }