Example #1
0
 public void TsbSave_Click(object sender, EventArgs e)
 {
     E_Sound.StopMusic();
     E_Sound.StopPreview();
     E_Globals.HideCursor      = true;
     E_Globals.ScreenShotTimer = (ClientDataBase.GetTickCount() + 500);
     E_Globals.MakeCache       = true;
 }
Example #2
0
 public void BtnPreview_Click(object sender, EventArgs e)
 {
     if (ReferenceEquals(E_Sound.PreviewPlayer, null))
     {
         if (lstMusic.SelectedIndex >= 0)
         {
             E_Sound.StopMusic();
             E_Sound.PlayPreview(lstMusic.Items[lstMusic.SelectedIndex].ToString());
         }
     }
     else
     {
         E_Sound.StopPreview();
         E_Sound.PlayMusic(E_Types.Map.Music);
     }
 }
Example #3
0
        public static void GameLoop()
        {
            Point    dest      = new Point(frmMapEditor.Default.PointToScreen(frmMapEditor.Default.picScreen.Location).X, frmMapEditor.Default.PointToScreen(frmMapEditor.Default.picScreen.Location).Y);
            Graphics g         = frmMapEditor.Default.picScreen.CreateGraphics();
            int      starttime = 0;
            int      Tick      = 0;
            int      fogtmr    = 0;
            int      FrameTime;
            int      tmr500      = 0;
            int      tmpfps      = 0;
            int      rendercount = 0;

            starttime = ClientDataBase.GetTickCount();

            do
            {
                if (E_Globals.GameDestroyed == true)
                {
                    ProjectData.EndApp();
                }

                UpdateUI();

                if (E_Globals.GameStarted == true)
                {
                    Tick = ClientDataBase.GetTickCount();

                    // update animation editor
                    if (E_Globals.Editor == E_Globals.EDITOR_ANIMATION)
                    {
                        E_Graphics.EditorAnim_DrawAnim();
                    }

                    if (E_Globals.Editor == E_Projectiles.EDITOR_PROJECTILE)
                    {
                        E_Graphics.Draw_ProjectilePreview();
                    }

                    FrameTime = Tick;
                    if (E_Globals.InMapEditor && !E_Globals.GettingMap)
                    {
                        //Calculate FPS
                        if (starttime < Tick)
                        {
                            E_Globals.FPS = tmpfps;

                            frmMapEditor.Default.tsCurFps.Text = "Current FPS: " + E_Globals.FPS;
                            tmpfps    = 0;
                            starttime = (ClientDataBase.GetTickCount() + 1000);
                        }
                        tmpfps++;

                        lock (E_Types.MapLock)
                        {
                            // fog scrolling
                            if (fogtmr < Tick)
                            {
                                if (E_Globals.CurrentFogSpeed > 0)
                                {
                                    //move
                                    E_Globals.fogOffsetX--;
                                    E_Globals.fogOffsetY--;
                                    FileSystem.Reset();
                                    if (E_Globals.fogOffsetX < -256)
                                    {
                                        E_Globals.fogOffsetX = 0;
                                    }
                                    if (E_Globals.fogOffsetY < -256)
                                    {
                                        E_Globals.fogOffsetY = 0;
                                    }
                                    fogtmr = Tick + 255 - E_Globals.CurrentFogSpeed;
                                }
                            }

                            if (tmr500 < Tick)
                            {
                                // animate waterfalls
                                switch (E_AutoTiles.waterfallFrame)
                                {
                                case 0:
                                    E_AutoTiles.waterfallFrame = 1;
                                    break;

                                case 1:
                                    E_AutoTiles.waterfallFrame = 2;
                                    break;

                                case 2:
                                    E_AutoTiles.waterfallFrame = 0;
                                    break;
                                }
                                // animate autotiles
                                switch (E_AutoTiles.autoTileFrame)
                                {
                                case 0:
                                    E_AutoTiles.autoTileFrame = 1;
                                    break;

                                case 1:
                                    E_AutoTiles.autoTileFrame = 2;
                                    break;

                                case 2:
                                    E_AutoTiles.autoTileFrame = 0;
                                    break;
                                }

                                tmr500 = Tick + 500;
                            }

                            E_Weather.ProcessWeather();

                            if (E_Sound.FadeInSwitch == true)
                            {
                                E_Sound.FadeIn();
                            }

                            if (E_Sound.FadeOutSwitch == true)
                            {
                                E_Sound.FadeOut();
                            }

                            if (rendercount < Tick)
                            {
                                //Auctual Game Loop Stuff :/
                                E_Graphics.Render_Graphics();
                                rendercount = Tick + 32;
                            }

                            //Do we need this?
                            //Application.DoEvents();

                            E_Graphics.EditorMap_DrawTileset();

                            if (E_Globals.TakeScreenShot)
                            {
                                if (E_Globals.ScreenShotTimer < Tick)
                                {
                                    SFML.Graphics.Image screenshot = E_Graphics.GameWindow.Capture();

                                    if (!System.IO.Directory.Exists(Application.StartupPath + "\\Data\\Screenshots"))
                                    {
                                        System.IO.Directory.CreateDirectory(Application.StartupPath + "\\Data\\Screenshots");
                                    }
                                    screenshot.SaveToFile(Application.StartupPath + "\\Data\\Screenshots\\Map" + System.Convert.ToString(E_Types.Map.mapNum) + ".png");

                                    E_Globals.HideCursor     = false;
                                    E_Globals.TakeScreenShot = false;
                                }
                            }

                            if (E_Globals.MakeCache)
                            {
                                if (E_Globals.ScreenShotTimer < Tick)
                                {
                                    SFML.Graphics.Image screenshot = E_Graphics.GameWindow.Capture();

                                    if (!System.IO.Directory.Exists(Application.StartupPath + "\\Data\\Cache"))
                                    {
                                        System.IO.Directory.CreateDirectory(Application.StartupPath + "\\Data\\Cache");
                                    }
                                    screenshot.SaveToFile(Application.StartupPath + "\\Data\\Cache\\Map" + System.Convert.ToString(E_Types.Map.mapNum) + ".png");

                                    E_Globals.HideCursor = false;
                                    E_Globals.MakeCache  = false;
                                    E_Editors.MapEditorSend();
                                }
                            }
                        }
                    }
                }

                // This should be the only one we need?
                Application.DoEvents();
                //Do we need to pause the thread? without it we gain like 200+ fps
                //Thread.Sleep(1);
                // Lets Yield Instead
                Thread.Yield();
            } while (true);
        }
