private void GetHit(PunchScriptableObject punch) { spriteRenderer.sortingOrder = 0; if (currentState.stateID == "Evade") { currentState.StateExit(new SwayBackState(this)); return; } if ((currentState.stateID == "BackWalk" || currentState.stateID == "Block") && punch.punchID != "Uppercut") { currentState.StateExit(new BlockState(this, this.punch.blockStun, this.punch.knockbackDistance)); } else // This is for when the player actually get's hit { BroadcastMessage("ReduceHealth", punch.damage); if (health.currentHealth <= 0) { currentState.StateExit(new KOState(this, punch)); } else { currentState.StateExit(new HitState(this, this.punch.hitStun, this.punch.knockbackDistance)); } FindObjectOfType <CameraController>().BroadcastMessage("CameraShaker", 0.2); } }
public KOState(PlayerStateMachine stateMachine, PunchScriptableObject punch) { stateID = "KO"; playerFSM = stateMachine; playerAnimator = stateMachine.GetComponentInChildren <Animator>(); knockBack = punch.knockbackDistance * 2; }
public PlayerPunch(PlayerStateMachine stateMachine, PunchScriptableObject punch) { stateID = "Punch"; // This is a shitty prototype name since we will add more punches playerFSM = stateMachine; playerAnimator = stateMachine.GetComponentInChildren <Animator>(); duration = punch.duration; startUpTime = punch.startUpTime; punchID = punch.punchID; this.punch = punch; }
public void SetVariables(PunchScriptableObject punch, string direction) { BoxCollider2D myCollider = GetComponent <BoxCollider2D>(); myCollider.size = new Vector2(punch.sizeX, punch.sizeY); if (direction == "Right") { myCollider.offset = new Vector2(punch.posX, punch.posY); } else { myCollider.offset = new Vector2(-punch.posX, punch.posY); } this.activeTime = punch.activeTime; this.punch = punch; this.whiffTime = punch.duration - punch.activeTime; }