|
- using Client.Controls;
- using Client.Envir.Translations;
- using Client.Models;
- using Client.Scenes;
- using Client.Scenes.Views;
- using Client.UserModels;
- using Library;
- using Library.MirDB;
- using Library.Network;
- using Library.SystemModels;
- using MirDB;
- using SlimDX;
- using SlimDX.Direct3D9;
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Client.Envir
- {
- public static class CEnvir
- {
- public static TargetForm Target;
- public static Random Random = new Random();
- private static DateTime _FPSTime;
- private static int FPSCounter;
- private static int FPSCount;
- public static int DPSCounter;
- private static int DPSCount;
- public static bool Shift;
- public static bool Alt;
- public static bool Ctrl;
- public static DateTime Now;
- public static Point MouseLocation;
- public static CConnection Connection;
- public static bool WrongVersion;
- public static Dictionary<LibraryFile, MirLibrary> LibraryList = new Dictionary<LibraryFile, MirLibrary>();
- public static ClientUserItem[] Storage;
- public static ClientUserItem[] MainStorage;
- public static List<ClientBlockInfo> BlockList = new List<ClientBlockInfo>();
- public static DBCollection<KeyBindInfo> KeyBinds;
- public static DBCollection<WindowSetting> WindowSettings;
- public static DBCollection<CastleInfo> CastleInfoList;
- public static Session Session;
- public static ConcurrentQueue<string> ChatLog = new ConcurrentQueue<string>();
- public static bool Loaded;
- public static string BuyAddress;
- public static string C;
- public static bool TestServer;
- public static int ErrorCount;
- private static string LastError;
- public static StringMessages Language { get; set; }
- static CEnvir()
- {
- new Thread(new ThreadStart(CEnvir.SaveChatLoop))
- {
- IsBackground = true
- }.Start();
- try
- {
- CEnvir.A();
- }
- catch
- {
- }
- }
- public static void LoadLanguage()
- {
- string upper = Config.Language.ToUpper();
- if (!(upper == "ENGLISH"))
- {
- if (!(upper == "CHINESE"))
- return;
- CEnvir.Language = (StringMessages) ((Dictionary<System.Type, object>) ConfigReader.ConfigObjects)[typeof (ChineseMessages)];
- }
- else
- CEnvir.Language = (StringMessages) ((Dictionary<System.Type, object>) ConfigReader.ConfigObjects)[typeof (EnglishMessages)];
- }
- private static void A()
- {
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games", "Zircon");
- if (!Directory.Exists(path))
- Directory.CreateDirectory(path);
- if (File.Exists(path + "\\CheckSum.bin"))
- {
- using (BinaryReader binaryReader = new BinaryReader((Stream) File.OpenRead(path + "\\CheckSum.bin")))
- CEnvir.C = binaryReader.ReadString();
- }
- else
- {
- using (BinaryWriter binaryWriter = new BinaryWriter((Stream) File.Create(path + "\\CheckSum.bin")))
- binaryWriter.Write(CEnvir.C = Functions.RandomString(CEnvir.Random, 20));
- }
- }
- public static void SaveChatLoop()
- {
- List<string> stringList = new List<string>();
- while (true)
- {
- while (CEnvir.ChatLog.IsEmpty)
- Thread.Sleep(1000);
- while (!CEnvir.ChatLog.IsEmpty)
- {
- string result;
- if (CEnvir.ChatLog.TryDequeue(out result))
- stringList.Add(result);
- }
- try
- {
- File.AppendAllLines(".\\Chat Logs.txt", (IEnumerable<string>) stringList);
- stringList.Clear();
- }
- catch
- {
- }
- }
- }
- public static void GameLoop()
- {
- CEnvir.UpdateGame();
- CEnvir.RenderGame();
- if (!Config.LimitFPS)
- return;
- Thread.Sleep(1);
- }
- private static void UpdateGame()
- {
- CEnvir.Now = Time.get_Now();
- DXControl.ActiveScene?.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, CEnvir.MouseLocation.X, CEnvir.MouseLocation.Y, 0));
- if (Time.get_Now() >= CEnvir._FPSTime)
- {
- CEnvir._FPSTime = Time.get_Now().AddSeconds(1.0);
- CEnvir.FPSCount = CEnvir.FPSCounter;
- CEnvir.FPSCounter = 0;
- CEnvir.DPSCount = CEnvir.DPSCounter;
- CEnvir.DPSCounter = 0;
- DXManager.MemoryClear();
- }
- CEnvir.Connection?.Process();
- DXControl.ActiveScene?.Process();
- string str1 = string.Format("FPS: {0}", (object) CEnvir.FPSCount);
- if (DXControl.MouseControl != null)
- str1 = str1 + ", Mouse Control: " + DXControl.MouseControl.GetType().Name;
- if (DXControl.FocusControl != null)
- str1 = str1 + ", Focus Control: " + DXControl.FocusControl.GetType().Name;
- if (GameScene.Game != null)
- {
- if (DXControl.MouseControl is MapControl)
- str1 += string.Format(", Co Ords: {0}", (object) GameScene.Game.MapControl.MapLocation);
- str1 += string.Format(", Objects: {0}", (object) GameScene.Game.MapControl.Objects.Count);
- if (MapObject.MouseObject != null)
- str1 = str1 + ", Mouse Object: " + MapObject.MouseObject.Name;
- }
- string str2 = str1 + string.Format(", DPS: {0}", (object) CEnvir.DPSCount);
- DXControl.DebugLabel.Text = str2;
- if (CEnvir.Connection != null)
- {
- string str3 = !((Decimal) CEnvir.Connection.get_TotalBytesSent() > 1048576M) ? (!((Decimal) CEnvir.Connection.get_TotalBytesSent() > 1024M) ? string.Format("{0:#,##0}B", (object) CEnvir.Connection.get_TotalBytesSent()) : string.Format("{0:#,##0}KB", (object) ((Decimal) CEnvir.Connection.get_TotalBytesSent() / 1024M))) : string.Format("{0:#,##0.0}MB", (object) ((Decimal) CEnvir.Connection.get_TotalBytesSent() / 1048576M));
- string str4 = !((Decimal) CEnvir.Connection.get_TotalBytesReceived() > 1048576M) ? (!((Decimal) CEnvir.Connection.get_TotalBytesReceived() > 1024M) ? string.Format("{0:#,##0}B", (object) CEnvir.Connection.get_TotalBytesReceived()) : string.Format("{0:#,##0}KB", (object) ((Decimal) CEnvir.Connection.get_TotalBytesReceived() / 1024M))) : string.Format("{0:#,##0.0}MB", (object) ((Decimal) CEnvir.Connection.get_TotalBytesReceived() / 1048576M));
- DXControl.PingLabel.Text = string.Format("Ping: {0}, Sent: {1}, Received: {2}", (object) CEnvir.Connection.Ping, (object) str3, (object) str4);
- DXControl.PingLabel.Location = new Point(DXControl.DebugLabel.DisplayArea.Right + 5, DXControl.DebugLabel.DisplayArea.Y);
- }
- else
- DXControl.PingLabel.Text = string.Empty;
- if (DXControl.MouseControl != null && DXControl.ActiveScene != null)
- {
- DXControl.HintLabel.Text = DXControl.MouseControl.Hint;
- Point point = new Point(CEnvir.MouseLocation.X, CEnvir.MouseLocation.Y + 17);
- if (point.X + DXControl.HintLabel.Size.Width > DXControl.ActiveScene.Size.Width)
- point.X = DXControl.ActiveScene.Size.Width - DXControl.HintLabel.Size.Width - 1;
- if (point.Y + DXControl.HintLabel.Size.Height > DXControl.ActiveScene.Size.Height)
- point.Y = DXControl.ActiveScene.Size.Height - DXControl.HintLabel.Size.Height - 1;
- if (point.X < 0)
- point.X = 0;
- if (point.Y < 0)
- point.Y = 0;
- DXControl.HintLabel.Location = point;
- }
- else
- DXControl.HintLabel.Text = (string) null;
- }
- private static void RenderGame()
- {
- try
- {
- Size clientSize = ((Form) CEnvir.Target).ClientSize;
- int num;
- if (clientSize.Width != 0)
- {
- clientSize = ((Form) CEnvir.Target).ClientSize;
- num = clientSize.Height == 0 ? 1 : 0;
- }
- else
- num = 1;
- if (num != 0)
- Thread.Sleep(1);
- else if (DXManager.DeviceLost)
- {
- DXManager.AttemptReset();
- Thread.Sleep(1);
- }
- else
- {
- DXManager.Device.Clear((ClearFlags) 1, Color4.op_Implicit(Color.Black), 1f, 0);
- DXManager.Device.BeginScene();
- DXManager.Sprite.Begin((SpriteFlags) 16);
- DXControl.ActiveScene?.Draw();
- DXManager.Sprite.End();
- DXManager.Device.EndScene();
- DXManager.Device.Present();
- ++CEnvir.FPSCounter;
- }
- }
- catch (Direct3D9Exception ex)
- {
- DXManager.DeviceLost = true;
- }
- catch (Exception ex)
- {
- CEnvir.SaveError(ex.ToString());
- DXManager.AttemptRecovery();
- }
- }
- public static void ReturnToLogin()
- {
- if (DXControl.ActiveScene is LoginScene)
- return;
- DXControl.ActiveScene.Dispose();
- DXSoundManager.StopAllSounds();
- DXControl.ActiveScene = (DXScene) new LoginScene(Config.IntroSceneSize);
- CEnvir.BlockList = new List<ClientBlockInfo>();
- }
复制代码
前往下载传奇3G2005源代码C# 逆向Zircon传奇3G源码 提取码回复可见
|
上一篇:Zircon传奇3源代码仿韩版黑龙逆向代码C#传奇3源码下一篇:传奇3G源码大全c#逆向3G2005源代码第二版Ziron
|