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. 39
      unity_project/Assets/BeatEmUp_GameTemplate3D/Scripts/Player/PlayerCombat.cs
  5. 24
      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/*
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_OrderedInterruption: 1
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
AnimatorController:
m_ObjectHideFlags: 0
@ -61,205 +39,205 @@ AnimatorController:
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: JumpKickActive
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: JumpKick
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Punch1
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Punch2
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Punch3
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Defend
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Hit1
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Hit2
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Kick0
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Kick1
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Kick2
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: GroundPunch
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: GroundKick
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Pickup
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Run
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Walk
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Idle
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: JumpInProgress
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Falling
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: MovementSpeed
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: Death
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: KnockDown_Up
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: KnockDown_Down
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: KnockDown_End
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: StandUp
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: isGrounded
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: JumpUp
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: ThrowWeapon
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: FireGun
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: SwingWeapon
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: RunningPunch
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: RunningKick
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
- m_Name: TornadoKick
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@ -2855,6 +2833,28 @@ AnimatorState:
m_MirrorParameter:
m_CycleOffsetParameter:
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
AnimatorState:
serializedVersion: 6
@ -2866,7 +2866,7 @@ AnimatorState:
m_Speed: 2
m_CycleOffset: 0
m_Transitions:
- {fileID: -5206101775321413371}
- {fileID: 1424379873004975657}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 1

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

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

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

@ -267,18 +267,22 @@ public class PlayerCombat : MonoBehaviour, IDamagable<DamageObject> {
}
}
//jump punch
if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && !isGrounded) {
if(JumpKickData.animTrigger.Length > 0) {
doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick");
StartCoroutine(JumpKickInProgress());
}
//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
if (action == "Kick" && buttonState == BUTTONSTATE.PRESS && !isGrounded) {
//jump kick (using punch button)
if (action == "Punch" && buttonState == BUTTONSTATE.PRESS && !isGrounded) {
if(JumpKickData.animTrigger.Length > 0) {
Debug.Log("did jump kick");
doAttack(JumpKickData, UNITSTATE.JUMPKICK, "Kick");
StartCoroutine(JumpKickInProgress());
}
@ -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
#region Combat functions
public bool IsPunching()
{
return playerState.currentState == UNITSTATE.PUNCH;
}
private void doAttack(DamageObject damageObject, UNITSTATE state, string inputAction){
animator.SetAnimatorTrigger(damageObject.animTrigger);
playerState.SetState(state);
@ -335,6 +353,11 @@ public class PlayerCombat : MonoBehaviour, IDamagable<DamageObject> {
if(state == UNITSTATE.JUMPKICK) return;
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
void useCurrentWeapon(){

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

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

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

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

Loading…
Cancel
Save