protected void UnSetFloatParam(FloatStatus type) { if (floatParams.ContainsKey(type)) { floatParams.Remove(type); } }
private void UpdateItem(string itemName, FloatStatus status, bool percentage = false) { var text = upgradeMenu.transform.Find(itemName + "/value").GetComponent <Text>(); text.text = percentage ? $"{status.currentValue:P}" : $"{status.currentValue}"; var button = upgradeMenu.transform.Find(itemName + "/Button").GetComponent <Button>(); button.interactable = status.maxLevel == -1 || status.currentLevel < status.maxLevel; }
protected void SetFloatParam(FloatStatus type, float value, bool isAdd) { if (!floatParams.ContainsKey(type)) { floatParams.Add(type, new FloatParam(type, value, isAdd)); } else { floatParams[type] = new FloatParam(type, value, isAdd); } }
public FrontCameraMonitor() { this.ReceiveCount = new IntStatus(); this.SystemError = new ErrorState(); this.MoveType = new MotorMoveType(); this.RedTape = new DetectType(); this.BlueObject = new DetectType(); this.Distance = new List <FloatStatus>(); for (int index = 0; index < PrivateConstants.SonicSensorCount; index++) { FloatStatus value = new FloatStatus(3); this.Distance.Add(value); } }
//Again I know status should be generic, but anyway just live with it private void InitItem(string itemName, FloatStatus status, bool percentage = false) { var text = upgradeMenu.transform.Find(itemName + "/Button/Text").GetComponent <Text>(); text.text = percentage ? $"+{status.stepValue:P}" : $"{status.stepValue:+0.####;-0.####}"; var button = upgradeMenu.transform.Find(itemName + "/Button").GetComponent <Button>(); button.onClick.AddListener(() => { if (playerStatus.rarePerks >= 1) { playerStatus.normalPerks--; status.currentLevel++; } }); }
public FloatParam(FloatStatus type, float value, bool isAdd) { Type = type; Value = value; IsAdd = isAdd; }
protected override bool DoUpdate() { CheckOneWayPlatformFallThrough(); Vector3 velocity = _playerController.characterPhysicsManager.velocity; velocity.y = GetJumpVerticalVelocity(velocity); velocity.x = GetDefaultHorizontalVelocity(velocity); if (velocity.y == 0) { _floatStatus = FloatStatus.CanFloat; } else { _floatStatus |= FloatStatus.IsInAir; if (velocity.y < 0) { // player is moving down, so check floating logic if ((_gameManager.inputStateManager.GetButtonState("Jump").buttonPressState & ButtonPressState.IsUp) != 0) { // player released jump button on way down, this means he can't float any more for this in air session _floatStatus &= ~FloatStatus.CanFloat; } if (((_floatStatus & FloatStatus.CanFloat) != 0) && (_gameManager.inputStateManager.GetButtonState("Jump").buttonPressState & ButtonPressState.IsDown) != 0) { // player is on his way down,can float and pressed the jump button, so he starts floating velocity.y *= _powerUpSettings.floaterSettings.startFloatingDuringFallVelocityMultiplier; _floatStatus |= FloatStatus.IsFloating; } if ((_gameManager.inputStateManager.GetButtonState("Jump").buttonPressState & ButtonPressState.IsPressed) != 0) { // player is on his way down and has the jump button pressed, so set the floating field _floatStatus |= FloatStatus.IsFloating; } } else { _floatStatus |= FloatStatus.CanFloat; _floatStatus &= ~FloatStatus.IsFloating; } } bool isFloating = velocity.y < 0 && (_floatStatus == (FloatStatus.IsInAir | FloatStatus.CanFloat | FloatStatus.IsFloating)); if (isFloating) { if (_isFloating) { _playerController.adjustedGravity = Mathf.Lerp(_playerController.adjustedGravity, _playerController.jumpSettings.gravity, Time.deltaTime * _powerUpSettings.floaterSettings.floaterGravityDecreaseInterpolationFactor); // TODO (Roman): hard coded... } else { _playerController.adjustedGravity = _powerUpSettings.floaterSettings.floaterGravity; _playerController.jumpSettings.inAirDamping = _powerUpSettings.floaterSettings.floaterInAirDampingOverride; } } else { _playerController.adjustedGravity = _playerController.jumpSettings.gravity; } _isFloating = isFloating; velocity.y = Mathf.Max( GetGravityAdjustedVerticalVelocity(velocity, _playerController.adjustedGravity, true) , _playerController.jumpSettings.maxDownwardSpeed); _playerController.characterPhysicsManager.Move(velocity * Time.deltaTime); return(true); }
public float GetValue(FloatStatus type) { return(FloatStatus[(int)type]); }