protected override void Start() { base.Start(); state = gameObject.AddComponent<WalkingState>(); state.Construct(); camMotor = gameObject.AddComponent<CameraMotor>(); camMotor.Init(); camTransform = camMotor.CameraContainer; }
void DoActivateMotor() { var go = Fsm.GetOwnerDefaultTarget(gameObject); script = go.GetComponent <CameraController>(); CameraMotor motor = script.GetMotor(modeToActivate.Value); script.ActivateMotor(motor); return; }
public void LateUpdate() { CameraMotor activeMotor = m_cameraController.ActiveMotor; if (activeMotor.Name == "Targeting" && !m_cameraController.InputSource.IsPressed(KeyCode.Mouse2)) { // affect the desired Zoom distance if we roll the scrollwheel m_desiredDistance -= Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * m_zoomRate * Mathf.Abs(m_desiredDistance); // clamp the zoom min/max m_desiredDistance = Mathf.Clamp(m_desiredDistance, m_minDistance, m_maxDistance); // For smoothing of the zoom, lerp distance activeMotor.Distance = Mathf.Lerp(activeMotor.Distance, m_desiredDistance, Time.deltaTime * m_zoomDampening); } }
public void SwitchToFirstPersonView() { CameraMotor activeMotor = m_cameraController.ActiveMotor; if (activeMotor.Name == "1st Person View") { return; } m_enableChangeCameraMode = false; //m_FPSControllerTrans.gameObject.SetActive(true); //if (m_targetTrans.parent != m_FPSControllerTrans.parent) //{ // m_targetTrans.SetParent(m_FPSControllerTrans.parent, true); //} Vector3 targetPos = m_targetTrans.localPosition; m_targetTrans.position = m_cameraController.transform.localPosition; m_targetTrans.rotation = m_cameraController.transform.localRotation; m_tweenerToFPV = m_targetTrans.DOLocalMove(m_cameraController.transform.localPosition, m_tweenTime); Vector3 ro = m_targetTrans.eulerAngles; ro.x = ro.z = 0; Quaternion targetRot = m_targetTrans.localRotation; //m_targetTrans.DOLocalRotateQuaternion(targetRot, m_tweenTime); m_targetTrans.DOLocalRotate(ro /*targetRot.eulerAngles*/, m_tweenTime, RotateMode.Fast); //TransitionMotor transMotor = m_cameraController.GetMotor<TransitionMotor>("Targeting Out"); //m_cameraController.ActivateMotor(transMotor); //m_cameraController.AnchorOffset = new Vector3(0.0f, 1.8f, 0.0f); DOTween.To(() => m_cameraController.AnchorOffset, x => m_cameraController.AnchorOffset = x, new Vector3(0.0f, 0, 0.0f), m_tweenTime); CameraMotor motor = m_cameraController.GetMotor <CameraMotor>("1st Person View"); motor.IsEnabled = true; m_cameraController.ActivateMotor(motor); // 动画开始时禁用相机控制 motor.IsEnabled = false; // 启用通过FOV实现的缩放 m_cameraController.IsZoomEnabled = true; m_tweenerToFPV.OnComplete(OnSwitchedToFirstPersonView); }
void DoSetCameraDistance() { var go = Fsm.GetOwnerDefaultTarget(gameObject); script = go.GetComponent <CameraController>(); CameraMotor motor = script.GetMotor(modeToModify.Value); if (set.Value == true) { motor.Distance = CameraDistance.Value; } else { CameraDistance.Value = motor.Distance; } }
public void Camera_ActiveCameraMotorReferencesCurrentCamera() { // Use the Assert class to test conditions. Camera[] camerasInScene = GameObject.FindObjectsOfType <Camera>(); Assert.IsNotEmpty(camerasInScene); Camera active = null; foreach (Camera go in camerasInScene) { if (go.isActiveAndEnabled) { active = go; break; } } CameraMotor cm = active.GetComponent <CameraMotor>(); Assert.AreSame(active, cm.Current); Assert.True(cm.Current.CompareTag(EXPECTED_TAG)); }
private void Awake() { Instance = this; //initialise fields playerMotor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>(); cameraMotor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>(); compMotor = GameObject.FindGameObjectWithTag("Companion").GetComponent <GorillaMotor>(); scoreText.text = score.ToString("0"); seedCountText.text = seeds.ToString(); isEndless = SceneController.getIsEndless(); if (Settings.isMusicOn.Value) {//checking for music AudioSource[] audios = FindObjectsOfType <AudioSource>(); foreach (AudioSource audio in audios) { if (audio.CompareTag("Music")) { musicPlayer = audio; } } StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f)); } heart1.gameObject.SetActive(true); heart2.gameObject.SetActive(true); heart3.gameObject.SetActive(true); if (!isEndless)//if not endless { informationText.text = ""; startCutscene.Begin(); //start the cutscene } else { informationText.text = "Tap Anywhere To Begin!"; //or start directly } }
void Start() { grid = Grid.instance; unitsStore = UnitsStore.instance; unitManager = UnitManager.instance; cameraMotor = Camera.main.GetComponent <CameraMotor>(); turnStartText = GameObject.FindObjectOfType <TurnStartText>(); currentTeam = teams[0]; // attacker moves first ShowTeamTurnUI(); // assuming for now that there are two teams only and they have random units // TODO: Teams should be inserted from outside of the script (probably by UI on previous screen) int unitsN = 5; foreach (Team t in teams) { for (int i = 0; i < unitsN; i++) { int rndUnitIndex = random.Next(unitsStore.awailableUnits.Length); t.storedUnits.Add(unitsStore.awailableUnits[rndUnitIndex]); } } int attackerNodeX = grid.gridSizeX / 2 - teams[0].storedUnits.Count / 2; int attackerNodeY = 1; PlaceTeamUnits(teams[0], attackerNodeX, attackerNodeY); int defenderNodeX = grid.gridSizeX / 2 - teams[1].storedUnits.Count / 2; int defenderNodeY = grid.gridSizeY - 2; PlaceTeamUnits(teams[1], defenderNodeX, defenderNodeY); foreach (Unit u in teams[1].units) { u.RotateTo(u.transform.position); } FocusCameraOnTeam(currentTeam); }
/* This method is run before the first frame update, it intialises all necessary variables */ private void Awake() { Instance = this; pollutionSlide.value = TrashSpawner.garbageMultiplier; playerMotor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>(); cameraMotor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>(); compMotor = GameObject.FindGameObjectWithTag("Companion").GetComponent <CompanionMotor>(); scoreText.text = score.ToString("0"); garbageText.text = garbage.ToString(); isEndless = SceneController.getIsEndless(); // Initialise music if (Settings.isMusicOn.Value) { AudioSource[] audios = FindObjectsOfType <AudioSource>(); foreach (AudioSource audio in audios) { if (audio.CompareTag("Music")) { musicPlayer = audio; } } StartCoroutine(AudioController.FadeOut(musicPlayer, 0.5f)); } heart1.gameObject.SetActive(true); heart2.gameObject.SetActive(true); heart3.gameObject.SetActive(true); // If its endless you skip all cutscenes if (!isEndless) { startCutscene.Begin(); } }
public void SwitchToThirdPersonView(Vector3 targetPos, Quaternion targetRot, Quaternion camDefaultRot, float distance = -1.0f) { if (m_tweenerPosToTPV != null) { if (m_tweenerPosToTPV.IsPlaying()) { //return; m_tweenerPosToTPV.Kill(); } m_tweenerPosToTPV = null; } if (m_tweenerRotToTPV != null) { if (m_tweenerRotToTPV.IsPlaying()) { //return; m_tweenerRotToTPV.Kill(); } m_tweenerRotToTPV = null; } m_enableChangeCameraMode = false; // 位姿动画变化 m_tweenerPosToTPV = m_targetTrans.DOLocalMove(targetPos, m_tweenTime); //m_targetTrans.DOLocalRotateQuaternion(targetRot, m_tweenTime); m_tweenerRotToTPV = m_targetTrans.DOLocalRotate(targetRot.eulerAngles, m_tweenTime, RotateMode.Fast); m_tweenerPosToTPV.OnComplete(OnSwitchedToThirdPersonView); // 设置相机的最终默认朝向 //m_cameraController._Transform.DOLocalRotateQuaternion(camDefaultRot, m_tweenTime); m_cameraController._Transform.DOLocalRotate(camDefaultRot.eulerAngles, m_tweenTime, RotateMode.Fast); CameraMotor activeMotor = m_cameraController.ActiveMotor; if (activeMotor.Name == "Targeting") { // 距离动态变化 if (distance > 0) { m_desiredDistance = distance; DOTween.To(() => activeMotor.Distance, x => activeMotor.Distance = x, distance, m_tweenTime); } return; } //m_FPSControllerTrans.gameObject.SetActive(false); //if (activeMotor.Name == "1st Person View") //{ // m_targetTrans.position = m_FPSControllerTrans.position; // m_targetTrans.rotation = m_FPSControllerTrans.rotation; //} //TransitionMotor transMotor = m_cameraController.GetMotor<TransitionMotor>("Targeting In"); //m_cameraController.ActivateMotor(transMotor); //m_cameraController.AnchorOffset = new Vector3(0.0f, 0.0f, 0.0f); DOTween.To(() => m_cameraController.AnchorOffset, x => m_cameraController.AnchorOffset = x, new Vector3(0.0f, 0.0f, 0.0f), m_tweenTime); CameraMotor motor = m_cameraController.GetMotor <CameraMotor>("Targeting"); m_cameraController.ActivateMotor(motor); m_desiredDistance = motor.Distance; // 距离动态变化 if (distance > 0) { m_desiredDistance = distance; DOTween.To(() => motor.Distance, x => motor.Distance = x, distance, m_tweenTime); } // 禁用通过FOV实现的缩放 DOTween.To(() => m_cameraController.Camera.fieldOfView, x => m_cameraController.Camera.fieldOfView = x, m_cameraController.OriginalFOV, m_tweenTime); m_cameraController.IsZoomEnabled = false; }
// Start is called before the first frame update void Start() { cameraMotor = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraMotor>(); playerTransform = GameObject.FindGameObjectWithTag("Player").transform; }
public virtual void Construct() { motor = GetComponent <CameraMotor>(); }
public virtual void Construct() { motor = GetComponent<CameraMotor>(); }
public void SwitchToFirstPersonView() { CameraMotor activeMotor = m_cameraController.ActiveMotor; }
private void Start() { cameraMotorScript = FindObjectOfType <CameraMotor>(); playerMotorScript = FindObjectOfType <CharacterMotor>(); }