Пример #1
0
 //Default settings
 public void MakeDefault()
 {
     SelectKey   = new GamepadInput(this, "SelectKey", Buttons.A, PlayerIndex.One);
     AnalogStick = new GamePadAnalog(this, "AnalogStick", Sticks.Right, PlayerIndex.One);
     UpKey       = new GamepadInput(this, "UpKey", Buttons.DPadUp, PlayerIndex.One);
     DownKey     = new GamepadInput(this, "DownKey", Buttons.DPadDown, PlayerIndex.One);
     LeftKey     = new GamepadInput(this, "LeftKey", Buttons.DPadLeft, PlayerIndex.One);
     RightKey    = new GamepadInput(this, "RightKey", Buttons.DPadRight, PlayerIndex.One);
     Input       = MovementInput.Analog;
 }
        public PlayerShip(Node parent, string name)
            : base(parent, name)
        {
            Body.X = EntityGame.Viewport.Width / 2f;
            Body.Y = EntityGame.Viewport.Height / 2f;

            Physics.Drag = 0.97f;
            Physics.AngularDrag = 0.9f;

            Render = new ImageRender(this, "Render");
            Render.SetTexture(GetRoot<State>().GetService<AssetCollector>().GetAsset<Texture2D>("ship"));
            Render.Layer = .01f;
            Render.Scale = new Vector2(.128f);
            Render.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);

            Body.Bounds = Render.Bounds;
            Body.Origin = new Vector2(Render.Texture.Width / 2f, Render.Texture.Height / 2f);

            Gun = new SimpleGun(this, "SimpleGun");
            Gun.LinkDependency(SimpleGun.DEPENDENCY_BODY, Body);
            Gun.LinkDependency(SimpleGun.DEPENDENCY_PHYSICS, Physics);
            Shape = new Circle(this, "Circle", Body.Width * .8f);
            Shape.Offset = new Vector2(Body.Width / 2, Body.Height / 2);
            Shape.Debug = true;
            Shape.LinkDependency(Circle.DEPENDENCY_BODY, Body);

            Collision.Group.AddMask(0);
            Collision.Pair.AddMask(2);
            Collision.CollideEvent += OnCollide;
            Collision.Immovable = true;
            Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
            Shape.LinkDependency(Circle.DEPENDENCY_COLLISION, Collision);

            //Control
            UpButton = new DoubleInput(this, "UpButton", Keys.W, Buttons.DPadUp, PlayerIndex.One);
            DownButton = new DoubleInput(this, "DownButton", Keys.S, Buttons.DPadDown, PlayerIndex.One);
            LeftButton = new DoubleInput(this, "LeftButton", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            RightButton = new DoubleInput(this, "RightButton", Keys.D, Buttons.DPadRight, PlayerIndex.One);
            FireButton = new DoubleInput(this, "FireButton", Keys.Space, Buttons.A, PlayerIndex.One);
            ThrustTrigger = new GamePadTrigger(this, "ThrustTrigger", Triggers.Right, PlayerIndex.One);
            //GravityTrigger = new GamePadTrigger(this, "GravityTrigger", Triggers.Left, PlayerIndex.One);

            LookAnalog = new GamePadAnalog(this, "LookAnalog", Sticks.Left, PlayerIndex.One);
        }
Пример #3
0
 //Default settings
 public void MakeDefault()
 {
     SelectKey = new GamepadInput(this, "SelectKey", Buttons.A, PlayerIndex.One);
     AnalogStick = new GamePadAnalog(this, "AnalogStick", Sticks.Right, PlayerIndex.One);
     UpKey = new GamepadInput(this, "UpKey", Buttons.DPadUp, PlayerIndex.One);
     DownKey = new GamepadInput(this, "DownKey", Buttons.DPadDown, PlayerIndex.One);
     LeftKey = new GamepadInput(this, "LeftKey", Buttons.DPadLeft, PlayerIndex.One);
     RightKey = new GamepadInput(this, "RightKey", Buttons.DPadRight, PlayerIndex.One);
     Input = MovementInput.Analog;
 }
            public ParticleTestManager(State stateref)
                : base(stateref, "ParticleTestManager")
            {
                _controlHandler = stateref.GetService<ControlHandler>();
                _body = new Body(this, "EmitterBody");
                Spawner = new TestSpawner(this, "Spawner");

                _moveCursor = new GamePadAnalog(this, "MoveCursor", Sticks.Left, PlayerIndex.One);
                _emitButton = new GamepadInput(this, "EmitButton", Buttons.B, PlayerIndex.One);
            }