Browse Source

special attack on both buttons

master
Josh 2 years ago
parent
commit
c0a2df16b5
  1. 4
      .gitignore
  2. 114
      unity_project/Assets/BeatEmUp_GameTemplate3D/AnimationControllers/PlayerController.controller
  3. 4
      unity_project/Assets/BeatEmUp_GameTemplate3D/Resources/InputManager.prefab
  4. 45
      unity_project/Assets/BeatEmUp_GameTemplate3D/Scripts/Player/PlayerCombat.cs
  5. 30
      unity_project/Assets/BeatEmUp_GameTemplate3D/Scripts/Player/PlayerMovement.cs
  6. 11
      unity_project/Assets/Characters/dorothy/Dorothy Prefab.prefab

4
.gitignore

@ -71,3 +71,7 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta /[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/* /[Aa]ssets/[Ss]treamingAssets/aa/*
unity_project/Library
unity_project/Logs
unity_project/Temp
unity_project/obj

114
unity_project/Assets/BeatEmUp_GameTemplate3D/AnimationControllers/PlayerController.controller

@ -25,28 +25,6 @@ AnimatorStateTransition:
m_InterruptionSource: 0 m_InterruptionSource: 0
m_OrderedInterruption: 1 m_OrderedInterruption: 1
m_CanTransitionToSelf: 0 m_CanTransitionToSelf: 0
--- !u!1101 &-5206101775321413371
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 110244858}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!91 &9100000 --- !u!91 &9100000
AnimatorController: AnimatorController:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -61,205 +39,205 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: JumpKickActive - m_Name: JumpKickActive
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: JumpKick - m_Name: JumpKick
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Punch1 - m_Name: Punch1
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Punch2 - m_Name: Punch2
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Punch3 - m_Name: Punch3
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Defend - m_Name: Defend
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Hit1 - m_Name: Hit1
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Hit2 - m_Name: Hit2
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Kick0 - m_Name: Kick0
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Kick1 - m_Name: Kick1
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Kick2 - m_Name: Kick2
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: GroundPunch - m_Name: GroundPunch
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: GroundKick - m_Name: GroundKick
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Pickup - m_Name: Pickup
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Run - m_Name: Run
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Walk - m_Name: Walk
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Idle - m_Name: Idle
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: JumpInProgress - m_Name: JumpInProgress
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Falling - m_Name: Falling
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: MovementSpeed - m_Name: MovementSpeed
m_Type: 1 m_Type: 1
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: Death - m_Name: Death
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: KnockDown_Up - m_Name: KnockDown_Up
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: KnockDown_Down - m_Name: KnockDown_Down
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: KnockDown_End - m_Name: KnockDown_End
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: StandUp - m_Name: StandUp
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: isGrounded - m_Name: isGrounded
m_Type: 4 m_Type: 4
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: JumpUp - m_Name: JumpUp
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: ThrowWeapon - m_Name: ThrowWeapon
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: FireGun - m_Name: FireGun
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: SwingWeapon - m_Name: SwingWeapon
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: RunningPunch - m_Name: RunningPunch
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: RunningKick - m_Name: RunningKick
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
- m_Name: TornadoKick - m_Name: TornadoKick
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 0} m_Controller: {fileID: 9100000}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
@ -2855,6 +2833,28 @@ AnimatorState:
m_MirrorParameter: m_MirrorParameter:
m_CycleOffsetParameter: m_CycleOffsetParameter:
m_TimeParameter: m_TimeParameter:
--- !u!1101 &1424379873004975657
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102332405851808462}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.8076923
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &5679427123164778674 --- !u!1102 &5679427123164778674
AnimatorState: AnimatorState:
serializedVersion: 6 serializedVersion: 6
@ -2866,7 +2866,7 @@ AnimatorState:
m_Speed: 2 m_Speed: 2
m_CycleOffset: 0 m_CycleOffset: 0
m_Transitions: m_Transitions:
- {fileID: -5206101775321413371} - {fileID: 1424379873004975657}
m_StateMachineBehaviours: [] m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0} m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 1 m_IKOnFeet: 1

4
unity_project/Assets/BeatEmUp_GameTemplate3D/Resources/InputManager.prefab

@ -73,9 +73,9 @@ MonoBehaviour:
- Action: Punch - Action: Punch
inputType: 0 inputType: 0
key: 331 key: 331
- Action: Kick - Action:
inputType: 0 inputType: 0
key: 332 key: 0
- Action: Defend - Action: Defend
inputType: 0 inputType: 0
key: 333 key: 333

45
unity_project/Assets/BeatEmUp_GameTemplate3D/Scripts/Player/PlayerCombat.cs

@ -267,19 +267,23 @@ public class PlayerCombat : MonoBehaviour, IDamagable<DamageObject> {
} }
} }
//jump punch //special attack (both)
if (action == "Punch" && buttonState == BUTTONSTATE.PRESS) {
var pm = GetComponent<PlayerMovement>();
if (pm != null && (pm.JumpNextFixedUpdate || (pm.jumpInProgress && pm.JumpIsRecent())))
{
DoSpecialAttack(pm);
Debug.Log("did special attack");
return;
}
}
//jump kick (using punch button)
if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && !isGrounded) { if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && !isGrounded) {
if(JumpKickData.animTrigger.Length > 0) { if(JumpKickData.animTrigger.Length > 0) {
doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick"); Debug.Log("did jump kick");
StartCoroutine(JumpKickInProgress()); doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick");
}
return;
}
//jump kick
if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && !isGrounded) {
if(JumpKickData.animTrigger.Length > 0) {
doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick");
StartCoroutine(JumpKickInProgress()); StartCoroutine(JumpKickInProgress());
} }
return; return;
@ -311,10 +315,24 @@ public class PlayerCombat : MonoBehaviour, IDamagable<DamageObject> {
} }
} }
public void DoSpecialAttack(PlayerMovement pm)
{
pm.CancelJump();
pm.JumpNextFixedUpdate = false;
pm.SetDirection(currentDirection);
doAttack(KickCombo[0], UNITSTATE.KICK, "Kick");
return;
}
#endregion #endregion
#region Combat functions #region Combat functions
public bool IsPunching()
{
return playerState.currentState == UNITSTATE.PUNCH;
}
private void doAttack(DamageObject damageObject, UNITSTATE state, string inputAction){ private void doAttack(DamageObject damageObject, UNITSTATE state, string inputAction){
animator.SetAnimatorTrigger(damageObject.animTrigger); animator.SetAnimatorTrigger(damageObject.animTrigger);
playerState.SetState(state); playerState.SetState(state);
@ -335,6 +353,11 @@ public class PlayerCombat : MonoBehaviour, IDamagable<DamageObject> {
if(state == UNITSTATE.JUMPKICK) return; if(state == UNITSTATE.JUMPKICK) return;
Invoke ("Ready", damageObject.duration); Invoke ("Ready", damageObject.duration);
} }
public const float SIMULTANEOUS_BUTTON_SPACING = .03f;
public bool AttackIsRecent()
{
return lastAttackTime > Time.time - PlayerCombat.SIMULTANEOUS_BUTTON_SPACING;
}
//use the currently equipped weapon //use the currently equipped weapon
void useCurrentWeapon(){ void useCurrentWeapon(){

30
unity_project/Assets/BeatEmUp_GameTemplate3D/Scripts/Player/PlayerMovement.cs

@ -38,11 +38,12 @@ public class PlayerMovement : MonoBehaviour {
public bool jumpInProgress; public bool jumpInProgress;
private bool isDead = false; private bool isDead = false;
private bool JumpNextFixedUpdate; public bool JumpNextFixedUpdate;
private float jumpDownwardsForce = .3f; private float jumpDownwardsForce = .3f;
private float lastJumpTime = 0f;
//a list of states where movement can take place //a list of states where movement can take place
private List<UNITSTATE> MovementStates = new List<UNITSTATE> { private List<UNITSTATE> MovementStates = new List<UNITSTATE> {
UNITSTATE.IDLE, UNITSTATE.IDLE,
UNITSTATE.WALK, UNITSTATE.WALK,
UNITSTATE.RUN, UNITSTATE.RUN,
@ -175,6 +176,7 @@ public class PlayerMovement : MonoBehaviour {
JumpNextFixedUpdate = false; JumpNextFixedUpdate = false;
jumpInProgress = true; jumpInProgress = true;
rb.velocity = Vector3.up * JumpForce; rb.velocity = Vector3.up * JumpForce;
lastJumpTime = Time.time;
//play animation //play animation
animator.SetAnimatorBool("JumpInProgress", true); animator.SetAnimatorBool("JumpInProgress", true);
@ -222,14 +224,28 @@ public class PlayerMovement : MonoBehaviour {
if(doubleTapActive && IsGrounded() && Mathf.Abs(dir.x)>0) playerState.SetState(UNITSTATE.RUN); if(doubleTapActive && IsGrounded() && Mathf.Abs(dir.x)>0) playerState.SetState(UNITSTATE.RUN);
} }
public bool JumpIsRecent()
{
return lastJumpTime > Time.time - PlayerCombat.SIMULTANEOUS_BUTTON_SPACING;
}
//input actions //input actions
void OnInputEvent(string action, BUTTONSTATE buttonState) { void OnInputEvent(string action, BUTTONSTATE buttonState) {
//ignore input when we are dead or when this state is not active //special attack (jump + attack) if jump is hit second
if(!MovementStates.Contains(playerState.currentState) || isDead) return; PlayerCombat pc = GetComponent<PlayerCombat>();
if (action == "Jump" && buttonState == BUTTONSTATE.PRESS && playerState.currentState == UNITSTATE.PUNCH && pc.AttackIsRecent())
{
pc.DoSpecialAttack(this);
}
//start a jump //ignore input when we are dead or when this state is not active
if(action == "Jump" && buttonState == BUTTONSTATE.PRESS && IsGrounded() && playerState.currentState != UNITSTATE.JUMPING) JumpNextFixedUpdate = true; if (!MovementStates.Contains(playerState.currentState) || isDead)
return;
if (action == "Jump" && buttonState == BUTTONSTATE.PRESS && IsGrounded() && playerState.currentState != UNITSTATE.JUMPING) JumpNextFixedUpdate = true;
//start running when a run button is pressed (e.g. Joypad controls) //start running when a run button is pressed (e.g. Joypad controls)
if(action == "Run") playerState.SetState(UNITSTATE.RUN); if(action == "Run") playerState.SetState(UNITSTATE.RUN);

11
unity_project/Assets/Characters/dorothy/Dorothy Prefab.prefab

@ -130,6 +130,7 @@ MonoBehaviour:
currentDirection: -1 currentDirection: -1
inputDirection: {x: 0, y: 0} inputDirection: {x: 0, y: 0}
jumpInProgress: 0 jumpInProgress: 0
JumpNextFixedUpdate: 0
--- !u!114 &4799662874652314383 --- !u!114 &4799662874652314383
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -227,7 +228,7 @@ MonoBehaviour:
knockBackForce: 0 knockBackForce: 0
hitSFX: DefaultHit hitSFX: DefaultHit
knockDown: 1 knockDown: 1
slowMotionEffect: 1 slowMotionEffect: 0
DefenceOverride: 1 DefenceOverride: 1
isGroundAttack: 0 isGroundAttack: 0
animationClip: {fileID: 0} animationClip: {fileID: 0}
@ -284,8 +285,8 @@ MonoBehaviour:
knockBackForce: 5 knockBackForce: 5
hitSFX: HeavyHit hitSFX: HeavyHit
knockDown: 1 knockDown: 1
slowMotionEffect: 1 slowMotionEffect: 0
DefenceOverride: 1 DefenceOverride: 0
isGroundAttack: 0 isGroundAttack: 0
animationClip: {fileID: 0} animationClip: {fileID: 0}
animationSpeed: 0 animationSpeed: 0
@ -303,8 +304,8 @@ MonoBehaviour:
knockBackForce: 5 knockBackForce: 5
hitSFX: HeavyHit hitSFX: HeavyHit
knockDown: 1 knockDown: 1
slowMotionEffect: 1 slowMotionEffect: 0
DefenceOverride: 1 DefenceOverride: 0
isGroundAttack: 0 isGroundAttack: 0
animationClip: {fileID: 0} animationClip: {fileID: 0}
animationSpeed: 0 animationSpeed: 0

Loading…
Cancel
Save