Ejemplo n.º 1
0
        public Gamestate(PlayerUnit playerUnit, Unit unit, Scenery scenery,
                         EventsState events, InputState input, PhysicsState physics, VideoState video, AudioState audio, TimeState time)
        {
            Assert.Ref(playerUnit, unit, scenery, events, input, physics, video, audio, time);

            PlayerUnit = playerUnit;
            Scenery    = scenery;
            Unit       = unit;

            Events  = events;
            Input   = input;
            Physics = physics;
            Video   = video;
            Audio   = audio;
            Time    = time;
        }
Ejemplo n.º 2
0
        public Gamestate Build(Gamestate old)
        {
            EventsState events = Events.Build();

            // we quit immediately on quit request, so don't bother building if we got one
            if (!events.IsQuitRequested)
            {
                PlayerUnit pUnit   = old?.PlayerUnit.Update(old, this) ?? new PlayerUnit(this);
                Unit       unit    = old?.Unit.Update(old, this) ?? new Unit(this);
                Scenery    scenery = old?.Scenery.Update(old, this) ?? new Scenery(this);

                InputState   input   = Input.Build();
                PhysicsState physics = Physics.Build(old?.Time.Delta ?? 0);
                VideoState   video   = Video.Build(old?.Video);
                AudioState   audio   = Audio.Build(old?.Audio);
                TimeState    time    = Time.Build(old?.Time);

                return(new Gamestate(pUnit, unit, scenery, events, input, physics, video, audio, time));
            }

            return(new Gamestate(old.PlayerUnit, old.Unit, old.Scenery, events, old.Input, old.Physics, old.Video, old.Audio, old.Time));
        }
Ejemplo n.º 3
0
        Scenery(Gamestate oldState, GamestateBuilder newState)
        {
            Assert.Ref(oldState, newState);

            Scenery oldScenery = oldState.Scenery;

            sound = oldScenery.sound;

            InputDevice  device = oldState.Input.Devices[oldScenery.inputDevice];
            StaticBody   body   = (StaticBody)(oldState.Physics.PhysicsBodies[oldScenery.staticBody]);
            RectDrawable drw    = (RectDrawable)(oldState.Video.Drawables[oldScenery.rectDrawable]);
            SoundSource  src    = oldState.Audio.SoundSources[oldScenery.soundSource];

            if (device.GetButtonPressed("SoundTest"))
            {
                src = src.PlaySound(sound);
            }

            inputDevice  = newState.Input.AddDevice(device);
            staticBody   = newState.Physics.AddPhysicsObject(body);
            rectDrawable = newState.Video.AddDrawable(drw);
            soundSource  = newState.Audio.AddSoundSource(src);
        }