public void Fencing_StopFencing(bool shouldStopFencing) { if (shouldStopFencing) { PlayerState = PlayerControllerState.movingAround; } }
public void MovingAround_StartFencing(bool shouldStartFencing) { if (shouldStartFencing) { PlayerState = PlayerControllerState.fencing; } }
public static FighterControllerState DetermineFighterControllerState(FighterController fighterController) { FighterControllerState fighterControllerState = null; if (fighterController.IsPlayerOne() || GameData.GetPlayers() == 2) { fighterControllerState = new PlayerControllerState(); } else { switch (GameData.GetComputerDifficulty()) { case Difficulty.Easy: fighterControllerState = new EasyAiControllerState(); break; case Difficulty.Medium: fighterControllerState = new MediumAiControllerState(); break; case Difficulty.Hard: fighterControllerState = new HardAiControllerState(); break; } } fighterControllerState.Init(fighterController); return(fighterControllerState); }
public void StartPlaningBuilding(BuildingData building) { state = PlayerControllerState.BuildingMode; buildingSystem.StartPlaning(building.placerPrefab); if (currentOpenBubbleMenu != null) { currentOpenBubbleMenu.Hide(); } }
void Update() { #region TimerMaintenance jumpCooldownTmp -= Time.deltaTime; #endregion #region GatherInput if (this.isThisMachinesPlayer) { this.gamepadState = GamePad.GetState(this.padIndex); } this.controllerMoveDirection = GamePad.GetAxis(GamePad.Axis.LeftStick, this.padIndex); this.controllerLookDirection = GamePad.GetAxis(GamePad.Axis.RightStick, this.padIndex); #endregion #region SettingPlayerState if (this.gamepadState.LeftTrigger > 0.20f) { this.playerState = PlayerControllerState.aiming; } else if (this.gamepadState.LeftStick) { this.playerState = PlayerControllerState.running; } else { this.playerState = PlayerControllerState.walking; } #endregion Vector3 forward = this.myCamera.transform.TransformDirection(Vector3.forward); forward = forward.normalized; this.moveDirection = this.controllerMoveDirection.y * forward + this.controllerMoveDirection.x * new Vector3(forward.z, 0, -forward.x); AdjustCamera(); #region RunningActionByState forward = this.myCamera.transform.TransformDirection(Vector3.forward); forward = forward.normalized; this.moveDirection = this.controllerMoveDirection.y * forward + this.controllerMoveDirection.x * new Vector3(forward.z, 0, -forward.x); moveDirection *= this.baseSpeed; switch (this.playerState) { case PlayerControllerState.walking: break; case PlayerControllerState.running: moveDirection *= this.runSpeedMultiplier; break; case PlayerControllerState.aiming: moveDirection *= this.aimSpeedMultiplier; break; } #endregion #region Movement if (this.moveDirection.magnitude > 0.05f) { this.GetComponent <Rigidbody>().velocity = Vector3.Lerp(this.GetComponent <Rigidbody>().velocity, this.moveDirection, this.velocityDampingSpeed); this.transform.forward = Vector3.Lerp(this.transform.forward, this.GetComponent <Rigidbody>().velocity.normalized, this.velocityDampingSpeed); this.GetComponent <Rigidbody>().angularVelocity = Vector3.Lerp(this.GetComponent <Rigidbody>().angularVelocity, Vector3.zero, this.velocityDampingSpeed); } #endregion }
// Update is called once per frame void Update() { cameraController.MoveCamera(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), Input.GetAxis("Mouse ScrollWheel")); #region input if (Input.GetKeyDown(KeyCode.B)) { uIManager.ToogleBuildingPanel(); } else if (Input.GetKeyDown(KeyCode.E)) { if (economyActive) { ExitEconomyMenagementMode(); } else { EnterEconomyMenagementMode(); } } #endregion #region Handle states in update switch (state) { case PlayerControllerState.Default: if (Input.GetMouseButtonDown(0)) { if (!economyActive) { if (!Utility.HitsUI(Input.mousePosition)) { if (currentOpenBubbleMenu != null) { currentOpenBubbleMenu.Hide(); } } layerMask = 1 << buildingsLayer; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) { //all buildings need to have buildingMenu attached BubbleMenu bubbleMenu = hit.collider.GetComponent <BubbleMenu>(); if (bubbleMenu != null) { currentOpenBubbleMenu = bubbleMenu; currentOpenBubbleMenu.Show(); } } } } break; case PlayerControllerState.BuildingMode: layerMask = 1 << groundLayer; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask)) { buildingSystem.PlanBuilding(hit.point); } if (Input.GetMouseButtonDown(0)) { if (!Utility.HitsUI(Input.mousePosition)) { Debug.Log("click"); buildingSystem.PlaceBuilding(hit.point); } } else if (Input.GetMouseButtonDown(1)) { state = PlayerControllerState.Default; buildingSystem.StopPlaning(); } break; #endregion } }
public void StopPlaningBuilding() { state = PlayerControllerState.Default; buildingSystem.StopPlaning(); }
void Start() { PlayerState = PlayerControllerState.movingAround; }
/// RequestStartCallBack is used to add functionality on start. public void RequestStartCallback(PlayerControllerState state, Action callback) { actions[(int)state].onStart += callback; }
private void SetState(PlayerControllerState state) { actions[(int)currentPlayerState].onEnd?.Invoke(); currentPlayerState = state; actions[(int)currentPlayerState].onStart?.Invoke(); }
public void SetPlayerControllerState(PlayerControllerState newState) { ControllerState = newState; //Set the material from the visualizations array. renderer.sharedMaterial = Visualization.First(x => x.State == newState).Material; }