void Update() { Vector2 groundBoxPosition = (Vector2)transform.position + new Vector2(0, -0.01f); Vector2 groundBoxSize = (Vector2)transform.localScale + new Vector2(-0.02f, 0); newIsGrounded = Physics2D.OverlapBox(groundBoxPosition, groundBoxSize, 0, groundLayerMask); if (newIsGrounded != isGrounded) { isGrounded = newIsGrounded; //Debug.Log($"{Time.time}: IsGrounded:{isGrounded}"); } if (isGrounded) { AerialState = AerialState.Grounded; } else if (rigidBody.velocity.y < 0) { AerialState = AerialState.Falling; } else if (AerialState == AerialState.Grounded) { AerialState = AerialState.FirstJump; } }
/// <summary> /// 初期化処理 /// </summary> void Start() { // コンポーネントの取得 playerBoost = GetComponent <PlayerBoost>(); playerSlide = GetComponent <PlayerSlide>(); playerAerialState = GetComponent <AerialState>(); playerAttack = GetComponent <PlayerAttack>(); character = GetComponent <Player>(); }
/// <summary> /// 初期化処理 /// </summary> void Start() { // コンポーネントを取得 playerGlide = GetComponent <PlayerGlide>(); character = GetComponent <Player>(); aerialState = GetComponent <AerialState>(); runState = GetComponent <RunState>(); downState = GetComponent <DownState>(); playerCharge = GetComponent <PlayerCharge>(); playerAttack = GetComponent <PlayerAttack>(); }
private void InitializeAirMachine() { AerialState s_aerial = new AerialState(ref c_playerData, ref c_collisionData, ref c_aerialMoveData, ref c_positionData); GroundedState s_grounded = new GroundedState(ref c_playerData, ref c_aerialMoveData, ref c_collisionData, ref c_positionData); BoostState s_boost = new BoostState(ref c_playerData, ref c_aerialMoveData, ref c_collisionData, ref c_positionData, ref c_turnData); JumpChargeState s_jumpCharge = new JumpChargeState(ref c_playerData, ref c_positionData, ref c_collisionData, ref c_aerialMoveData, ref cart_incr); AirDisabledState s_airDisabled = new AirDisabledState(); c_airMachine = new StateMachine(StateRef.GROUNDED); c_airMachine.AddState(s_grounded, StateRef.GROUNDED); c_airMachine.AddState(s_aerial, StateRef.AIRBORNE); c_airMachine.AddState(s_jumpCharge, StateRef.CHARGING); c_airMachine.AddState(s_airDisabled, StateRef.DISABLED); c_airMachine.AddState(s_boost, StateRef.GROUNDED_BOOSTING); }
public void UpdateAerialState(CountdownTimer jumpResponseCountdownTimer, bool jumpButtonDown, bool jumpButtonUp) { jumpResponseCountdownTimer.Tick(Time.deltaTime); float finalJumpHeight = JumpHeight * (1 - (PlayerItemSlot != null ? PlayerItemSlot.JumpPenaltyWhenPickedUp : 0f)); //Skaczemy if (AerialState == AerialState.Grounded && jumpButtonDown //Mozna wykonac drugi skok && jumpResponseCountdownTimer.Expired) { alreadyJumpedTwice = false; jumpCommand.Execute(anim); JumpSound?.Play(); rigidBody.AddForce(Vector2.up * finalJumpHeight); jumpResponseCountdownTimer.Start(); //Debug.Log($"{Time.time}: Jump:{rigidBody.velocity}"); } else if ( (AerialState == AerialState.FirstJump || AerialState == AerialState.Falling) && jumpButtonDown && !alreadyJumpedTwice) { alreadyJumpedTwice = true; jumpCommand.Execute(anim); JumpSound?.Play(); AerialState = AerialState.SecondJump; //przed skokiem wyzerowanie predkości wznoszenia, żeby drugi skok nie zwielokratniał bieżącej siły skoku rigidBody.velocity = new Vector2(rigidBody.velocity.x, 0); rigidBody.AddForce(Vector2.up * finalJumpHeight); jumpResponseCountdownTimer.Stop(); //Debug.Log($"{Time.time}: Jump2:{rigidBody.velocity}"); } //Wyladowal else if (AerialState == AerialState.Grounded) { jumpResponseCountdownTimer.Stop(); } }
private void Start() { currentState = new InitialState(this); actions = new IAction[0]; // playerChar = GameObject.FindGameObjectWithTag("Player"); initialState = new InitialState(this); advanceState = new AdvanceState(this); retreatState = new RetreatState(this); projectileState = new ProjectileState(this); antiAirState = new AntiAirState(this); aerialState = new AerialState(this); jumpState = new JumpState(this); aggression = 0.0f; jumpChance = 0; aerialChance = 0; dpChance = 0; projectileChance = 0; idleChance = 0; retreatChance = 0; advanceChance = 0; totalTime = 0; }
/// <summary> /// 初期化処理 /// </summary> void Awake() { // 子オブジェクトを取得 feverEffect = transform.Find("FeverEffect").GetComponent <ParticleSystem>(); boostEffect = transform.Find("BoostEffect").GetComponent <ParticleSystem>(); chargeingEffect = transform.Find("ChargeEffects/Charging").GetComponent <ParticleSystem>(); chargeSignal = transform.Find("ChargeEffects/ChargeSignal").GetComponent <ParticleSystem>(); chargePauseEffect = transform.Find("ChargeEffects/ChargePause").GetComponent <ParticleSystem>(); chargeMaxEffect = transform.Find("ChargeEffects/ChargeMax").GetComponent <ParticleSystem>(); // アタッチされているステートを取得 aerialState = GetComponent <AerialState>(); afterSlideState = GetComponent <AfterSlideState>(); boostState = GetComponent <BoostState>(); downState = GetComponent <DownState>(); glideState = GetComponent <GlideState>(); idleState = GetComponent <IdleState>(); runState = GetComponent <RunState>(); slideState = GetComponent <SlideState>(); afterGoalState = GetComponent <AfterGoalState>(); // ステートを管理するクラスを取得 playerStateManager = new PlayerStateManager(); }
// Start is called before the first frame update void Start() { obj = GameObject.Find("Aerial"); _AerialState = AerialState.STATE_BACK; //this.gameObject.SetActive(false); }
public void SetAerialState(AerialState s) { _AerialState = s; }