示例#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;
 }
示例#2
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);
        }
示例#3
0
        internal static void HandleMapProjectile(ref byte[] data)
        {
            int        i      = 0;
            ByteStream buffer = new ByteStream(data);

            i = buffer.ReadInt32();

            MapProjectiles[i].ProjectileNum = buffer.ReadInt32();
            MapProjectiles[i].Owner         = buffer.ReadInt32();
            MapProjectiles[i].OwnerType     = (byte)(buffer.ReadInt32());
            MapProjectiles[i].dir           = (byte)(buffer.ReadInt32());
            MapProjectiles[i].X             = buffer.ReadInt32();
            MapProjectiles[i].Y             = buffer.ReadInt32();
            MapProjectiles[i].Range         = 0;
            MapProjectiles[i].Timer         = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 60000);

            buffer.Dispose();
        }
示例#4
0
 public void TsbScreenShot_Click(object sender, EventArgs e)
 {
     E_Globals.HideCursor      = true;
     E_Globals.ScreenShotTimer = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 1000);
     E_Globals.TakeScreenShot  = true;
 }
示例#5
0
        public void NudFurniture_ValueChanged(object sender, EventArgs e)
        {
            if (E_Globals.Editorindex == 0 || E_Globals.Editorindex > Constants.MAX_ITEMS)
            {
                return;
            }

            Types.Item[E_Globals.Editorindex].Data2 = (int)nudFurniture.Value;

            if (E_Graphics.FurnitureGFXInfo[(int)nudFurniture.Value].IsLoaded == false)
            {
                E_Graphics.LoadTexture((int)nudFurniture.Value, (byte)10);
            }

            //seeying we still use it, lets update timer
            E_Graphics.FurnitureGFXInfo[(int)nudFurniture.Value].TextureTimer = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 100000);

            if (nudFurniture.Value > 0 && nudFurniture.Value <= E_Housing.NumFurniture)
            {
                Types.Item[E_Globals.Editorindex].FurnitureWidth  = System.Convert.ToInt32((double)E_Graphics.FurnitureGFXInfo[(int)nudFurniture.Value].width / 32);
                Types.Item[E_Globals.Editorindex].FurnitureHeight = System.Convert.ToInt32((double)E_Graphics.FurnitureGFXInfo[(int)nudFurniture.Value].height / 32);
                if (Types.Item[E_Globals.Editorindex].FurnitureHeight > 1)
                {
                    Types.Item[E_Globals.Editorindex].FurnitureHeight = Types.Item[E_Globals.Editorindex].FurnitureHeight - 1;
                }
            }
            else
            {
                Types.Item[E_Globals.Editorindex].FurnitureWidth  = 1;
                Types.Item[E_Globals.Editorindex].FurnitureHeight = 1;
            }

            E_Items.EditorItem_DrawFurniture();
        }
示例#6
0
        internal static void EditorItem_DrawFurniture()
        {
            int       Furniturenum = 0;
            Rectangle sRECT        = new Rectangle();
            Rectangle dRECT        = new Rectangle();

            Furniturenum = (int)FrmItem.Default.nudFurniture.Value;

            if (Furniturenum < 1 || Furniturenum > E_Housing.NumFurniture)
            {
                E_Graphics.EditorItem_Furniture.Clear(E_Graphics.ToSFMLColor(FrmItem.Default.picFurniture.BackColor));
                E_Graphics.EditorItem_Furniture.Display();
                return;
            }

            if (E_Graphics.FurnitureGFXInfo[Furniturenum].IsLoaded == false)
            {
                E_Graphics.LoadTexture(Furniturenum, (byte)10);
            }

            //seeying we still use it, lets update timer
            E_Graphics.FurnitureGFXInfo[Furniturenum].TextureTimer = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 100000);

            // rect for source
            sRECT.Y      = 0;
            sRECT.Height = E_Graphics.FurnitureGFXInfo[Furniturenum].height;
            sRECT.X      = 0;
            sRECT.Width  = E_Graphics.FurnitureGFXInfo[Furniturenum].width;

            // same for destination as source
            dRECT = sRECT;

            E_Graphics.EditorItem_Furniture.Clear(E_Graphics.ToSFMLColor(FrmItem.Default.picFurniture.BackColor));

            E_Graphics.RenderSprite(E_Graphics.FurnitureSprite[Furniturenum], E_Graphics.EditorItem_Furniture, dRECT.X, dRECT.Y, sRECT.X, sRECT.Y, sRECT.Width, sRECT.Height);

            if (FrmItem.Default.optSetBlocks.Checked == true)
            {
                for (var X = 0; X <= 3; X++)
                {
                    for (var Y = 0; Y <= 3; Y++)
                    {
                        if (X <= ((double)E_Graphics.FurnitureGFXInfo[Furniturenum].width / 32) - 1)
                        {
                            if (Y <= ((double)E_Graphics.FurnitureGFXInfo[Furniturenum].height / 32) - 1)
                            {
                                if (Types.Item[E_Globals.Editorindex].FurnitureBlocks[(int)X, (int)Y] == 1)
                                {
                                    E_Text.DrawText(System.Convert.ToInt32(X * 32 + 8), System.Convert.ToInt32(Y * 32 + 8), "X", SFML.Graphics.Color.Red, SFML.Graphics.Color.Black, E_Graphics.EditorItem_Furniture);
                                }
                                else
                                {
                                    E_Text.DrawText(System.Convert.ToInt32(X * 32 + 8), System.Convert.ToInt32(Y * 32 + 8), "O", SFML.Graphics.Color.Blue, SFML.Graphics.Color.Black, E_Graphics.EditorItem_Furniture);
                                }
                            }
                        }
                    }
                }
            }
            else if (FrmItem.Default.optSetFringe.Checked == true)
            {
                for (var X = 0; X <= 3; X++)
                {
                    for (var Y = 0; Y <= 3; Y++)
                    {
                        if (X <= ((double)E_Graphics.FurnitureGFXInfo[Furniturenum].width / 32) - 1)
                        {
                            if (Y <= ((double)E_Graphics.FurnitureGFXInfo[Furniturenum].height / 32))
                            {
                                if (Types.Item[E_Globals.Editorindex].FurnitureFringe[(int)X, (int)Y] == 1)
                                {
                                    E_Text.DrawText(System.Convert.ToInt32(X * 32 + 8), System.Convert.ToInt32(Y * 32 + 8), "O", SFML.Graphics.Color.Blue, SFML.Graphics.Color.Black, E_Graphics.EditorItem_Furniture);
                                }
                            }
                        }
                    }
                }
            }
            E_Graphics.EditorItem_Furniture.Display();
        }
