public PlayerComponent( IGamepad gamepad, PlayerRigidbody playerRigidbody, PlayerSoundsComponent playerSounds, PlayerStateMachine playerStateMachine) { this.gamepad_ = gamepad; this.playerRigidbody_ = playerRigidbody; this.rigidbody_ = playerRigidbody.Rigidbody; this.playerSounds_ = playerSounds; this.stateMachine_ = playerStateMachine; this.levelGridRenderer_ = new LevelGridRenderer { LevelGrid = LevelConstants.LEVEL_GRID, }; this.motor_ = new PlayerMotor { StateMachine = this.stateMachine_, PlayerRigidbody = this.playerRigidbody_, }; this.collider_ = new PlayerCollider { StateMachine = this.stateMachine_, PlayerRigidbody = this.playerRigidbody_, }; this.boxPlayerRenderer_ = new BoxPlayerRenderer { PlayerRigidbody = this.playerRigidbody_, }; }
public WhipComponent( IGamepad gamepad, PlayerRigidbody playerRigidbody, PlayerSoundsComponent playerSounds, PlayerStateMachine stateMachine) { this.gamepad_ = gamepad; this.playerRigidbody_ = playerRigidbody; this.playerSounds_ = playerSounds; this.stateMachine_ = stateMachine; var whipPointCount = 10; this.whipPoints_ = new MutableVector2 <float> [whipPointCount]; for (var i = 0; i < whipPointCount; ++i) { this.whipPoints_[i] = new MutableVector2 <float>(); } }
private void InstantiatePlayer_(IApp app, IAppNode viewRoot) { var instantiator = app.Instantiator; var gamepad = app.Input.Controller; var rigidbody = new Rigidbody { Position = (LevelConstants.SIZE * 10, LevelConstants.SIZE * 13), YAcceleration = PlayerConstants.GRAVITY, MaxYSpeed = float.MaxValue, }; var playerRigidbody = new PlayerRigidbody { Rigidbody = rigidbody, }; var playerStateMachine = new PlayerStateMachine { State = PlayerState.STANDING, }; var playerSounds = new PlayerSoundsComponent(app.Audio, rigidbody, playerStateMachine); var player = new PlayerComponent(gamepad, playerRigidbody, playerSounds, playerStateMachine); var itemSwitcher = new ItemSwitcherComponent(gamepad, playerRigidbody, playerSounds, playerStateMachine); var vectorRenderer = new PlayerVectorRendererComponent(playerRigidbody, playerStateMachine); instantiator.NewChild(viewRoot, player, playerSounds, itemSwitcher, vectorRenderer); }
public ItemSwitcherComponent( IGamepad gamepad, PlayerRigidbody playerRigidbody, PlayerSoundsComponent playerSounds, PlayerStateMachine stateMachine) { this.gamepad_ = gamepad; this.itemComponents_ = new IItemComponent[] { new ShieldComponent(gamepad, playerRigidbody, stateMachine), new WhipComponent(gamepad, playerRigidbody, playerSounds, stateMachine), new SwordComponent(gamepad, playerRigidbody, stateMachine), }; this.currentItemIndex_ = new CircularRangedInt(0, 0, this.itemComponents_.Length); }