Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DrawScene() // draws the scene, starting with the lowest priority objects and then going up to the highest priority ones, then draws any text objects and the debug display if it is on.
- {
- Priority currentPriority = Priority.Background1;
- Game.Children.Clear();
- while (currentPriority <= Priority.High)
- {
- if (currentPriority != Priority.Invisible)
- {
- if (Gamestate == GameState.Game || Gamestate == GameState.EditMode)
- {
- // v2 for 0.06+
- for (int i = 0; i < currentlevel.OBJLAYOUT.Count; i++)
- {
- if (currentlevel.OBJLAYOUT[i].OBJX - Scrollbar.HorizontalOffset > 0 - currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelWidth & currentlevel.OBJLAYOUT[i].OBJX - Scrollbar.HorizontalOffset < this.Width + currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelWidth & currentlevel.OBJLAYOUT[i].OBJY - Scrollbar.VerticalOffset > 0 - currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelHeight & currentlevel.OBJLAYOUT[i].OBJY - Scrollbar.VerticalOffset < this.Height + currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelHeight | IsSentientBeing(currentlevel.OBJLAYOUT[i]))
- { // optimization (bld 1037-41)
- if (currentlevel.OBJLAYOUT[i].OBJPRIORITY == currentPriority)
- {
- if (currentlevel.OBJLAYOUT[i].OBJPLAYER == true & Gamestate == GameState.Game)
- {
- Scrollbar.ScrollToHorizontalOffset(currentlevel.OBJLAYOUT[i].OBJX - this.Width / 6); // level scrolling
- Scrollbar.ScrollToVerticalOffset(currentlevel.OBJLAYOUT[i].OBJY - this.Width / 6); // vertical level scrolling
- }
- Rectangle rectangle = new Rectangle();
- rectangle.Height = currentlevel.OBJLAYOUT[i].OBJIMAGE.Height;
- rectangle.Width = currentlevel.OBJLAYOUT[i].OBJIMAGE.Width;
- rectangle.StrokeThickness = 0;
- HandleAnimations(currentlevel.OBJLAYOUT[i]);
- if (Gamestate == GameState.Game & currentlevel.OBJLAYOUT[i].OBJGRAV != false)
- {
- HandlePhys(currentlevel.OBJLAYOUT[i]);
- }
- HandleAI(currentlevel.OBJLAYOUT[i]);
- Canvas.SetLeft(rectangle, currentlevel.OBJLAYOUT[i].OBJX);
- Canvas.SetTop(rectangle, currentlevel.OBJLAYOUT[i].OBJY);
- rectangle.Fill = new ImageBrush(currentlevel.OBJLAYOUT[i].OBJIMAGE);
- Game.Children.Add(rectangle);
- if (currentlevel.OBJLAYOUT[i].OBJHELDWEAPON != null) // weapon drawing
- {
- Rectangle WeaponRectangle = new Rectangle();
- WeaponRectangle.Height = currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGE.Height;
- WeaponRectangle.Width = currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGE.Width;
- WeaponRectangle.StrokeThickness = 0;
- currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONPOSITIONX = currentlevel.OBJLAYOUT[i].OBJX + currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelWidth / 1.33;
- currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONPOSITIONY = currentlevel.OBJLAYOUT[i].OBJY + currentlevel.OBJLAYOUT[i].OBJIMAGE.PixelHeight / 2;
- Canvas.SetLeft(WeaponRectangle, currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONPOSITIONX);
- Canvas.SetTop(WeaponRectangle, currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONPOSITIONY);
- WeaponRectangle.Fill = new ImageBrush(currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGE); // the image.
- Game.Children.Add(WeaponRectangle);
- if (currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONAMMOLIST.Count > 0) // ammo
- {
- for (int j = 0; j < currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONAMMOLIST.Count; j++ )
- {
- Ammo ammo = currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONAMMOLIST[j];
- if (ammo.X - Scrollbar.HorizontalOffset > 0 - currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.PixelWidth & ammo.X - Scrollbar.HorizontalOffset < this.Width + currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.PixelWidth & ammo.Y - Scrollbar.VerticalOffset > 0 - currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.PixelHeight & ammo.Y - Scrollbar.VerticalOffset < this.Width + currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.PixelHeight)
- {
- Rectangle AmmoRectangle = new Rectangle();
- AmmoRectangle.Width = currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.Width;
- AmmoRectangle.Height = currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONIMAGEAMMO.Height;
- AmmoRectangle.StrokeThickness = 0;
- Canvas.SetLeft(AmmoRectangle, ammo.X);
- Canvas.SetTop(AmmoRectangle, ammo.Y);
- AmmoRectangle.Fill = new ImageBrush(ammo.AMMOIMAGE);
- Game.Children.Add(AmmoRectangle);
- }
- else
- {
- currentlevel.OBJLAYOUT[i].OBJHELDWEAPON.WEAPONAMMOLIST.RemoveAt(j);
- }
- }
- }
- }
- }
- }
- }
- if (currentPriority == Priority.High)
- {
- if (TextList.Count > 0)
- {
- foreach (AGTextBlock Textblock in TextList)
- {
- if (Textblock.IsDisplayed == true)
- {
- Canvas.SetLeft(Textblock, Textblock.GamePos.X);
- Canvas.SetTop(Textblock, Textblock.GamePos.Y);
- // DEBUG CODE //
- if (Textblock.TextName == "GlobalTimerDebug" & Settings.DebugMode)
- {
- int minutes = GlobalTimer / 60 / 60;
- int seconds = (GlobalTimer / 60) % 60;
- double hundredths = RoundNearest(((GlobalTimer * 60) % 59) * 1.4, 1);
- if (seconds > 9)
- {
- SetText(Textblock, $"--DEBUG--\nFrame No: {GlobalTimer.ToString()}\nLevel Time: {minutes.ToString()}:{seconds.ToString()}.{hundredths.ToString()}\nCurrent Window Size: {this.Width},{this.Height}\n\n-Settings-\nDebug Mode: {Settings.DebugMode}\nDemo Mode: {Settings.DemoMode}\nDemo Mode Max Level: {Settings.DemoModeMaxLevel}\nGame Name: {Settings.GameName}\nResolution: {Settings.Resolution}\nTitle Screen Path: {Settings.TitleScreenPath} \nWindow Size: {Settings.WindowType}");
- }
- else
- {
- SetText(Textblock, $"--DEBUG--\nFrame No: {GlobalTimer.ToString()}\nLevel Time: {minutes.ToString()}:0{seconds.ToString()}.{hundredths.ToString()}\nCurrent Window Size: {this.Width},{this.Height}\n\n-Settings-\nDebug Mode: {Settings.DebugMode}\nDemo Mode: {Settings.DemoMode}\nDemo Mode Max Level: {Settings.DemoModeMaxLevel}\nGame Name: {Settings.GameName}\nResolution: {Settings.Resolution}\nTitle Screen Path: {Settings.TitleScreenPath} \nWindow Size: {Settings.WindowType}");
- }
- Canvas.SetLeft(Textblock, Scrollbar.HorizontalOffset);
- Canvas.SetTop(Textblock, Scrollbar.VerticalOffset);
- }
- // END DEBUG CODE //
- Game.Children.Add(Textblock);
- }
- }
- }
- }
- currentPriority++; // increment the object priority we are currently drawing. this allows us to put objects in front of each other etc (currently 5 layers)
- }
- }
- }
Add Comment
Please, Sign In to add comment