public static UnitCache Of(string fx, int min, int max, int w, int h, System.Action<UnitCache> done) { var u = new UnitCache(); Console.WriteLine("LoadCache " + new { fx, min, max }); u.LoadCache(fx, min, max); u.Width = w; u.Height = h; u.WhenCacheLoaded(done); return u; }
private void Setup(System.Action done) { t = new Timer(); var text = new IHTMLInput(HTMLInputTypeEnum.text); text.className = "TalkToOthers"; text.AttachToDocument(); text.onkeypress += delegate(IEvent x) { if (x.IsReturn) { this.CurrentSession.IServer_TalkToOthers(text.value); this.DisplayNotification(text.value, Color.Blue); text.value = ""; } }; text.style.zIndex = 1000; //Native.Document.body.DisableContextMenu(); //CreateRotatingTank(96 + 48 * 7, 96 + 48 * 1, t, "tree_1", 383, 392); //CreateRotatingTank(96 + 48 * 1, 96 + 48 * 2, t, "tank_1", 308, 339); int u = 7; System.Action idone = null; System.Action<System.Action> adone = delegate(System.Action x) { if (x != null) idone += x; u--; if (u == 0) { if (idone != null) { idone(); idone = null; } //done(); //t.StartInterval(100); } }; done(); t.StartInterval(100); UnitCache.Of("harvester_1", 71, 71 + 31, 48, 48, delegate(UnitCache c) { adone(delegate { for (int i = 1; i < 10; i++) { Unit.Of(c, 32 * 7, 24 * i, t, 5); } }); } ); building_1 = UnitCache.Of("building_1", 365, 365 + 17, 72, 72, delegate(UnitCache c) { adone(delegate { for (int i = 1; i < 5; i++) { var xu = Unit.Of(c, 32 * 14, 72 * i, t, 2); System.Action To3 = null; System.Action To4 = null; System.Action To1r = null; System.Action To1 = null; To3 = delegate { xu.Cache = building_3; xu.WhenDone = To4; }; To1r = delegate { xu.ReverseAnimation = true; xu.Cache = building_1; xu.WhenDone = To1; }; To1 = delegate { xu.ReverseAnimation = false; xu.Cache = building_1; xu.WhenDone = To3; }; To4 = delegate { xu.Cache = building_4; xu.WhenDone = To1r; }; xu.WhenDone = To3; } }); } ); UnitCache.Of("building_2", 1252, 1252 + 15, 48, 48, delegate(UnitCache c) { adone(delegate { for (int i = 1; i < 10; i++) { Unit.Of(c, 32 * 17, 48 * i, t, 6); } }); } ); building_4 = UnitCache.Of("building_4", 405, 405 + 17, 72, 72, uc => adone(null)); building_3 = UnitCache.Of("building_3", 393, 393 + 11, 72, 72, uc => adone(null)); UnitCache.Of("tank_2", 308, 308 + 31, 24, 24, delegate(UnitCache c) { adone(delegate { for (int i = 1; i < 10; i++) { Unit.Of(c, 32 * 3, 24 * i, t, 3); } }); } ); explosion_1 = UnitCache.Of("explosion_1", 990, 1015, 78, 121, delegate(UnitCache c) { adone(delegate { Native.Document.body.onclick += delegate(IEvent ev) { int cx = ev.CursorX; int cy = ev.CursorY; UserCreateExplosion(cx, cy); }; }); } ); new IHTMLImage("fx/building/power.png").InvokeOnComplete( delegate(IHTMLImage img) { for (int i = 0; i < 3; i++) { SpawnAnimation(img, 50 + 48 * i, 200, 48, 72, 0, 23, t); } } ); new IHTMLImage("fx/building/cy.png").InvokeOnComplete( delegate(IHTMLImage img) { for (int i = 0; i < 3; i++) { SpawnAnimation(img, 50 + 72 * i, 300, 72, 72, 0, 34, t); } } ); new IHTMLImage("fx/building/barrack.png").InvokeOnComplete( delegate(IHTMLImage img) { for (int i = 0; i < 3; i++) { SpawnAnimation(img, 280 + 48 * i, 300, 48, 72, 0, 46, t); } } ); new IHTMLImage("fx/vehicle/veh_cy.png").InvokeOnComplete( delegate(IHTMLImage img) { for (int i = 0; i < 3; i++) { SpawnAnimation(img, 50 + 48 * i, 400, 48, 48, 0, 31, t); } } ); //.InvokeOnComplete( // delegate(IHTMLImage img) // { // this.Explosion = img; // for (int i = 0; i < 3; i++) // { // SpawnAnimation(img, 250 + 48 * i, 200, 78, 121, 0, 25, t); // } // } //); }
public static Unit Of(UnitCache c, int x, int y, Timer t, int skip) { var u = new Unit(); u.Cache = c; u.Moveto(x, y); int s = 0; t.Tick += delegate { if (s % skip == 0) { s = 0; u.Tick(t); } s++; }; return u; }