public Editor(Game game) { this.game = game; grid = game.content.FindName("grid") as Canvas; workspace = game.content.FindName("workspace") as Canvas; scroller = game.content.FindName("scroller") as Canvas; game.MouseLeftButtonDown += new MouseEventHandler(OnMouseLeftButtonDown); game.MouseLeftButtonUp += new MouseEventHandler(OnMouseLeftButtonUp); game.MouseMove += new MouseEventHandler(OnMouseMove); }
public void Init(Canvas root) { Current = this; this.content = root; // register the scriptable endpoints WebApplication.Current.RegisterScriptableObject("page", this); game = new Game(root); stats = new Stats(root); help = new Help(root); level = new Level("__empty__", game.world, game.foreground, game.background); Canvas gamehost = root.FindName("gamehost") as Canvas; gamehost.Children.Add(game); Canvas statshost = root.FindName("statshost") as Canvas; statshost.Children.Add(stats); Canvas helphost = root.FindName("helphost") as Canvas; helphost.Children.Add(help); continueInfo = root.FindName("continue") as Canvas; timer.Attach(root, "game-loop", new Timer.TickDelegate(GameTick), new TimeSpan(TimeSpan.TicksPerSecond/120)); keyboard.Init(root, new Keyboard.KeyEventDelegate(KeyPress)); SwitchLevel(levels[currentLevel]); }