private void ChangeState(CameraStateType cameraStateType) { switch (cameraStateType) { case CameraStateType.Idle: currentState = new CameraNomalState(animator); break; case CameraStateType.Damage: currentState = new CameraShakeState(animator); break; case CameraStateType.Skill_1: currentState = new CameraSkillActionState(animator); break; case CameraStateType.Skill_2: currentState = new CameraSkillActionState(animator); break; default: currentState = new CameraNomalState(animator); break; } }
public void AddState(string stateName, ICameraState state) { if (!states.ContainsKey(stateName) && !states.ContainsValue(state)) { states.Add(stateName, state); } }
public void stop() { if (_player) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; _state = _moveState; _state.entry(this); Factory.Instance.DeleteGameObject(ref _player); foreach (Transform child in _canvas.transform) { child.GetComponent <Button>().interactable = true; } EnemySpawner.spawnersActive(false); GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject enemy in enemies) { Destroy(enemy); } } }
private void Awake() { _moveState = gameObject.AddComponent <CameraMoveState>(); _objectSelectedState = gameObject.AddComponent <CameraObjectSelectedState>(); _playerState = gameObject.AddComponent <CameraPlayerState>(); _state = _moveState; }
protected override void CalculateModification(ICameraState cameraState, float deltaTime) { Vector3 modifiedTarget = this._target.position + this._targetOffset; Vector3 targetToCameraNormal = (cameraState.Position - modifiedTarget).normalized; this._cameraTargetPosition = modifiedTarget + (targetToCameraNormal * this._distanceFromTarget); this._cameraTargetRotation = Quaternion.LookRotation(-targetToCameraNormal, Vector3.up); }
public void Awake() { states = new Dictionary <string, ICameraState>(); AddState("Action", new CameraActionState(this)); AddState("Lock", new CameraLockState(this)); current = Get("Action"); current.Enter(); }
protected override void CalculateModification(ICameraState cameraState, float deltaTime) { this._cameraTargetPosition = cameraState.Position; this._cameraTargetRotation = cameraState.Rotation; CameraSystem.Instance.ChangeCameraFOV(Mathf.Lerp(this._cachedFoV, this._fieldOfView, TransitionLerpT)); }
protected override void CalculateModification(ICameraState cameraState, float deltaTime) { if (this._lookAtTarget != null) { this._cameraTargetPosition = cameraState.Position; this._cameraTargetRotation = Quaternion.LookRotation((this._lookAtTarget.position - cameraState.Position).normalized, Vector3.up); } }
protected override void CalculateModification(ICameraState cameraState, float deltaTime) { this._positionOffset += Random.insideUnitSphere * this._shakeIntensity * deltaTime; this._rotationOffset *= Quaternion.AngleAxis(this._shakeIntensity * 10.0f * deltaTime, Random.insideUnitSphere); this._cameraTargetPosition = Vector3.Lerp(cameraState.Position, cameraState.Position + this._positionOffset, this._shakeLerpT); this._cameraTargetRotation = Quaternion.Slerp(cameraState.Rotation, cameraState.Rotation * this._rotationOffset, this._shakeLerpT); }
public FollowMoving(GameObject cameraObject) { animator = cameraObject.GetComponentInChildren <Animator>(); this.cameraObject = cameraObject; //cameraOffset = cameraObject.transform.position - targetTransform.position; cameraOffset = new Vector3(0.3f, vDist, hDist); currentState = new CameraNomalState(animator); }
public void SetState(ViewMode new_state) { if (m_states[new_state] == m_current_state) { return; } if (m_current_state != null) { m_current_state.StateExit(this); } m_current_state = m_states[new_state]; m_current_state.StateEnter(this); }
public void Change(eState i_eState) { if (i_eState == eState.Target) { m_curState = m_targetState; } else if (i_eState == eState.Free) { m_curState = m_freeState; } else { m_curState = null; } }
//void Update() { } public void CameraHandler(float in_time) { if (_player == null) { return; } _desired_camera_point.SetCurrentPosition(DesiredCameraPos(), in_time); UpdateCameraVelocityAndPosition(in_time); EStateType new_state = _current_state.Update(in_time); if (new_state != _current_state.GetStateType()) { ICameraState old_state = _current_state; _current_state = CreateStateByType(new_state); _current_state.Update(0f); } }
public CameraStrategy() { m_strategyStock.Distance.Value = 20.0f; m_strategyStock.Distance.Power = 0.5f; m_strategyStock.Distance.PeriodTime = 1.3f; m_strategyStock.Direction.Value = LEMath.s_fPI * 0.9f; m_strategyStock.Direction.Power = 0.8f; m_strategyStock.Direction.PeriodTime = 0.6f; m_strategyStock.Target.Value = 0.3f; m_strategyStock.Target.Power = 0.5f; m_strategyStock.Target.PeriodTime = 0.8f; m_freeState = new CameraFreeState(this); m_targetState = new CameraTargetState(this); m_gameState = new CameraGameState(this); m_curState = m_gameState; }
public override void Init() { base.Init(); m_bDirty = true; m_fYaw = CameraDefine.m_fCameraYawDefault; m_fPitch = CameraDefine.m_fCameraPitchDefault; m_fDistance = CameraDefine.m_fCameraDistanceDefault; m_TargetOffset = CameraDefine.m_CameraTargetOffset; // 初始化状态 m_StateInit = new CameraStateInit(this); m_StateStareTarget = new CameraStateStareTarget(this); m_StateChangeToStareTarget = new CameraStateChangeToStareTarget(this); m_StateStarePos = new CameraStateStarePos(this); m_StateChangeToStarePos = new CameraStateChangeToStarePos(this); m_State = m_StateInit; //LookTarget(Singleton<ObjManager>.GetInstance().MainPlayer, null, 0); }
public void ModifiyCamera(ICameraState cameraState, float deltaTime) { CalculateModification(cameraState, deltaTime); if (this._transitioning == true) { Vector3 originalPosition = cameraState.Position; Quaternion originalRotation = cameraState.Rotation; cameraState.Position = Vector3.Lerp(originalPosition, this._cameraTargetPosition, this._transitionLerpT); Vector3 directionFrom = originalRotation * Vector3.forward; Vector3 directionTo = this._cameraTargetRotation * Vector3.forward; Vector3 actualRotation = Vector3.Lerp(directionFrom, directionTo, this._transitionLerpT); cameraState.Rotation = Quaternion.LookRotation(actualRotation.normalized, Vector3.up); } else { cameraState.Position = this._cameraTargetPosition; cameraState.Rotation = this._cameraTargetRotation; } }
public void play() { //Cursor.lockState = CursorLockMode.Locked; Cursor.lockState = CursorLockMode.Confined; Cursor.visible = false; Factory.Instance.CreateGameObject(ObjectTypes.Player, out _player); _state = _playerState; _state.entry(this); foreach (Transform child in _canvas.transform) { if (child.name != "Stop Button") { child.GetComponent <Button>().interactable = false; } } EnemySpawner.spawnersActive(true); _navMeshSurface.BuildNavMesh(); }
void Start() { CWorld.Instance.SetCamera4(this); _cam = Camera.main; _cam_transform = transform; _camera_shift = new Vector3(0, 1f, -_distance); CWorld.Instance.OnNewPlayer += OnNewPlayer; if (CWorld.Instance.GetPlayer() != null) { OnNewPlayer(this, EventArgs.Empty); } _current_state = new CCameraState_Idle(this); _desired_camera_point = new DesiredCameraPoint(DesiredCameraPos(), Vector3.zero); _cam_transform.position = DesiredCameraPos(); //_acceleration_value = 10f; //_deceleration_value = -0.5f; _acc = 0f; _fvel = 0f; _is_obtuse_angle = false; }
/// <summary> /// 设置状态,只能是继承自ICameraState的类调用 /// </summary> /// <param name="newState"></param> public void SetState(ICameraState newState) { m_State = newState; }
// Update is called once per frame void Update() { ICameraState state = _state.input(this); if (state == null) { _state.update(this); } else { _state = state; _state.entry(this); } #region //bool leftClicked = Input.GetMouseButtonDown(0); //bool rightClicked = Input.GetMouseButtonDown(1); //// Select an object when left clicked, and there is no currently selected object. //if (leftClicked && !_selectedObj && !EventSystem.current.IsPointerOverGameObject()) //{ // Ray mousePos = Camera.main.ScreenPointToRay(Input.mousePosition); // RaycastHit rayHit; // if (Physics.Raycast(mousePos.origin, mousePos.direction, out rayHit, Mathf.Infinity)) // { // _selectedObj = rayHit.collider.gameObject; // Debug.Log("Selected: " + _selectedObj.name); // } //} //// Deselect currently selected object //else if (rightClicked) // _selectedObj = null; //float horizontal = Input.GetAxis("Mouse X"); //float vertical = Input.GetAxis("Mouse Y"); //// Move selected object with mouse //if (_selectedObj) //{ // float height = 0.0f; // if (Input.GetMouseButton(2)) // { // height = vertical; // horizontal = 0.0f; // vertical = 0.0f; // } // if (Input.GetMouseButton(0)) // _selectedObj.transform.position += new Vector3(horizontal, height, vertical); //} //// Move camera //else //{ // if (Input.GetMouseButton(1)) // { // transform.position += transform.right * horizontal; // transform.position += transform.up * vertical; // } // transform.position += transform.forward * Input.GetAxis("Mouse ScrollWheel") * 3.0f; // if (Input.GetMouseButton(2)) // { // transform.Rotate(new Vector3(2.0f * vertical, 0.0f, 0.0f)); // transform.Rotate(new Vector3(0.0f, 2.0f * horizontal, 0.0f)); // } //} #endregion }
private void Switch(string newStateName) { current.Exit(); current = states[newStateName]; current.Enter(); }
public void SwitchState(ICameraState state) { _State.OnExit(); _State = state; _State.OnEnter(); }
void Start() { _State = new Normal(this); }
public void SetState(ICameraState s) { _cameraState = s as CameraState; }
private void Awake() { _State = new Idle(this); CreateInstance(); }
public void SetState(ICameraState state) => this.state = state;
protected abstract void CalculateModification(ICameraState cameraState, float deltaTime);