public virtual State RoamState() { if (TimeSince(TimeOfRandomAngleChange, 2f)) { StartCoroutine(MoveFloatH(Random.Range(-1.5f, 1.5f), 2f)); StartCoroutine(MoveFloatV(Random.Range(-1.5f, 1.5f), 2f)); TimeOfRandomAngleChange = Time.time; } if (TimeSince(TimeOfPlayerDetect, PlayerDetectionSettings.detectionInterval)) { var pTarget = GetClosestPlayer(PlayerDetectionSettings.detectionRange, PlayerDetectionSettings.detectionOnlyIfPlayerInSight); if (pTarget) { playerTarget = pTarget; return(State.Chase); } } if (TimeSince(TimeOfActionChoice, ChoiceMakingInterval)) { if (Random.value < 0.3f && canRoamAround) { return(State.Idle); } } cM.TryMovement(h, v, true); return(state); }
void GetInput() { float h = 0; float v = 0; float hAttack = 0; float vAttack = 0; if (Pause) { if (Input.GetKeyDown(StartButton)) { Pause.TogglePauseMenu(); } } if (canInput && Time.timeScale != 0) { h += Input.GetAxisRaw(hMoveAxis); v += Input.GetAxisRaw(vMoveAxis); h += mobileH; v += mobileV; hAttack += mobileHAttack; vAttack += mobileVAttack; if (currentInput != InputMethod.SingleplayerMouse) { hAttack += Input.GetAxisRaw(hFireAxis); vAttack += Input.GetAxisRaw(vFireAxis); } if (Input.GetKeyDown(JumpButton)) { cM.Jump(); } if (Input.GetKeyDown(DropWeaponButton)) { pC.weaponManager.DropWeapon(); } if (Input.GetKeyDown(SwapWeaponButton)) { pC.weaponManager.TrySwapWeapon(); } } cM.TryMovement(h, v, LookWhereMove()); TryAttack(hAttack, vAttack); }