public IState DashingState() { IState newState = new DashingState(playerController.playerRigidBody, playerController, playerController.jumpVector, playerController.stateMachine); Debug.Log("new DashingState created, - " + newState + playerController.playerRigidBody + playerController + playerController.jumpVector + playerController.stateMachine); return(newState); }
private void Start() { playtime = 0; pData = GetComponent <PlayerData>(); if (File.Exists(selectedProfilePath)) { selectedProfile = File.ReadAllText(selectedProfilePath); saveDataPath += selectedProfile + ".json"; if (File.Exists(saveDataPath)) { string json = File.ReadAllText(saveDataPath); var dto = JsonConvert.DeserializeObject <PlayerDTO>(json); pData.serializeData = dto.playerSerializeData; playtime = dto.Playtime; if (pData.HasCheckPoint) { transform.position = new Vector2(pData.PosX, pData.PosY); } } } pInput = new PlayerInput(pData); spriteRenderer = GetComponent <SpriteRenderer>(); audioSource = GetComponent <AudioSource>(); #region Initialize States IdleState = new IdleState(this, pInput, pData, "Idle_Animation"); RunningState = new RunningState(this, pInput, pData, "Running_Animation"); FallingState = new FallingState(this, pInput, pData, "Falling_Animation"); JumpState = new JumpState(this, pInput, pData, "Jump_Animation"); StartFallingState = new StartFallingState(this, pInput, pData, "Start_Falling_Animation"); WallSlideState = new WallSlideState(this, pInput, pData, "Wall_slide"); DashingState = new DashingState(this, pInput, pData, "Dash_Animation"); PrimaryAttackState = new PrimaryAttackState(this, pInput, pData, "Left_swing_attack"); GroundedSecondaryAttackState = new GroundedSecondaryAttackState(this, pInput, pData, "Right_swing_attack"); GroundedDownwardAttackState = new GroundedDownwardAttackState(this, pInput, pData, "Downward");; DeathState = new DeathState(this, pInput, pData, "Death_Animation"); CheckPointState = new CheckPointState(this, pInput, pData, "CheckPoint_Animation"); WallJumpState = new WallJumpState(this, pInput, pData, "Jump_Animation"); currentState = IdleState; #endregion Initialize States }