Пример #1
0
 public void SetAllFollowTransforms(Transform followTransform)
 {
     foreach (Camera Cam in RegisteredObjects.Values)
     {
         InertialCameraController ICC
             = Cam.GetComponent <InertialCameraController>();
         if (ICC != null)
         {
             ICC.FollowTransform = followTransform;
         }
         else
         {
             LargeScaleCamera LSC
                 = Cam.GetComponent <LargeScaleCamera>();
             if (LSC != null)
             {
                 LSC.FollowTransform = followTransform;
             }
             else
             {
                 throw new InvalidOperationException(
                           "Camera "
                           + Cam.ToString()
                           + " does not have an InertialCameraController "
                           + "or LargeScaleCamera component"
                           );
             }
         }
     }
 }
Пример #2
0
        SetupGameCameras
            (Transform initialFollowTransform)
        {
            //Debug.Log("Setting-up game cameras");
            MyContract.RequireFieldNotNull(
                SpaceshipClassManager, "SpaceshipClassManager"
                );

            // instantiate with initial values
            Vector3 CameraOffset
                = SpaceshipClassManager
                  .getCameraOffset(PlayerShipClassChoice);
            InertialCameraController PlayerCamController
                = CameraRegistry[(int)CameraRoles.Player]
                  .GetComponent <InertialCameraController>();
            LargeScaleCamera NearestPlanetCamController
                = CameraRegistry[(int)CameraRoles.NearestPlanet]
                  .GetComponent <LargeScaleCamera>();
            LargeScaleCamera SolarSystemCamController
                = CameraRegistry[(int)CameraRoles.SolarSystem]
                  .GetComponent <LargeScaleCamera>();

            PlayerCamController.offset = CameraOffset;
            NearestPlanetCamController.CameraOffset = CameraOffset;
            SolarSystemCamController.CameraOffset   = CameraOffset;

            // These shouldn't be different,
            // but they're manually set in the (Unity) editor
            // so the (human) editor could be lazy about it
            // and only change one setting
            // and forget the other 2
            float MoveSpeed = PlayerCamController.moveSpeed;

            NearestPlanetCamController.MoveSpeed = MoveSpeed;
            SolarSystemCamController.MoveSpeed   = MoveSpeed;
            float TurnSpeed = PlayerCamController.turnSpeed;

            NearestPlanetCamController.TurnSpeed = TurnSpeed;
            SolarSystemCamController.TurnSpeed   = TurnSpeed;

            CameraRegistry.SetAllFollowTransforms(initialFollowTransform);

            WarpTo(CurrentNearestOrbitingBody);
        }