public GuiManager(SpriteFont font) { controls = new List <Control>(); Font = font; Controller = new InputController(Game.Instance.InputManager); InputSetup = new InputControlSetup(); Controller.ChangeSetup(InputSetup); BindKeys(); }
/// <summary> /// Vaihtaa controllerin asetelmaa /// </summary> /// <param name="newSetup">Uusi setuppi</param> public void ChangeSetup(InputControlSetup newSetup) { if (CurrentSetup != null) { input.Mapper.RemoveSetup(CurrentSetup); } CurrentSetup = newSetup; input.Mapper.AddSetup(CurrentSetup); }
public FarmPlayer(KhvGame game, FarmWorld world, PlayerIndex index = PlayerIndex.One) : base(game, index) { defaultInputSetup = new InputControlSetup(); this.world = world; Position = new Vector2(500, 200); Size = new Size(30, 47); Collider = new BoxCollider(world, this, new BasicObjectCollisionQuerier(), new BasicTileCollisionQuerier()); Collider.OnCollisionEnter += Collider_OnCollisionEnter; Collider.OnCollision += Collider_OnCollision; Collider.OnCollisionLeave += Collider_OnCollisionLeave; }
public Player(World world) { Size = new Size(100, 100); Velocity = new Vector2(Speed, 0); // Inputin alustus. defaultSetup = new InputControlSetup(); controller = new InputController(Game.Instance.InputManager); controller.ChangeSetup(defaultSetup); Game.Instance.MapManager.OnMapChanged += new MapManagerEventHandler(MapManager_OnMapChanged); animator = Game.Instance.Content.Load <CharacterModel>("playeri\\plaery").CreateAnimator("player"); animator.ChangeAnimation("attack"); animator.Scale = 0.35f; // Colliderin alustus. body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(100), ConvertUnits.ToSimUnits(100), 1.0f); body.Friction = 0f; body.BodyType = BodyType.Dynamic; body.Restitution = 0f; body.LinearDamping = 5f; body.UserData = this; Position = Vector2.Zero; Size = new Size(100, 100); HealthComponent health = new HealthComponent(100); // Komponentti alustus. components.Add(targetingComponent = new TargetingComponent <Monster>(this)); components.Add(directionalArrow = new DirectionalArrow()); components.Add(weaponComponent = new WeaponComponent(targetingComponent, new BaseballBat())); components.Add(health); Game.Instance.MapManager.OnMapChanged += new MapManagerEventHandler(MapManager_OnMapChanged); // weaponSound = Game.Instance.Content.Load<SoundEffect>("music\\baseballbat"); Speed = 15f; }
protected override void FinishSetup(InputControlSetup setup) { button1 = setup.GetControl <ButtonControl>(this, "button1"); axis1 = setup.GetControl <AxisControl>(this, "axis1"); base.FinishSetup(setup); }