// Use this for initialization void Start() { Move_parameter_x = 0; Move_parameter_x = 0; playerController = this; AttackTrigger = 0; PlayerAnimation_parameter = 0; GhostShadow.ghostShadow.gameObject.GetComponent <GhostShadow>().enabled = false; debounce = true; CanMove = true; AttackCollider_Small.SetActive(false); AttackCollider_Big.SetActive(false); AttackCollider_BigSkill.SetActive(false); CanAttack = true; CancelAttackCoroutine = null; ResetStateCoroutine = null; DoubleClickCoroutine = null; FastRunCoroutine = null; GetUpCoroutine = null; AvoidDistance = AvoidMaxDistance; FixBulletPos = Bullet_pos.transform.position - transform.position; Weapons.transform.parent = WeaponsBone;//-- LightAccessoriesUp.transform.parent = LightAccessoriesUpBone; LightAccessoriesDown.transform.parent = LightAccessoriesDownBone; attackState = AttackState.Default; moveState = MoveState.Idle; playerAnimatorState = PlayerAnimatorState.Movement; avoidState = AvoidState.Default; jumpState = JumpState.Jump; }
//--------------------------Avoid--------------------------------- //--------------------------Dead---------------------------------- public void Dead() { if (playerAnimatorState != PlayerAnimatorState.Dead) { animator.SetTrigger("Dead"); playerAnimatorState = PlayerAnimatorState.Dead; } }
IEnumerator ResetState(float WaitTime) { yield return(new WaitForSeconds(WaitTime)); playerAnimatorState = PlayerAnimatorState.Movement; avoidState = AvoidState.Default; GhostShadow.ghostShadow.gameObject.GetComponent <GhostShadow>().enabled = false; IsFastRun = false; DamageObject.SetActive(true); }
public void ChangeAvoidState() { playerAnimatorState = PlayerAnimatorState.Avoid; AttackColliderClose(); ShortAttack1_Particle.Stop(); ShortAttack2_Particle.Stop(); ShortAttack3_Particle.Stop(); LongAttack_Particle.Stop(); if (avoidState == AvoidState.Back || avoidState == AvoidState.BackLeft || avoidState == AvoidState.BackRight) { GhostShadow.ghostShadow.gameObject.GetComponent <GhostShadow>().enabled = true; } }
public void CanTriggerAttack() //用來判斷哪時可以開始觸發下一階段,掛的位置需搭配每一個動畫之間的Exit Time來配置(數動畫的fram會比較精確) { CanAttack = true;//可以觸發下一階段 playerAnimatorState = PlayerAnimatorState.Attack; //PlayerAnimatorState用來判斷角色的動作(Movement,Attack,Jump,Avoid...) //,再宣告一個attackState來記錄Attack的狀態(Default,Attack1,Attack2...) if (ResetStateCoroutine != null) { StopCoroutine(ResetStateCoroutine); //停止將狀態轉為Idle的Coroutine } if (CancelAttackCoroutine != null) { StopCoroutine(CancelAttackCoroutine); //停止將攻擊狀態轉為Default的Coroutine } StopCoroutine("CancelAttackNow"); }
//--------------------------Move--------------------------------- //--------------------------Jump--------------------------------- private void Jump() { if (IsGround) { if (playerAnimatorState == PlayerAnimatorState.Jump) { playerAnimatorState = PlayerAnimatorState.Movement; jumpState = JumpState.Jump; moveState = MoveState.Idle; animator.SetTrigger("Idle"); // Debug.Log(moveState); } JumpCount = 0; } if (Input.GetKeyDown(KeyCode.Space) && (playerAnimatorState == PlayerAnimatorState.Movement || playerAnimatorState == PlayerAnimatorState.Jump)) { if (IsGround && debounce) { rigi.AddForce(0, JumpHeight, 0, ForceMode.Impulse); animator.SetTrigger("Jump"); playerAnimatorState = PlayerAnimatorState.Jump; jumpState = JumpState.Jump; StartCoroutine("Debounce"); } else if (JumpCount == 0 && !IsGround && debounce) { JumpCount -= 1; rigi.mass = 10; rigi.velocity = Vector3.zero; rigi.AddForce(0, DoubleJumpHigh, 0, ForceMode.Impulse); rigi.mass = 800; animator.SetTrigger("DoubleJump"); playerAnimatorState = PlayerAnimatorState.Jump; jumpState = JumpState.DoubleJump; } } }
public void StateChangeToFalling() { playerAnimatorState = PlayerAnimatorState.Jump; jumpState = JumpState.Falling; animator.ResetTrigger("Idle"); }
public void FirstAttackState() { playerAnimatorState = PlayerAnimatorState.Attack; }
private void AvoidStateSelect(AvoidState InputAvoidState) { UI_HP.Ui_HP.SP -= UI_HP.Ui_HP.SP_Max / UI_HP.Ui_HP.SP_Light.Length; UI_HP.Ui_HP.ConsumeSP(); CanMove = true; playerAnimatorState = PlayerAnimatorState.Avoid; DamageObject.SetActive(false); avoidStartTime = Time.time; switch (InputAvoidState) { case AvoidState.Forward: avoidState = InputAvoidState; animator.SetTrigger("Avoid_Forward"); AvoidRotate = 0; break; case AvoidState.Back: avoidState = AvoidState.Back; animator.SetTrigger("Avoid_Back"); AvoidRotate = 180; break; case AvoidState.Left: avoidState = AvoidState.Left; animator.SetTrigger("Avoid_Left"); AvoidRotate = -90; break; case AvoidState.Right: avoidState = AvoidState.Right; animator.SetTrigger("Avoid_Right"); AvoidRotate = 90; break; case AvoidState.ForwardLeft: avoidState = AvoidState.ForwardLeft; animator.SetTrigger("Avoid_ForwardLeft"); AvoidRotate = -45; break; case AvoidState.ForwardRight: avoidState = AvoidState.ForwardRight; animator.SetTrigger("Avoid_ForwardRight"); AvoidRotate = 45; break; case AvoidState.BackLeft: avoidState = AvoidState.BackLeft; animator.SetTrigger("Avoid_BackLeft"); AvoidRotate = -135; break; case AvoidState.BackRight: avoidState = AvoidState.BackRight; animator.SetTrigger("Avoid_BackRight"); AvoidRotate = 135; break; } AvoidEuler = Quaternion.Euler(0, RotationX + AvoidRotate, 0); AvoidPosition = AvoidEuler * new Vector3(0, 0, AvoidDistance) + transform.position; }