private void Awake() { _stateMachine = new PlayerStateMachine(); CombatController = new CombatController(); IdleState = new PlayerIdleState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_IDLE_2_HASH); MoveState = new PlayerMoveState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_RUN_2_HASH); JumpState = new PlayerJumpState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_JUMP_HASH); InAirState = new PlayerInAirState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_AIR_HASH); LandState = new PlayerLandState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LAND_HASH); WallSlideState = new PlayerWallSlideState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_WALL_SLIDING_HASH); LedgeClimbState = new PlayerLedgeClimbState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LEDGE_GRAB_HASH); LedgeJumpState = new PlayerLedgeJumpState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_LEDGE_JUMP_HASH); CrouchIdleState = new PlayerCrouchIdleState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_CROUCH_IDLE_HASH); CrouchMoveState = new PlayerCrouchMoveState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_CROUCH_WALK_HASH); SwordAttackState = new PlayerSwordAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_ATTACK_1_HASH, 3); HandAttackState = new PlayerHandAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_PUNCH_1_HASH, 5); AirAttackState = new PlayerAirAttackState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_AIR_ATTACK_1_HASH, 2); SlideState = new PlayerSlideState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_SLIDE_HASH); ItemState = new PlayerItemState(this, _stateMachine, _playerData, AnimationConstants.PLAYER_USE_ITEM_HASH); }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- public Player() { movement = new PlayerMoveComponent(this); // Unit properties. centerOffset = new Point2I(0, -5); Health = 4 * 3; MaxHealth = 4 * 3; swimmingSkills = PlayerSwimmingSkills.CantSwim; tunic = PlayerTunics.GreenTunic; moveAnimation = GameData.ANIM_PLAYER_DEFAULT; knockbackSpeed = GameSettings.PLAYER_KNOCKBACK_SPEED; hurtKnockbackDuration = GameSettings.PLAYER_HURT_KNOCKBACK_DURATION; bumpKnockbackDuration = GameSettings.PLAYER_BUMP_KNOCKBACK_DURATION; // Physics. Physics.CollisionBox = new Rectangle2F(-4, -10 + 3, 8, 9); Physics.SoftCollisionBox = new Rectangle2F(-6, -14 + 3, 12, 13); Physics.CollideWithWorld = true; Physics.CollideWithEntities = true; Physics.CollideWithRoomEdge = true; Physics.CheckRadialCollisions = true; Physics.RoomEdgeCollisionBoxType = CollisionBoxType.Soft; Physics.HasGravity = true; Physics.AutoDodges = true; Physics.MovesWithConveyors = true; Physics.MovesWithPlatforms = true; Physics.AllowEdgeClipping = true; Physics.IsCrushable = true; Physics.EdgeClipAmount = 1; Physics.CrushMaxGapSize = 4; Physics.CustomTileCollisionCondition = delegate(Tile tile) { if (movement.IsOnColorBarrier && (tile is TileColorBarrier)) { return(false); } return(true); }; // Graphics. Graphics.DepthLayer = DepthLayer.PlayerAndNPCs; Graphics.DepthLayerInAir = DepthLayer.InAirPlayer; Graphics.DrawOffset = new Point2I(-8, -13); // Init tools. toolShield = new PlayerToolShield(); toolSword = new PlayerToolSword(); toolVisual = new PlayerToolVisual(); // Create the basic player states. stateNormal = new PlayerNormalState(); stateBusy = new PlayerBusyState(); stateSwim = new PlayerSwimState(); stateLadder = new PlayerLadderState(); stateLedgeJump = new PlayerLedgeJumpState(); stateSwingSword = new PlayerSwingSwordState(); stateSwingBigSword = new PlayerSwingBigSwordState(); stateSwingMagicRod = new PlayerSwingMagicRodState(); stateSwingCane = new PlayerSwingCaneState(); stateHoldSword = new PlayerHoldSwordState(); stateSwordStab = new PlayerSwordStabState(); stateSpinSword = new PlayerSpinSwordState(); stateSeedShooter = new PlayerSeedShooterState(); stateSwitchHook = new PlayerSwitchHookState(); stateMagicBoomerang = new PlayerMagicBoomerangState(); stateGrab = new PlayerGrabState(); stateCarry = new PlayerCarryState(); statePullHandle = new PlayerPullHandleState(); stateRespawnDeath = new PlayerRespawnDeathState(); stateMinecart = new PlayerMinecartState(); stateJumpTo = new PlayerJumpToState(); }