private void Awake() { fsm = GetComponent <Animator>(); player = GetComponent <Player>(); playerAnimator = GetComponent <PlayerAnimator>(); playerAudio = GetComponent <PlayerAudio>(); state = new FsmFrameInfo(AnimStates.ENTRY); frameInfo = new PlayerFrameInfo(); GameManager manager = Toolbox.GetOrAddComponent <GameManager>(); manager.RegisterPlayer(this); #if UNITY_EDITOR state.DebugInit(fsm); #endif }
public void DoUpdate(Player player, ref PlayerFrameInfo frameInfo) { animator.SetFloat(AnimParams.FACEDIRX, player.FaceDir.x); animator.SetFloat(AnimParams.FACEDIRY, player.FaceDir.y); spriteRenderer.sortingOrder = Mathf.RoundToInt(player.transform.position.y * 100f) * -1; if (frameInfo.isFullyCharged) { flasherCharge.Stop(); flasherFullCharge.Start(); } else if (frameInfo.isCharging) { flasherCharge.Start(); } else if (frameInfo.hasStoppedCharging) { flasherCharge.Stop(); flasherFullCharge.Stop(); } }
public void DoUpdate(Player player, ref PlayerFrameInfo frameInfo) { if (frameInfo.isAttacking) { PlaySfxEvent ev = new PlaySfxEvent(swordSound); eventManager.Publish(Events.PLAY_SFX, ev); } if (frameInfo.isChargeAttacking) { PlaySfxEvent ev = new PlaySfxEvent(swordSound); eventManager.Publish(Events.PLAY_SFX, ev); } if (frameInfo.damageInfo != null) { PlaySfxEvent ev = new PlaySfxEvent(owSounds[Random.Range(0, owSounds.Length)]); eventManager.Publish(Events.PLAY_SFX, ev); } if (player.currentHp <= 0) { PlaySfxEvent ev = new PlaySfxEvent(deathSounds[Random.Range(0, deathSounds.Length)]); eventManager.Publish(Events.PLAY_SFX, ev); } }
public void DoUpdate(FsmFrameInfo state, ControlManager c, ref PlayerFrameInfo frameInfo) { this.frameInfo = frameInfo; if (frameInfo.damageInfo != null) { Damage(frameInfo.damageInfo); } if (state.hasChanged) { if (state.prev == AnimStates.ROLL) { StopRoll(); } if (state.curr == AnimStates.ATTACK1) { frameInfo.isAttacking = true; ResetCharge(); if (c.isMoved) { Face(c.move); } } else if (state.curr == AnimStates.ATTACK2) { frameInfo.isAttacking = true; ResetCharge(); if (c.isMoved) { Face(c.move); } } else if (state.curr == AnimStates.ATTACK3) { frameInfo.isAttacking = true; ResetCharge(); if (c.isMoved) { Face(c.move); } } else if (state.curr == AnimStates.CHARGEATTACK) { frameInfo.isChargeAttacking = true; ResetCharge(); if (c.isMoved) { Face(c.move); } } else if (state.curr == AnimStates.ROLL) { if (c.isMoved) { StartRoll(c.move); } else { StartRoll(FaceDir); } } } if (state.curr == AnimStates.IDLE) { if (c.isAttackHeld) { AddCharge(Time.deltaTime); } if (c.isMoved) { Walk(c.move); } if (c.isAttackReleased) { if (IsFullyCharged) { frameInfo.toChargeAttack = true; } else if (IsCharging) { frameInfo.toAttack = true; } ResetCharge(); } } else if (state.curr == AnimStates.WALK) { if (c.isAttackHeld) { AddCharge(Time.deltaTime); } if (c.isMoved) { Walk(c.move); } if (c.isAttackReleased) { if (IsFullyCharged) { frameInfo.toChargeAttack = true; } else if (IsCharging) { frameInfo.toAttack = true; } ResetCharge(); } } else if (state.curr == AnimStates.ROLL) { mover.UpdateVelocity(); } }