/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { world = new World(); player1 = new Player(world); player1Renderer = new PlayerRenderer(GraphicsDevice, player1); player1Renderer.Initialize(); hud = new HudRenderer(GraphicsDevice, world, player1Renderer.camera); hud.Initialize(); #region choose renderer renderer = new ThreadedWorldRenderer(GraphicsDevice, player1Renderer.camera, world); // renderer = new SimpleRenderer(GraphicsDevice, player1Renderer.camera, world,player1); diagnosticWorldRenderer = new DiagnosticWorldRenderer(GraphicsDevice, player1Renderer.camera, world); skyDomeRenderer = new SkyDomeRenderer(GraphicsDevice, player1Renderer.camera, world); renderer.Initialize(); diagnosticWorldRenderer.Initialize(); skyDomeRenderer.Initialize(); throwExceptions = false; #endregion //TODO refactor WorldRenderer needs player position + view frustum base.Initialize(); }
public MainWindow() { _resource = new VanillaResource(); _font = new Font(_resource, "default"); _chunk = new Chunk2D(); _chunk.Fill(0, 0, 0, 256, 0, 0, "bedrock"); _chunk.Fill(0, 1, 0, 256, 60, 0, "stone"); _chunk.Fill(0, 61, 0, 256, 62, 0, "dirt"); _chunk.Fill(0, 63, 0, 256, 63, 0, "grass_block_side"); var rand = new Random(); for (int i = 0; i < 800; i++) { switch (rand.Next(11)) { case 0: _chunk.SetBlock(rand.Next(256), rand.Next(13) + 1, "diamond_ore"); break; case 1: case 2: _chunk.SetBlock(rand.Next(256), rand.Next(30) + 3, "gold_ore"); break; case 3: case 4: case 5: _chunk.SetBlock(rand.Next(256), rand.Next(40) + 10, "iron_ore"); break; case 6: case 7: case 8: case 9: case 10: _chunk.SetBlock(rand.Next(256), rand.Next(45) + 15, "coal_ore"); break; } } _hud = new HudRenderer(this, () => _atlases, _font); _hud.Add(new TextHudObject { Text = "Hello, World!" }); _viewInput = this.CreateKeyAxisInput(negativeXKey: Keys.A, positionXKey: Keys.D, negativeYKey: Keys.S, positionYKey: Keys.W, negativeZKey: Keys.Minus, positionZKey: Keys.Equal).CreateScaledAxisInput(4F).CreateSmoothAxisInput(); _playerMoveInput = this.CreateKeyAxisInput(negativeXKey: Keys.Left, positionXKey: Keys.Right, negativeYKey: Keys.Down, positionYKey: Keys.Up); _player = new Player(); _boxObj = new BoxObject(); //KeyDown += (sender, e) => Console.WriteLine(e.Key); this.AddCompletedRenderer(_hud); }
public FactoryIntroVignette(Session session, HiresSnow snow = null) { this.session = session; areaMusic = session.Audio.Music.Event; session.Audio.Music.Event = null; session.Audio.Apply(forceSixteenthNoteHack: false); Add(hud = new HudRenderer()); RendererList.UpdateLists(); textbox = new Textbox("KaydenFox_FactoryMod_1_Factory_A_Intro"); textCoroutine = new Coroutine(TextSequence()); }
public override void LoadContent(ContentManager Content, GraphicsDevice GraphicsDevice) { GameController = new GameController(); MapRenderer = new MapRenderer(GameController); MapRenderer.LoadContent(Content); HUD = new HudRenderer(MapRenderer, GameController); HUD.LoadContent(Content); }
public CustomTextVignette(Session session, string text, HiresSnow snow = null) { this.session = session; areaMusic = session.Audio.Music.Event; session.Audio.Music.Event = null; session.Audio.Apply(); sfx = Audio.Play(SFX.music_prologue_intro_vignette); if (snow == null) { fade = 1f; snow = new HiresSnow(); } Add(renderer = new HudRenderer()); Add(this.snow = snow); RendererList.UpdateLists(); this.text = FancyText.Parse(Dialog.Get(text), 960, 8, 0f); textCoroutine = new Coroutine(TextSequence()); }
public MainWindow() { // one sensor is currently supported this.kinectSensor = KinectSensor.GetDefault(); // get the coordinate mapper this.coordinateMapper = this.kinectSensor.CoordinateMapper; // open the reader for the body frames this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader(); this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader(); this.audioReader = this.kinectSensor.AudioSource.OpenReader(); // get the depth (display) extents FrameDescription jointFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription; FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); FrameDescription infraredFrameDescription = this.kinectSensor.InfraredFrameSource.FrameDescription; colorRenderer = new ColorFrameRenderer(colorFrameDescription.Width, colorFrameDescription.Height, jointFrameDescription.Width, jointFrameDescription.Height, infraredFrameDescription.Width, infraredFrameDescription.Height); var drawingGroup = new DrawingGroup(); var drawingImage = new DrawingImage(drawingGroup); hudRenderer = new HudRenderer(drawingGroup, drawingImage, colorFrameDescription.Width, colorFrameDescription.Height); AudioSource audioSource = this.kinectSensor.AudioSource; // Allocate 1024 bytes to hold a single audio sub frame. Duration sub frame // is 16 msec, the sample rate is 16khz, which means 256 samples per sub frame. // With 4 bytes per sample, that gives us 1024 bytes. this.audioBuffer = new byte[audioSource.SubFrameLengthInBytes]; this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; this.audioReader.FrameArrived += audioReader_FrameArrived; //on startup hide the audio meter AudioMeterVisibility = Visibility.Hidden; this.infraredFrameReader = this.kinectSensor.InfraredFrameSource.OpenReader(); //Infrared // open the reader for the depth frames this.infraredFrameReader = this.kinectSensor.InfraredFrameSource.OpenReader(); // wire handler for frame arrival this.infraredFrameReader.FrameArrived += this.colorRenderer.Reader_InfraredFrameArrived; // set IsAvailableChanged event notifier this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; // open the sensor this.kinectSensor.Open(); // set the status text TODO: change namespace name in resources this.StatusText = this.kinectSensor.IsAvailable ? Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.RunningStatusText : Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.NoSensorStatusText; // use the window object as the view model in this simple example this.DataContext = this; // initialize the components (controls) of the window this.InitializeComponent(); //register the code which will tell the system what to do when keys are pressed SetupKeyHandlers(); //initialize panTilt = PanTiltController.GetOrCreatePanTiltController(); firingControl = FiringController.GetOrCreateFiringController(); var panTiltErr = panTilt.TryInitialize(); var firingErr = firingControl.TryInitialize(); if (panTiltErr != null) { //crash the app. we can't do anything if it doesn't intialize throw panTiltErr; } if (firingErr != null) { //crash the app. we can't do anything if it doesn't intialize throw firingErr; } string safetyText; if (this.firingControl.VirtualSafetyOn) { safetyText = Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.SafetyDisengagedText; } else { safetyText = Microsoft.Samples.Kinect.BodyBasics.Properties.Resources.SafetyEngagedText; } panTilt.TryInitialize(); //draw the headsup display initially this.hudRenderer.RenderHud(new HudRenderingParameters() { CannonX = this.CannonX, CannonY = this.CannonY, //CannonTheta = this.CannonTheta, StatusText = this.statusText, SystemReady = (this.kinectSensor.IsAvailable && this.kinectSensor.IsOpen && this.panTilt.IsReady), FrameRate = this.FrameRate, TrackingMode = this.trackingMode, FiringSafety = this.firingControl.VirtualSafetyOn, FiringSafetyText = safetyText }); //set voice synth to Hazel this.voiceSynth.SelectVoice("Microsoft Hazel Desktop"); this.voiceSynth.SpeakAsync("Kinect Cannon Fully Initialized"); //debug start frame rate counter FPSTimerStart(); // Try to use the controller }
private void modRenderContent(On.Celeste.HudRenderer.orig_RenderContent orig, HudRenderer self, Scene scene) { orig(self, scene); if (( (ExtendedVariantsModule.Settings.ChangeVariantsRandomly && ExtendedVariantsModule.Settings.DisplayEnabledVariantsToScreen) || (ExtendedVariantsModule.Session != null && ExtendedVariantsModule.Session.ExtendedVariantsDisplayedOnScreenViaTrigger) ) && !((scene as Level)?.Paused ?? false)) { Draw.SpriteBatch.Begin(); infoPanel.Render(); Draw.SpriteBatch.End(); } }
private void HudRenderer_RenderContent(On.Celeste.HudRenderer.orig_RenderContent orig, HudRenderer self, Monocle.Scene scene) { if (!Settings.Enabled) { orig(self, scene); return; } if (effectTime != Settings.EffectTime) { timerHelper.ChangeTimerIntervals(); effectTime = Settings.EffectTime; } Monocle.Draw.SpriteBatch.Begin(); if (Settings.EnableInfoPanel) { infoPanel.Update(); infoPanel.SetFont(Monocle.Draw.DefaultFont, Monocle.Draw.SpriteBatch.GraphicsDevice); infoPanel.Draw(Monocle.Draw.SpriteBatch); } if (Settings.ShowSeekerNames) { foreach (Seeker seeker in spawnHelper.spawnedSeekers) { SeekerName nameObj = seeker.Get <SeekerName>(); if (nameObj.Name != null) { string name = nameObj.Name; DrawTextOverObject(name, seeker.Position); } } } if (Settings.ShowSnowballNames) { foreach (Snowball snowball in spawnHelper.spawnedSnowballs) { SnowballName nameObj = snowball.Get <SnowballName>(); if (nameObj.Name != null) { string name = nameObj.Name; DrawTextOverObject(name, snowball.Position); } } } Monocle.Draw.SpriteBatch.End(); orig(self, scene); }
private static void HudRendererOnRenderContent(On.Celeste.HudRenderer.orig_RenderContent orig, HudRenderer self, Scene scene) { CenterTheCamera(() => orig(self, scene)); }