private static void SwitchState(State s) { _state.Dispose(); _state = s; s.Init(); }
private static void Init() { _random = new Random(); InitializeLua(); Application.Init(); if (!GLib.Thread.Supported) GLib.Thread.Init(); Gdk.Threads.Init(); Gdk.Threads.Enter(); _window = new Gtk.Window(Globals.WINDOW_NAME); _window.SetDefaultSize(Globals.WIDTH, Globals.HEIGHT); _window.AppPaintable = true; _window.DoubleBuffered = false; _window.DeleteEvent += OnWinDelete; _window.KeyPressEvent += OnKeyPress; _window.KeyReleaseEvent += OnKeyRelease; //_window.ConfigureEvent += OnWindowConfigure; DrawingArea da = new DrawingArea(); da.ExposeEvent += OnExposed; Gdk.Color col = new Gdk.Color(0, 0, 0); _window.ModifyBg(StateType.Normal, col); da.ModifyBg(StateType.Normal, col); GLib.Timeout.Add(33, new GLib.TimeoutHandler(Graphics.TimedDraw)); _window.Add(da); _window.ShowAll(); Gdk.Threads.Leave(); Graphics.Init(); // depends on _window being initialized Item.Init(); Enemy.Init(); // depends on Globals ctor Weapon.Init(); // depends on Globals ctor Armor.Init(); // depends on Globals ctor Accessory.Init(); // depends on Globals ctor Materia.Init(); // depends on Globals ctor Character.Init(); // depends on [Weapons|Armor|Materia].Init() Globals.Init(); // depends on Character.Init() MenuScreen.Init(); // depends on Globals.Init() Inventory.Init(); // depends on a whole lot of things Spell.Init(); // depends on Globals ctor Materiatory.Init(); // depends on Materia.Init() int time = Int32.Parse(Globals.SaveGame.SelectSingleNode("//time").InnerText); _clock = new Clock(time); // depends on Globals ctor // Go to Main Menu _state = MainMenu; // Go to new Battle //GoToBattleState(); // Go to Post-Battle //List<IItem> i = new List<IItem>(); //i.Add(Item.ItemTable["powersource"]); //i.Add(Item.ItemTable["powersource"]); //i.Add(Item.ItemTable["potion"]); //PostBattle = new PostBattleState(234, 12, 1200, i); //_state = PostBattle; _state.Init(); if (Globals.Party[0] == null && Globals.Party[1] == null && Globals.Party[2] == null) throw new GamedataException("No character in party!"); // Level-up demo //using (StreamWriter w = new StreamWriter(@"c:\scripts\test.txt")) //{ // while (Character.Cloud.Level < 98) // { // Character.Cloud.GainExperience(Character.Cloud.ToNextLevel + 10); // w.WriteLine(Character.Cloud.ToString()); // } // w.Flush(); //} }
private static void Init() { _random = new Random(); InitializeLua(); Application.Init(); if (!GLib.Thread.Supported) { GLib.Thread.Init(); } Gdk.Threads.Init(); Gdk.Threads.Enter(); _window = new Gtk.Window(Globals.WINDOW_NAME); _window.SetDefaultSize(Globals.WIDTH, Globals.HEIGHT); _window.AppPaintable = true; _window.DoubleBuffered = false; _window.DeleteEvent += OnWinDelete; _window.KeyPressEvent += OnKeyPress; _window.KeyReleaseEvent += OnKeyRelease; //_window.ConfigureEvent += OnWindowConfigure; DrawingArea da = new DrawingArea(); da.ExposeEvent += OnExposed; Gdk.Color col = new Gdk.Color(0, 0, 0); _window.ModifyBg(StateType.Normal, col); da.ModifyBg(StateType.Normal, col); GLib.Timeout.Add(33, new GLib.TimeoutHandler(Graphics.TimedDraw)); _window.Add(da); _window.ShowAll(); Gdk.Threads.Leave(); Graphics.Init(); // depends on _window being initialized Item.Init(); Enemy.Init(); // depends on Globals ctor Weapon.Init(); // depends on Globals ctor Armor.Init(); // depends on Globals ctor Accessory.Init(); // depends on Globals ctor Materia.Init(); // depends on Globals ctor Character.Init(); // depends on [Weapons|Armor|Materia].Init() Globals.Init(); // depends on Character.Init() MenuScreen.Init(); // depends on Globals.Init() Inventory.Init(); // depends on a whole lot of things Spell.Init(); // depends on Globals ctor Materiatory.Init(); // depends on Materia.Init() int time = Int32.Parse(Globals.SaveGame.SelectSingleNode("//time").InnerText); _clock = new Clock(time); // depends on Globals ctor // Go to Main Menu _state = MainMenu; // Go to new Battle //GoToBattleState(); // Go to Post-Battle //List<IItem> i = new List<IItem>(); //i.Add(Item.ItemTable["powersource"]); //i.Add(Item.ItemTable["powersource"]); //i.Add(Item.ItemTable["potion"]); //PostBattle = new PostBattleState(234, 12, 1200, i); //_state = PostBattle; _state.Init(); if (Globals.Party[0] == null && Globals.Party[1] == null && Globals.Party[2] == null) { throw new GamedataException("No character in party!"); } // Level-up demo //using (StreamWriter w = new StreamWriter(@"c:\scripts\test.txt")) //{ // while (Character.Cloud.Level < 98) // { // Character.Cloud.GainExperience(Character.Cloud.ToNextLevel + 10); // w.WriteLine(Character.Cloud.ToString()); // } // w.Flush(); //} }