浏览代码

Renamed variable in all Conditions and Actions

/main
Ciro Continisio 4 年前
当前提交
383e85b3
共有 11 个文件被更改,包括 45 次插入45 次删除
  1. 6
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs
  2. 6
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs
  3. 10
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs
  4. 6
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs
  5. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/HorizontalMoveActionSO.cs
  6. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/RotateActionSO.cs
  7. 12
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/SlideActionSO.cs
  8. 12
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasHitHeadConditionSO.cs
  9. 6
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingJumpConditionSO.cs
  10. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsMovingConditionSO.cs
  11. 8
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsSlidingConditionSO.cs

6
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/ApplyMovementVectorActionSO.cs


public class ApplyMovementVectorAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
_characterController.Move(_characterScript.movementVector * Time.deltaTime);
_characterController.Move(_protagonistScript.movementVector * Time.deltaTime);
}
}

6
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/AscendActionSO.cs


public class AscendAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private float _verticalMovement;
private float _gravityContributionMultiplier;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
}
public AscendAction(float initialJumpForce)

_verticalMovement += Physics.gravity.y * GRAVITY_MULTIPLIER * Time.deltaTime * _gravityContributionMultiplier;
//Note that even if it's added, the above value is negative due to Physics.gravity.y
_characterScript.movementVector.y = _verticalMovement;
_protagonistScript.movementVector.y = _verticalMovement;
}
}

10
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/DescendActionSO.cs


public class DescendAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private float _verticalMovement;
private const float GRAVITY_MULTIPLIER = 5f;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
_verticalMovement = _characterScript.movementVector.y;
_verticalMovement = _protagonistScript.movementVector.y;
_characterScript.jumpInput = false;
_protagonistScript.jumpInput = false;
}
public override void OnUpdate()

//Cap the maximum so the player doesn't reach incredible speeds when freefalling from high positions
_verticalMovement = Mathf.Clamp(_verticalMovement, MAX_FALL_SPEED, MAX_RISE_SPEED);
_characterScript.movementVector.y = _verticalMovement;
_protagonistScript.movementVector.y = _verticalMovement;
}
}

6
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/GroundGravityActionSO.cs


public class GroundGravityAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private float _verticalPull;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
_characterScript.movementVector.y = _verticalPull;
_protagonistScript.movementVector.y = _verticalPull;
}
}

8
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/HorizontalMoveActionSO.cs


public class WalkAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private float _speed;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
_characterScript.movementVector.x = _characterScript.movementInput.x * _speed;
_characterScript.movementVector.z = _characterScript.movementInput.z * _speed;
_protagonistScript.movementVector.x = _protagonistScript.movementInput.x * _speed;
_protagonistScript.movementVector.z = _protagonistScript.movementInput.z * _speed;
}
}

8
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/RotateActionSO.cs


public class RotateAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private Transform _transform;
private float _turnSmoothTime;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
Vector3 horizontalMovement = _characterScript.movementVector;
Vector3 horizontalMovement = _protagonistScript.movementVector;
float targetRotation = Mathf.Atan2(_characterScript.movementVector.x, _characterScript.movementVector.z) * Mathf.Rad2Deg;
float targetRotation = Mathf.Atan2(_protagonistScript.movementVector.x, _protagonistScript.movementVector.z) * Mathf.Rad2Deg;
_transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(
_transform.eulerAngles.y,
targetRotation,

12
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/SlideActionSO.cs


public class SlideAction : StateAction
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private float _slideSpeed;

public override void Awake(StateMachine stateMachine)
{
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
Vector3 hitNormal = _characterScript.lastHit.normal;
_characterScript.movementVector.x = (1f - hitNormal.y) * hitNormal.x * _slideSpeed;
_characterScript.movementVector.z = (1f - hitNormal.y) * hitNormal.z * _slideSpeed;
Vector3 hitNormal = _protagonistScript.lastHit.normal;
_protagonistScript.movementVector.x = (1f - hitNormal.y) * hitNormal.x * _slideSpeed;
_protagonistScript.movementVector.z = (1f - hitNormal.y) * hitNormal.z * _slideSpeed;
_characterScript.movementVector = Vector3.zero;
_protagonistScript.movementVector = Vector3.zero;
}
}

12
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/HasHitHeadConditionSO.cs


public class HasHitHeadCondition : Condition
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
private CharacterController _characterController;
private Transform _transform;

_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
bool isMovingUpwards = _characterScript.movementVector.y > 0f;
bool isMovingUpwards = _protagonistScript.movementVector.y > 0f;
float distance = Mathf.Abs(_characterScript.lastHit.point.y - topPositionY);
float distance = Mathf.Abs(_protagonistScript.lastHit.point.y - topPositionY);
_characterScript.jumpInput = false;
_characterScript.movementVector.y = 0f;
_protagonistScript.jumpInput = false;
_protagonistScript.movementVector.y = 0f;
return true;
}

6
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsHoldingJumpConditionSO.cs


public class IsHoldingJumpCondition : Condition
{
//Component references
private Protagonist _characterScript;
private Protagonist _protagonistScript;
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
protected override bool Statement() => _characterScript.jumpInput;
protected override bool Statement() => _protagonistScript.jumpInput;
}

8
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsMovingConditionSO.cs


public class IsMovingCondition : Condition
{
private float _treshold;
private Protagonist _characterScript;
private Protagonist _protagonistScript;
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
}
public IsMovingCondition(float treshold)

protected override bool Statement()
{
Vector3 movementVector = _characterScript.movementInput;
Vector3 movementVector = _protagonistScript.movementInput;
movementVector.y = 0f;
return movementVector.sqrMagnitude > _treshold;
}

_characterScript.movementVector = Vector3.zero;
_protagonistScript.movementVector = Vector3.zero;
}
}

8
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/IsSlidingConditionSO.cs


public class IsSlidingCondition : Condition
{
private CharacterController _characterController;
private Protagonist _characterScript;
private Protagonist _protagonistScript;
_characterScript = stateMachine.GetComponent<Protagonist>();
_protagonistScript = stateMachine.GetComponent<Protagonist>();
if (_characterScript.lastHit == null)
if (_protagonistScript.lastHit == null)
float currentSlope = Vector3.Angle(Vector3.up, _characterScript.lastHit.normal);
float currentSlope = Vector3.Angle(Vector3.up, _protagonistScript.lastHit.normal);
return (currentSlope >= _characterController.slopeLimit);
}
}
正在加载...
取消
保存