Ejemplo n.º 1
0
        protected BaseTimeline()
        {
            _updater = CreateUpdater(Update);
            _holdUpdater = CreateUpdater(UpdateHold);

            _currentUpdater = _updater;
            Add(_updater);
        }
Ejemplo n.º 2
0
            public GroundConstraint(Body body, Fixture bodyFixture, SurfaceMovementControl surfaceMovementControl)
            {
                _body = body;
                _surfaceMovementControl = surfaceMovementControl;
                Add(bodyFixture.CreateContactHandler(HexPhysicTypes.Ground, EnterGroundContact, ExitGroundContact));

                // sensor
                var sensor = _body.AttachCircle(10f, 0);
                sensor.IsSensor = true;
                sensor.SetCollisionType(HexPhysicTypes.GroundSensor);
                _closeHexList = Add(new FixtureContactList(sensor));

                // ground constraint
                _groundConstraintUpdate = new UpdateComponent(UpdateGroundConstraint, UpdateTime.Sim);
                Add(_groundConstraintUpdate);

                // state
                Add(new StateRecorder("groundConstraint",
                    state => { },
                    state =>
                    {
                        _isOnGround = false;
                        _currentHex = null;
                    }));
            }
Ejemplo n.º 3
0
        void ILoad.Load()
        {
            // body
            Body = Add(new Body(Physic.World, Vector2.Zero)
            {
                BodyType = BodyType.Dynamic,
                GravityScale = 1,
                LinearDamping = 0
            });
            Body.CreateFixture(new CircleShape(1, 1));

            // update
            Add(new UpdateComponent(Update, UpdateTime.Sim));

            // particle emitter
            Func<Particle> flameParticle = () => new FlameParticle
            {
                Radius = 1f,
                Force = GetForce(),
                BaseColor = Color.LightBlue
            };

            Func<Particle> cloudParticle = () => new CloudParticle()
            {
                Radius = GetForce() / 5
            };

            _emitter = Add(new ParticleEmitter(DataPack.Textures.Snow, cloudParticle)
            {
                EmittingCount = new IntRange(5, 10),
                Frequency = .01f,
                //BlendState = BlendState.NonPremultiplied
            });

            _emitter.StartEmitting();
            _emitter.IsVisible = false;

            // rendering
            Add(new DrawComponent(Draw));

            // stabilization
            _stabilizationUpdate = new UpdateComponent(UpdateStabilisation, UpdateTime.Sim);

            // ui
            Add(new GameUI
            {
                // mouse + keyboard
                new MouseButtonBinding(OpenTK.Input.MouseButton.Left, StartThruster, StopThruster),
                new KeyBinding(Keys.LeftShift, () => Boost = true, () => Boost = false),

                // gamepad
                new GamePadStickBinding(Side.Left, RotateWithGamePad),
                new GamePadButtonBinding(Buttons.LeftTrigger, StartThruster, StopThruster),
                new GamePadButtonBinding(Buttons.A, () => Boost = true, () => Boost = false),

            });
            _thrusterUpdate = new UpdateComponent(RotateTowardMouse, UpdateTime.Sim);
            StartStabilization();

            // default settings
            EnableStabilizer = true;
        }
Ejemplo n.º 4
0
 public void HoldFor(float duration)
 {
     IsPaused = true;
     _holdDuration = duration;
     _currentUpdater = _holdUpdater;
     Replace(_updater, _holdUpdater);
 }
Ejemplo n.º 5
0
        private void UpdateHold()
        {
            var dt = GetDt() * Scale;

            _holdDuration -= dt;
            if (_holdDuration >= 0)
                return;

            IsPaused = false;
            _currentUpdater = _updater;
            Replace(_holdUpdater, _updater);
        }
Ejemplo n.º 6
0
        public void Resume()
        {
            if (!IsPaused)
                return;

            IsPaused = false;

            _currentUpdater = _updater;
            Remove(_holdUpdater);
            Add(_updater);
        }