private void Start() { child = GetComponentInChildren <Camera>().transform; rotation = GameLink.Game.SceneComponents.GetOrRegister <SubscribableQuaternion> ((int)ComponentKeys.GameCameraRotation, SubscribableQuaternion.Create); rotation.Subscribe(new SimpleListener <Quaternion>((q) => RefreshRotation())); RefreshRotation(); zoom = GameLink.Game.SceneComponents.GetOrRegister <SubscribableFloat> ((int)ComponentKeys.GameCameraZoom, SubscribableFloat.Create); zoom.Subscribe(new SimpleListener <float>((z) => RefreshZoom())); RefreshZoom(); }
public CameraController(ChessScene scene) { scene.ActivatableList.Add(new TickingJanitor(scene.Game, this)); scene.Components.GetOrRegister <Message <Board> >((int)ComponentKeys.BoardCreatedMessage, Message <Board> .Create) .Subscribe(new SimpleListener <Board>(ReceivedNewBoard)); rotation = scene.Components.GetOrRegister <SubscribableQuaternion>((int)ComponentKeys.GameCameraRotation, SubscribableQuaternion.Create); rotation.Value = Quaternion.identity; zoom = scene.Components.GetOrRegister <SubscribableFloat>((int)ComponentKeys.GameCameraZoom, SubscribableFloat.Create); zoom.Value = ZOOM_DEFAULT; trackMouseBtn = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.CameraTrackMouseBtn, SubscribableBool.Create); mouseChange = scene.Components.GetOrRegister <SubscribableVector2>((int)ComponentKeys.MouseChange, SubscribableVector2.Create); mouseWheel = scene.Components.GetOrRegister <SubscribableInt>((int)ComponentKeys.ScrollWheel, SubscribableInt.Create); scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.CameraRecenterBtn, SubscribableBool.Create) .Subscribe(new ReleaseListener(RecenterCamera)); }