using System; using System.Collections.Generic; using System.Linq; using System.Text; using VBXSE; using System.IO; namespace DIGIEVO { public static class Main { public enum Menus { Combat, Main, Profile, Moves, Traits, EvolveKey, NameCreature, ListOfEnemies, CustomBattle, AutoBattle } public static Creature creature = null; public static Menus currentMenu = Menus.Main; public static float textSpeed = 50f; //In letters per second public static Client client; public static bool breakWait = false; public static int accessStatus = -1; public static void StartGame() { bool connected = false; try { Main.Connect(); connected = true; } catch { Menu.ShowNotification("Could not connect to the DIGIEVO system.\n\nDIGIEVO requires an active internet connection.\nIf you are connected to the internet,\nthe DIGIEVO system may be down.", Menu.NotificationReason.FatalError); } if (connected) { Main.LoadCreature(); if (accessStatus == 1) { if (creature.name == "UNKNOWN") Menu.OpenMenu(Menus.NameCreature); else Menu.OpenMenu(Menus.Main); } //Combat.StartCombat(); } } public static void LoadCreature() { //Ask creature from server if (File.Exists("accessfile")) { StreamReader sr = new StreamReader("accessfile"); string[] split = sr.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); sr.Close(); byte[] pass = new byte[split.Length]; for (int i = 0; i < split.Length; i++) { pass[i] = Convert.ToByte(split[i]); } accessStatus = -1; client.AskCreature(pass); while (accessStatus == -1) { System.Threading.Thread.Sleep(50); } if (accessStatus == 1) Main.creature.pass = pass; else Menu.ShowNotification("Your CREATURE was not recognized by the\nDIGIEVO system.\n\nYour ACCESS FILE may be corrupt. In order to request\na new CREATURE, please delete your ACCESS FILE.", Menu.NotificationReason.FatalError); } else { creature = new Creature(); //Ask the server for a pass and code accessStatus = -1; Main.RegisterPassAndCode(); while (accessStatus == -1) { System.Threading.Thread.Sleep(50); } } } public static void Connect() { client = new Client(); } public static void RegisterPassAndCode() { client.AskCode(); client.AskPass(); } public static void SendCreature() { client.SendSerialization(creature.Serialize()); } public static void AskCreature(string code) { client.AskCreature(code); } public static void EvolutionNotice(string code) { client.EvolutionNotice(code); } public static void RequestRandomBattle(int powerRating) { client.RequestRandomBattle(powerRating); } public static bool ElementalResistance(Element user, Element target) { switch (user) { case Element.FIRE: if (target == Element.GRASS) return true; break; case Element.WATER: if (target == Element.FIRE) return true; break; case Element.GRASS: if (target == Element.WATER) return true; break; } return false; } public static bool ElementalAdvantage(Element user, Element target) { switch (user) { case Element.FIRE: if (target == Element.GRASS) return true; break; case Element.WATER: if (target == Element.FIRE) return true; break; case Element.GRASS: if (target == Element.WATER) return true; break; case Element.LIGHT: if (target == Element.DARK) return true; break; case Element.DARK: if (target == Element.LIGHT) return true; break; } return false; } public static void QuitGame() { Environment.Exit(0); } } }