created a debug prefab

This commit is contained in:
Melbyj1125
2022-02-18 13:56:10 -06:00
parent 820b11dd61
commit 167f7840a0
108 changed files with 9076 additions and 123 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cbd26ea59a5c21a4284c123c05406717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseAirKickState : dOffenseBaseState
{
private float legRotation = 0; // angle for leg rotation
bool kicked = false; // whether they have kicked or not
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
oSM.leg.SetActive(true); // activate leg
legRotation = -90;
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
kicked = false; // haven't kicked
//start kicking routine
oSM.StartCoroutine(kicking(8f));
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
legRotation = 0; // reset leg angle
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
oSM.leg.SetActive(false); // reset leg angle
}
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
//if kicked or grounded then cooldown
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
//jitter player upwards because of a weird issue with collider
oSM.moveController.Move(new Vector3(0,.002f,0));
}
//kicking timer
private IEnumerator kicking(float waitTime){
yield return new WaitForSeconds(waitTime);
kicked = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1979beb1f8855ca419e5694da5cd0c26
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseAirPunchState : dOffenseBaseState
{
private float legRotation = 0; // angle for leg rotation
bool kicked = false; // whether they have kicked or not
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
oSM.leg.SetActive(true); // activate leg
legRotation = -90;
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
kicked = false; // haven't kicked
//start kicking routine
oSM.StartCoroutine(kicking(8f));
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
legRotation = 0; // reset leg angle
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
oSM.leg.SetActive(false); // reset leg angle
}
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
//if kicked or grounded then cooldown
if(kicked || (oSM.aSM.currentState == oSM.aSM.GroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
//jitter player upwards because of a weird issue with collider
oSM.moveController.Move(new Vector3(0,.002f,0));
}
//kicking timer
private IEnumerator kicking(float waitTime){
yield return new WaitForSeconds(waitTime);
kicked = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 639f429564de9864292274ce4630d8b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseKickState : dOffenseBaseState
{
float legRotation = 0; // angle for leg rotation
bool kicked = false; // whether they have kicked or not
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
oSM.leg.SetActive(true); // activate leg
kicked = false; // haven't kicked
//start kicking routine
oSM.StartCoroutine(kicking(1f));
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
legRotation = 0; // reset leg angle
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
oSM.leg.SetActive(false); // reset leg angle
}
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
//if kicked then cooldown
if(kicked){
oSM.SwitchState(oSM.CooldownState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
//if leg isn't fully extended rotate it
if(legRotation > -90){
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
legRotation -= 20;
}
else{
legRotation = -90;
}
//jitter player upwards because of a weird issue with collider
oSM.moveController.Move(new Vector3(0,.002f,0));
}
//kicking timer
private IEnumerator kicking(float waitTime){
yield return new WaitForSeconds(waitTime);
kicked = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b4d338e2fa79844b8a2a385e9534520
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffensePunchState : dOffenseBaseState
{
float legRotation = 0; // angle for leg rotation
bool kicked = false; // whether they have kicked or not
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
oSM.leg.SetActive(true); // activate leg
kicked = false; // haven't kicked
//start kicking routine
oSM.StartCoroutine(kicking(1f));
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
legRotation = 0; // reset leg angle
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z); // rotate leg
oSM.leg.SetActive(false); // deactivate leg
}
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then cooldown
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.CooldownState);
}
//if kicked then cooldown
if(kicked){
oSM.SwitchState(oSM.CooldownState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
//if leg isn't fully extended rotate it
if(legRotation > -90){
oSM.leg.transform.eulerAngles = new Vector3(legRotation, oSM.leg.transform.eulerAngles.y, oSM.leg.transform.eulerAngles.z);
legRotation -= 20;
}
else{
legRotation = -90;
}
//jitter player upwards because of a weird issue with collider
oSM.moveController.Move(new Vector3(0,.002f,0));
}
//kicking timer
private IEnumerator kicking(float waitTime){
yield return new WaitForSeconds(waitTime);
kicked = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 190b69b70a6fd684aabaee22d13b1d41
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1b4008d8f961aaa4cac36f186b176641
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseCooldownState : dOffenseBaseState
{
bool cooldown = false; // whether or not cooldown is over
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
cooldown = false; // cooldown isn't over
//start cooldown
oSM.StartCoroutine(kickCooldown());
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
}
public override void UpdateState(dOffenseStateManager oSM){
//if cooldown over and incapacitated then incapacitated
if(cooldown && (oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.IncapacitatedState);
}
//if cooldown over then None
else if(cooldown){
oSM.SwitchState(oSM.NoneState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
}
//kick cooldown
private IEnumerator kickCooldown(){
yield return new WaitForSeconds(.5f);
cooldown = true;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6057e16fd22e5bc4893db0d4392988d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseIncapacitatedState : dOffenseBaseState
{
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
}
public override void UpdateState(dOffenseStateManager oSM){
//if no longer incapacitated then None
if((oSM.mSM.currentState != oSM.mSM.RagdollState && oSM.mSM.currentState != oSM.mSM.SlideState && oSM.mSM.currentState != oSM.mSM.CrouchState && oSM.mSM.currentState != oSM.mSM.CrouchWalkState) && (oSM.aSM.currentState != oSM.aSM.WallRunState && oSM.aSM.currentState != oSM.aSM.WallIdleState && oSM.aSM.currentState != oSM.aSM.GrappleAirState && oSM.aSM.currentState != oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.NoneState);
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a65473cdff4d4d343bd9fea0d2abf01b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dOffenseNoneState : dOffenseBaseState
{
public override void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState){
}
public override void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState){
}
public override void UpdateState(dOffenseStateManager oSM){
//if incapacitated then incapacitated
if((oSM.mSM.currentState == oSM.mSM.RagdollState || oSM.mSM.currentState == oSM.mSM.SlideState || oSM.mSM.currentState == oSM.mSM.CrouchState || oSM.mSM.currentState == oSM.mSM.CrouchWalkState) || (oSM.aSM.currentState == oSM.aSM.WallRunState || oSM.aSM.currentState == oSM.aSM.WallIdleState || oSM.aSM.currentState == oSM.aSM.GrappleAirState || oSM.aSM.currentState == oSM.aSM.GrappleGroundedState)){
oSM.SwitchState(oSM.IncapacitatedState);
}
//if grounded then grounded kick states
else if(oSM.aSM.currentState == oSM.aSM.GroundedState && (Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
//if power is above 300 then punch
if(oSM.pStats.KickPow > 300){
oSM.SwitchState(oSM.PunchState);
}
//otherwise kick
else{
oSM.SwitchState(oSM.KickState);
}
}
//if in the air
else if((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0)){
//if power is above 300 air punch
if(oSM.pStats.KickPow > 300){
oSM.SwitchState(oSM.AirPunchState);
}
//otherwise air kick
else{
oSM.SwitchState(oSM.AirKickState);
}
}
}
public override void FixedUpdateState(dOffenseStateManager oSM){
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 207ecd38b476de8458c6f495c74f01c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class dOffenseBaseState
{
public abstract void EnterState(dOffenseStateManager oSM, dOffenseBaseState previousState);
public abstract void ExitState(dOffenseStateManager oSM, dOffenseBaseState nextState);
public abstract void UpdateState(dOffenseStateManager oSM);
public abstract void FixedUpdateState(dOffenseStateManager oSM);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48e9373052af5ca40b2f91cfb88cd315
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAPI;
public class dOffenseStateManager : NetworkBehaviour
{
////Player States
public dOffenseBaseState currentState;
public dOffenseBaseState previousState;
//Offense States
public dOffenseNoneState NoneState = new dOffenseNoneState();
public dOffenseIncapacitatedState IncapacitatedState = new dOffenseIncapacitatedState();
public dOffenseCooldownState CooldownState = new dOffenseCooldownState();
//Kick&Punch States
public dOffenseKickState KickState = new dOffenseKickState();
public dOffenseAirKickState AirKickState = new dOffenseAirKickState();
public dOffensePunchState PunchState = new dOffensePunchState();
public dOffenseAirPunchState AirPunchState = new dOffenseAirPunchState();
////
////Objects Sections
GameObject parentObj; // Parent object
public GameObject leg; // leg object
public GameObject legHitbox; // leg hitbox
////
////Components Section
public CharacterController moveController; // Character Controller
Rigidbody rB; // Players Rigidbody
CapsuleCollider capCol; // Players Capsule Collider
Animator animator; // Animation Controller
////
////Scripts Section
public PlayerStats pStats; // Player Stats
public dMoveStateManager mSM; // move state manager
public dAerialStateManager aSM; // aerial state manager
////
void Awake(){
////Initialize Player Components
moveController = GetComponent<CharacterController>(); // set Character Controller
rB = GetComponent<Rigidbody>(); //set Rigid Body
capCol = GetComponent<CapsuleCollider>(); // set Capsule Collider
capCol.enabled = true;
animator = GetComponent<Animator>(); // set animator
////
////Initialize Player Objects
leg = transform.Find("Leg").gameObject; // Set Leg Object
legHitbox = leg.transform.Find("LegHitbox").gameObject; // Set Leg Hitbox
leg.SetActive(false);
parentObj = transform.parent.gameObject; // set parent object
////
////Initialize Scripts
pStats = GetComponent<PlayerStats>(); // set PlayerStats
mSM = GetComponent<dMoveStateManager>(); // set move state manager
aSM = GetComponent<dAerialStateManager>(); // set aerial state manager
////
}
void Start(){
//players starting state
currentState = NoneState;
previousState = NoneState;
currentState.EnterState(this, previousState);
}
void Update(){
//if (!IsLocalPlayer) { return; }
//calls any logic in the update state from current state
currentState.UpdateState(this);
}
void FixedUpdate(){
//if (!IsLocalPlayer) { return; }
//calls any logic in the fixed update state from current state
currentState.FixedUpdateState(this);
}
public void SwitchState(dOffenseBaseState state){
currentState.ExitState(this, state);
//Sets the previous State
previousState = currentState;
//updates current state and calls logic for entering
currentState = state;
currentState.EnterState(this, previousState);
}
//Collision checker for the leg
private void OnCollisionEnter(Collision collision)
{
if (!IsLocalPlayer) { return; }
Collider myCollider = collision.contacts[0].thisCollider;
if (collision.transform.CompareTag("kickable") && myCollider == legHitbox.GetComponent<Collider>()){
if(collision.gameObject.GetComponent<Rigidbody>().isKinematic == true){
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
}
Vector3 direction = this.transform.forward;
Debug.Log(direction);
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
}
if (collision.transform.CompareTag("destroyable") && myCollider == legHitbox.GetComponent<Collider>()){
collision.transform.gameObject.GetComponent<BreakableBlock>().damage(pStats.KickPow);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aae777136fbdb954083d81a3deeb7313
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: