public void CalculateStats() { maximal_Health = base_Health + (HealthSkillMultiplicator * Skills.GetSubSkillValue("Body Health")); maximal_Stamina = base_Stamina + (StaminaSkillMultiplicator * Skills.GetSubSkillValue("Endurance")); maximal_Psi = base_Psi + (PsiSkillMultiplicator * Skills.GetSubSkillValue("Psi Power")); maximal_Psi += (Skills.GetSubSkillValue("Psi Use")); regenerate_Stamina = 5 + (Skills.GetSubSkillValue("Endurance") / 10); }
void Movement() { if (!isLocalPlayer) { return; } MoveDir = Vector3.zero; if (Input.GetButton("Forward")) { MoveDir.z = 1; } if (Input.GetButton("Backward")) { MoveDir.z = -1; } if (Input.GetButton("Strafe Left")) { MoveDir.x = -1; } if (Input.GetButton("Strafe Right")) { MoveDir.x = 1; } if (onGround) { MoveDir = MoveDir.normalized * (MoveSpeed + (Skills.GetSubSkillValue("Agility") / 100f)); if (Input.GetButton("Run") && Stats.current_Stamina >= RunCostPerSec && MoveDir != Vector3.zero) { MoveDir *= RunMultiplicator; if (!isRunning) { isRunning = true; CmdSetRunning(isRunning); } } if ((Input.GetButton("Run") == false || MoveDir == Vector3.zero) && isRunning) { isRunning = false; CmdSetRunning(isRunning); } if (Input.GetButton("Crouch")) { //MoveDir *= CrouchMultiplicator; MoveDir = Vector3.zero; } } else { MoveDir = MoveDir.normalized * MoveSpeed; } if (Input.GetButtonDown("Crouch")) { HitBox.height = ColliderHeight / 2f; HitBox.center = ColliderCenter / 2f; isCrouching = true; } if (Input.GetButtonUp("Crouch")) { HitBox.height = ColliderHeight; HitBox.center = ColliderCenter; isCrouching = false; } if (Input.GetButtonDown("Jump") && onGround && Stats.current_Stamina > 1) { MoveDir.y = JumpPower + (Skills.GetSubSkillValue("Athletics") / 100f); //AnimationControl.doJump(); //onGround = false; CmdJump(); } if (MoveDir == Vector3.zero && onGround) { RB.velocity = new Vector3(RB.velocity.x * Drag, RB.velocity.y - 0.1f, RB.velocity.z * Drag); return; } Force = Vector3.zero; Force += transform.forward * MoveDir.z; Force += transform.right * MoveDir.x; Force += Vector3.up * (RB.velocity.y + MoveDir.y); if (Force != Vector3.zero && onGround) { RB.velocity = new Vector3(Force.x, Force.y, Force.z); } if (Force != Vector3.zero && !onGround && Vector3.Distance(Vector3.zero, RB.velocity) < Vector3.Distance(Vector3.zero, new Vector3(Force.x, 0, Force.z))) { RB.AddForce(new Vector3(Force.x, 0, Force.z) * AirForce, ForceMode.Acceleration); } if (!onGround) { RB.velocity = new Vector3(RB.velocity.x * AirDrag, RB.velocity.y, RB.velocity.z * AirDrag); } }