// // < Update state > // public void UpdateState(EHarvestHumanMovementState state) { if (_currentState == state || state == EHarvestHumanMovementState.STAY) { return; } switch (state) { case EHarvestHumanMovementState.LEFT: this._SetLeftState(); break; case EHarvestHumanMovementState.RIGHT: this._SetRightState(); break; case EHarvestHumanMovementState.BOTTOM: this._SetBottomState(); break; case EHarvestHumanMovementState.TOP: this._SetTopState(); break; default: break; } _currentState = state; }
protected void _UpdateMovementState() { var dx = this.transform.position.x - _prevWorldPos.x; var dy = this.transform.position.y - _prevWorldPos.y; var dxm = Mathf.Abs(dx); var dym = Mathf.Abs(dy); if (dxm + dym <= eps) { movementState = EHarvestHumanMovementState.STAY; } else { if (dx > 0.0f && dy > 0.0f) { movementState = EHarvestHumanMovementState.TOP; } else if (dx > 0.0f && dy < 0.0f) { movementState = EHarvestHumanMovementState.RIGHT; } else if (dx < 0.0f && dy < 0.0f) { movementState = EHarvestHumanMovementState.BOTTOM; } else { movementState = EHarvestHumanMovementState.LEFT; } } _prevWorldPos = this.transform.position; }
protected void Awake() { _currentState = EHarvestHumanMovementState.STAY; }