示例#7
0
        internal static void DrawFurniture(int index, int Layer)
        {
            int i       = 0;
            int ItemNum = 0;
            int X       = 0;
            int Y       = 0;
            int Width   = 0;
            int Height  = 0;
            int X1      = 0;
            int Y1      = 0;

            ItemNum = Furniture[index].ItemNum;

            if (Types.Item[ItemNum].Type != (int)Enums.ItemType.Furniture)
            {
                return;
            }

            i = Types.Item[ItemNum].Data2;

            if (E_Graphics.FurnitureGFXInfo[i].IsLoaded == false)
            {
                E_Graphics.LoadTexture(i, (byte)10);
            }

            //seeying we still use it, lets update timer
            E_Graphics.SkillIconsGFXInfo[i].TextureTimer = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 100000);

            Width  = Types.Item[ItemNum].FurnitureWidth;
            Height = Types.Item[ItemNum].FurnitureHeight;

            if (Width > 4)
            {
                Width = 4;
            }
            if (Height > 4)
            {
                Height = 4;
            }
            if (i <= 0 || i > NumFurniture)
            {
                return;
            }

            // make sure it's not out of map
            if (Furniture[index].X > E_Types.Map.MaxX)
            {
                return;
            }
            if (Furniture[index].Y > E_Types.Map.MaxY)
            {
                return;
            }

            for (X1 = 0; X1 <= Width - 1; X1++)
            {
                for (Y1 = 0; Y1 <= Height; Y1++)
                {
                    if (Types.Item[Furniture[index].ItemNum].FurnitureFringe[X1, Y1] == Layer)
                    {
                        // Set base x + y, then the offset due to size
                        X = (Furniture[index].X * 32) + (X1 * 32);
                        Y = (Furniture[index].Y * 32 - (Height * 32)) + (Y1 * 32);
                        X = E_Graphics.ConvertMapX(X);
                        Y = E_Graphics.ConvertMapY(Y);

                        Sprite tmpSprite = new Sprite(E_Graphics.FurnitureGFX[i])
                        {
                            TextureRect = new IntRect(0 + (X1 * 32), 0 + (Y1 * 32), 32, 32),
                            Position    = new Vector2f(X, Y)
                        };
                        E_Graphics.GameWindow.Draw(tmpSprite);
                    }
                }
            }
        }
示例#8
0
        internal static void DrawFog()
        {
            int fogNum = 0;

            //If InMapEditor Then Exit Sub

            fogNum = E_Globals.CurrentFog;
            if (fogNum <= 0 || fogNum > E_Graphics.NumFogs)
            {
                return;
            }

            int horz = 0;
            int vert = 0;

            for (var x = E_Globals.TileView.Left; x <= E_Globals.TileView.Right + 1; x++)
            {
                for (var y = E_Globals.TileView.Top; y <= E_Globals.TileView.Bottom + 1; y++)
                {
                    if (E_Graphics.IsValidMapPoint(System.Convert.ToInt32(x), System.Convert.ToInt32(y)))
                    {
                        horz = System.Convert.ToInt32(-x);
                        vert = System.Convert.ToInt32(-y);
                    }
                }
            }

            if (E_Graphics.FogGFXInfo[fogNum].IsLoaded == false)
            {
                E_Graphics.LoadTexture(fogNum, (byte)8);
            }

            //seeying we still use it, lets update timer
            E_Graphics.FogGFXInfo[fogNum].TextureTimer = System.Convert.ToInt32(System.Convert.ToInt32(ClientDataBase.GetTickCount()) + 100000);

            Sprite tmpSprite = default(Sprite);

            tmpSprite = new Sprite(E_Graphics.FogGFX[fogNum])
            {
                Color       = new SFML.Graphics.Color(255, 255, 255, (byte)E_Globals.CurrentFogOpacity),
                TextureRect = new IntRect(0, 0, (int)E_Graphics.GameWindow.Size.X + 200, (int)E_Graphics.GameWindow.Size.Y + 200),
                Position    = new Vector2f((float)((horz * 2.5) + 50), (float)((vert * 3.5) + 50)),
                Scale       = (new Vector2f((float)((E_Graphics.GameWindow.Size.X + 200) / E_Graphics.FogGFXInfo[fogNum].width), (float)((E_Graphics.GameWindow.Size.Y + 200) / E_Graphics.FogGFXInfo[fogNum].height)))
            };

            E_Graphics.GameWindow.Draw(tmpSprite);             //
        }