Example #4
0
 static void defaultInstance_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
 {
     E_Sound.StopMusic();
     E_Sound.StopPreview();
     defaultInstance = null;
 }
Example #5
0
 public void TsbDiscard_Click(object sender, EventArgs e)
 {
     E_Sound.StopMusic();
     E_Sound.StopPreview();
     E_Editors.MapEditorCancel();
 }
Example #6
0
 public void FrmEditor_MapEditor_Closed(object sender, EventArgs e)
 {
     E_Sound.StopMusic();
     E_Sound.StopPreview();
     E_Editors.MapEditorCancel();
 }
Example #7
0
        public static void ProcessWeather()
        {
            int i = 0;
            int x;

            if (E_Globals.CurrentWeather > 0)
            {
                if (E_Globals.CurrentWeather == (int)Enums.WeatherType.Rain || E_Globals.CurrentWeather == (int)Enums.WeatherType.Storm)
                {
                    PlayWeatherSound("Rain.ogg", true);
                }
                x = ClientDataBase.Rand(1, 101 - E_Globals.CurrentWeatherIntensity);
                if (x == 1)
                {
                    //Add a new particle
                    for (i = 1; i <= MAX_WEATHER_PARTICLES; i++)
                    {
                        if (WeatherParticle[i].InUse == 0)
                        {
                            if (ClientDataBase.Rand(1, 3) == 1)
                            {
                                WeatherParticle[i].InUse    = 1;
                                WeatherParticle[i].type     = E_Globals.CurrentWeather;
                                WeatherParticle[i].Velocity = ClientDataBase.Rand(8, 14);
                                WeatherParticle[i].X        = (E_Globals.TileView.Left * 32) - 32;
                                WeatherParticle[i].Y        = (E_Globals.TileView.Top * 32) + ClientDataBase.Rand(-32, (int)E_Graphics.GameWindow.Size.Y);
                            }
                            else
                            {
                                WeatherParticle[i].InUse    = 1;
                                WeatherParticle[i].type     = E_Globals.CurrentWeather;
                                WeatherParticle[i].Velocity = ClientDataBase.Rand(10, 15);
                                WeatherParticle[i].X        = (E_Globals.TileView.Left * 32) + ClientDataBase.Rand(-32, (int)E_Graphics.GameWindow.Size.X);
                                WeatherParticle[i].Y        = (E_Globals.TileView.Top * 32) - 32;
                            }
                            //Exit For
                        }
                    }
                }
            }
            else
            {
                StopWeatherSound();
            }
            if (E_Globals.CurrentWeather == (int)Enums.WeatherType.Storm)
            {
                x = ClientDataBase.Rand(1, 400 - E_Globals.CurrentWeatherIntensity);
                if (x == 1)
                {
                    //Draw Thunder
                    E_Globals.DrawThunder = ClientDataBase.Rand(15, 22);
                    E_Sound.PlayExtraSound("Thunder.ogg");
                }
            }
            for (i = 1; i <= MAX_WEATHER_PARTICLES; i++)
            {
                if (WeatherParticle[i].InUse == 1)
                {
                    if (WeatherParticle[i].X > E_Globals.TileView.Right * 32 || WeatherParticle[i].Y > E_Globals.TileView.Bottom * 32)
                    {
                        WeatherParticle[i].InUse = 0;
                    }
                    else
                    {
                        WeatherParticle[i].X = WeatherParticle[i].X + WeatherParticle[i].Velocity;
                        WeatherParticle[i].Y = WeatherParticle[i].Y + WeatherParticle[i].Velocity;
                    }
                }
            }
        }