Exemple #1
0
        public override void BuildUI(UIManager manager)
        {
            UIArea manageData;
            manager.AddArea(manageData = new UIArea(Screen.Width - 400, 100, 250, 300) {Closable = true});
            manageData.Visible = true;
            manageData.AddControl(new TextArea(30, 25, "Manage Defense") {Color = "blue"});

            myClickState = null;
            myClickState = new Button<bool>(false, 20, 50, 100, 25, new Func<string>(() => { return myClickState.Data ? "This" : "That"; })) {
                                                                                                                                                     Click = (p) => { myClickState.Data = !myClickState.Data; }
                                                                                                                                             };

            manageData.AddControl(myClickState);
            manageData.AddControl(new Button(20, 80, 100, 25, "Send Wave") {
                                                                                   Click = (p) => {
                                                                                               //idk do something on button click
                                                                                           }
                                                                           });
        }
        public LevelManagerArea(UIManager.UIManager uiManager)
        {

            LevelManager = uiManager.UIManagerAreas.LevelManagerArea = new UIArea(Window.OuterWidth - 440, 100, 390, 390) { Closable = true };
            LevelManager.Visible = true;

            uiManager.AddArea(LevelManager);
            LevelManager.AddControl(new TextArea(30, 25, "Level Manager") { Color = "blue" });

            LevelManager.AddControl(new Button(50, 70, 120, 28, "Live Objects") { Click = (p) => { new LiveObjectsArea(uiManager); } });
            LevelManager.AddControl(new Button(50, 110, 120, 28, "Debug Animations")
            {
                Click = (p) =>
                {

                    SonicManager.Instance.TileChunkDebugDrawOptions.OutlineChunk = !SonicManager.Instance.TileChunkDebugDrawOptions.OutlineChunk;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowPaletteAnimationData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowPaletteAnimationData;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowBaseData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowBaseData;
                    SonicManager.Instance.TileChunkDebugDrawOptions.ShowTileAnimationData = !SonicManager.Instance.TileChunkDebugDrawOptions.ShowTileAnimationData;

                }
            });
        }
Exemple #3
0
        public override void BuildUI(UIManager manager)
        {
            UIArea manageData;
            manager.AddArea(manageData = new UIArea(Screen.Width - 400, 100, 250, 300) {Closable = true});
            manageData.Visible = true;
            manageData.AddControl(new TextArea(30, 25, "Manage Defense") {Color = "blue"});

            manageData.AddControl(new TextArea(5, 50, "Mode: "));

            myClickState = null;
            myClickState = new Button<bool>(true, 20, 50, 100, 25, new Func<string>(() => { return myClickState.Data ? "Edit" : "Play"; })) {
                                                                                                                                                    Click = (p) => {
                                                                                                                                                                myClickState.Data = !myClickState.Data;

                                                                                                                                                                if (myClickState.Data) gameManager.GameMode = GameMode.Play;
                                                                                                                                                                else gameManager.GameMode = GameMode.TileEdit;
                                                                                                                                                            }
                                                                                                                                            };

            manageData.AddControl(myClickState);
            manageData.AddControl(new Button(20, 80, 100, 25, "Send Wave") {Click = (p) => { }});
        }
        public ObjectFrameworkArea(UIManager.UIManager manager)
        {
            var size = 40 * 4;

            objectFrameworkArea = new UIArea<ObjectFrameworkData>(new ObjectFrameworkData() {ObjectFramework = new LevelObject("Foo")}, 540, 75, 850, 690) {Closable = true};
            objectFrameworkArea.Visible = false;
            manager.AddArea(objectFrameworkArea);
            manager.UIManagerAreas.ObjectFrameworkArea = this;

            objectFrameworkArea.AddControl(new TextArea(30, 25, "Object Framework") {Color = "blue"});

            objectFrameworkArea.AddControl(new TextArea(16, 60, "Assets") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38, 140, 25, "Add Asset") {
                                                                                             Color = "rgb(50,150,50)",
                                                                                             Click = (p) => {
                                                                                                         objectFrameworkArea.Data.ObjectFramework.Assets.Add(
                                                                                                                 new LevelObjectAsset("Asset " +
                                                                                                                                      ( objectFrameworkArea.Data.ObjectFramework.Assets.Count +
                                                                                                                                        1 )));
                                                                                                         Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                     }
                                                                                     });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Assets = new ScrollBox(30, 60 + 10, 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 1 ), "Pieces") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 1 ), 140, 25, "Add Piece") {
                                                                                                            Color = "rgb(50,150,50)",
                                                                                                            Click = (p) => {
                                                                                                                        objectFrameworkArea.Data.ObjectFramework.Pieces.Add(
                                                                                                                                new LevelObjectPiece("Piece " +
                                                                                                                                                     ( objectFrameworkArea.Data.ObjectFramework.
                                                                                                                                                                           Pieces.Count +
                                                                                                                                                       1 )));
                                                                                                                        Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                    }
                                                                                                    });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Pieces =
                    new ScrollBox(30, 60 + 10 + ( size * 1 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 2 ), "Piece Layouts") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 2 ), 140, 25, "Add Piece Layout") {
                                                                                                                   Color = "rgb(50,150,50)",
                                                                                                                   Click = (p) => {
                                                                                                                               objectFrameworkArea.Data.ObjectFramework.PieceLayouts.Add(
                                                                                                                                       new LevelObjectPieceLayout("Piece Layout " +
                                                                                                                                                                  ( objectFrameworkArea.Data.
                                                                                                                                                                                        ObjectFramework
                                                                                                                                                                                       .
                                                                                                                                                                                        PieceLayouts
                                                                                                                                                                                       .Count +
                                                                                                                                                                    1 )));
                                                                                                                               Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                           }
                                                                                                           });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.PieceLayouts =
                    new ScrollBox(30, 60 + 10 + ( size * 2 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(16, 60 + ( size * 3 ), "Projectiles") {Color = "black"});

            objectFrameworkArea.AddControl(new Button(160, 38 + ( size * 3 ), 140, 25, "Add Projectile") {
                                                                                                                 Color = "rgb(50,150,50)",
                                                                                                                 Click = (p) => {
                                                                                                                             objectFrameworkArea.Data.ObjectFramework.Projectiles.Add(
                                                                                                                                     new LevelObjectProjectile(
                                                                                                                                             "Piece Projectile " +
                                                                                                                                             ( objectFrameworkArea.Data.ObjectFramework.Projectiles.
                                                                                                                                                                   Count + 1 )));
                                                                                                                             Populate(objectFrameworkArea.Data.ObjectFramework);
                                                                                                                         }
                                                                                                         });

            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Projectiles =
                    new ScrollBox(30, 60 + 10 + ( size * 3 ), 25, 4, 250) {BackColor = "rgb(50, 60, 127)",});

            objectFrameworkArea.AddControl(new TextArea(320, 80 - 20, "Key: ") {Font = UIManager.UIManager.SmallTextFont, Color = "black"});
            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Key =
                    new TextBox(370, 60 - 20, 150, 25, "") {Color = "rgb(50,150,50)", Click = (p) => { objectFrameworkArea.Data.ObjectFramework.Key = objectFrameworkArea.Data.Key.Text; }});

            objectFrameworkArea.AddControl(new TextArea(320 + 205, 80 - 24, "Description: ") {Font = UIManager.UIManager.SmallTextFont, Color = "black"});
            objectFrameworkArea.AddControl(
                    objectFrameworkArea.Data.Description =
                    new TextBox(370 + 240, 60 - 20, 220, 25, "") {Color = "rgb(50,150,50)", Click = (p) => { objectFrameworkArea.Data.ObjectFramework.Description = objectFrameworkArea.Data.Description.Text; }});

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b1 = new Button(320, 95 - 20, 250, 25, "onInit") {
                                                                                                                             Color = "rgb(50,150,50)",
                                                                                                                             Click = (p) => {
                                                                                                                                         objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                         if (objectFrameworkArea.Data.b1.Toggled) {
                                                                                                                                             addCodeWindow(objectFrameworkArea.Data.ObjectFramework.InitScript,
                                                                                                                                                           () => { objectFrameworkArea.Data.ObjectFramework.InitScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                         } else
                                                                                                                                             ClearMainArea();
                                                                                                                                     }
                                                                                                                     });
            objectFrameworkArea.Data.b1.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b2 = new Button(580, 95 - 20, 250, 25, "onTick") {
                                                                                                                             Color = "rgb(50,150,50)",
                                                                                                                             Click = (p) => {
                                                                                                                                         objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                         objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                         if (objectFrameworkArea.Data.b2.Toggled) {
                                                                                                                                             addCodeWindow(objectFrameworkArea.Data.ObjectFramework.TickScript,
                                                                                                                                                           () => { objectFrameworkArea.Data.ObjectFramework.TickScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                         } else
                                                                                                                                             ClearMainArea();
                                                                                                                                     }
                                                                                                                     });
            objectFrameworkArea.Data.b2.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b3 = new Button(320, 130 - 20, 250, 25, "onCollide") {
                                                                                                                                 Color = "rgb(50,150,50)",
                                                                                                                                 Click = (p) => {
                                                                                                                                             objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                             objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                             objectFrameworkArea.Data.b4.Toggled = false;
                                                                                                                                             if (objectFrameworkArea.Data.b3.Toggled) {
                                                                                                                                                 addCodeWindow(objectFrameworkArea.Data.ObjectFramework.CollideScript,
                                                                                                                                                               () => { objectFrameworkArea.Data.ObjectFramework.CollideScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                             } else
                                                                                                                                                 ClearMainArea();
                                                                                                                                         }
                                                                                                                         });
            objectFrameworkArea.Data.b3.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.b4 = new Button(580, 130 - 20, 250, 25, "onHurtSonic") {
                                                                                                                                   Color = "rgb(50,150,50)",
                                                                                                                                   Click = (p) => {
                                                                                                                                               objectFrameworkArea.Data.b1.Toggled = false;
                                                                                                                                               objectFrameworkArea.Data.b2.Toggled = false;
                                                                                                                                               objectFrameworkArea.Data.b3.Toggled = false;
                                                                                                                                               if (objectFrameworkArea.Data.b4.Toggled) {
                                                                                                                                                   addCodeWindow(objectFrameworkArea.Data.ObjectFramework.HurtScript,
                                                                                                                                                                 () => { objectFrameworkArea.Data.ObjectFramework.HurtScript = objectFrameworkArea.Data.Editor.GetValue(); });
                                                                                                                                               } else
                                                                                                                                                   ClearMainArea();
                                                                                                                                           }
                                                                                                                           });
            objectFrameworkArea.Data.b4.Toggle = true;

            objectFrameworkArea.AddControl(objectFrameworkArea.Data.MainPanel = new Panel<MainPanelData>(new MainPanelData(), 320, 150, 510, 510));
            //    setTimeout("        var sc = document.getElementById("picFieldUploader");sc.style.visibility = "hidden";sc.style.position="absolute";", 300);
        }
        public LevelSelectorArea(UIManager.UIManager manager)
        {
            var levelInformation = new UIArea(70, 70, 460, 420);
            levelInformation.Visible = true;
            manager.AddArea(levelInformation);

            levelInformation.AddControl(new TextArea(30, 25, "Level Selector") { Font = UIManager.UIManager.TextFont, Color = "blue" });
            levelInformation.AddControl(new TextArea(30, 52, ((Func<string>)(() => UIManager.UIManager.CurLevelName))) { Font = UIManager.UIManager.TextFont, Color = "black" });

            levelInformation.AddControl(new Button(320, 70, 100, 22, "Save Level") { Font = UIManager.UIManager.ButtonFont, Color = "rgb(50,150,50)" });

            levelInformation.AddControl(new Button(320, 105, 135, 22, "Load Empty Level")
            {
                Font = UIManager.UIManager.ButtonFont,
                Color = "rgb(50,150,50)",
                Click = (p) =>
                {
                    /*  levelManagerArea.visible = true;
loadingText.visible = true;
var index = 0;
var tim = function () {
var max = 188;
if (index == max) {
setTimeout(function () {
alert(_H.stringify(sonicManager.SonicLevel));
sonicManager.uiManager.loadGame(_H.stringify(sonicManager.SonicLevel), sonicManager.mainCanvas);
loadingText.visible = false;
}, 500);
return;
}
setTimeout(tim, 100);

_H.loadSprite("assets/Chunks/Tile" + index++ + ".png", function (image) {
loadingText.text = "Loading " + index + "/" + max;
sonicManager.importChunkFromImage(image);
if (index == max) {
sonicManager.inds = { done: true };
}
});

};
setTimeout(tim, 100);*/
                }
            });

            var ctls =
                    levelInformation.AddControl(new ScrollBox(30, 70, 25, 11, 250) { BackColor = "rgb(50, 60, 127)", });
            var loadLevel = (Action<string>)(name =>
            {
                UIManager.UIManager.UpdateTitle("Downloading " + name);
                SonicEngine.Instance.client.Emit("LoadLevel.Request", new DataObject<string>(name));
                ;
            });
            bool neverGot=true;
            SonicEngine.Instance.client.On<DataObject<string>>("LoadLevel.Response", LoadLevel);
            Window.SetTimeout(() => {
                if (neverGot) {
                    UIManager.UIManager.CurLevelName = "Connection Failed, static level loaded";
                    LoadLevel(new DataObject<string>(Window.Instance.Me().STATICLEVEL));
                }

                  

                              }, 3000);

            SonicEngine.Instance.client.On<DataObject<string[]>>("GetLevels.Response",
                                                                 data => {
                                                                     neverGot = false;
                                                                     bool load = true;
                                                                     foreach (var level in data.Data.OrderBy(a => a))
                                                                     {
                                                                         if (load)
                                                                         {
                                                                             //#if RELEASE
                                                                             //loadLevel(level);
                                                                             //#endif
                                                                             load = false;
                                                                         }
                                                                         string area = level;
                                                                         ctls.AddControl(new Button(0, 0, 0, 0, level)
                                                                         {
                                                                             Color = "rgb(50,190,90)",
                                                                             Click = (p) => { loadLevel(area); }
                                                                         });
                                                                     }
                                                                 });
            SonicEngine.Instance.client.Emit("GetLevels.Request", null);

            UIManager.UIManager.CurLevelName = "Level Not Loaded";
        }
Exemple #6
0
        public override void BuildUI(UIManager manager)
        {
            UIArea manageData;
            manager.AddArea(manageData = new UIArea(Screen.Width - 400, 100, 250, 300) {Closable = true});
            manageData.Visible = true;
            manageData.AddControl(new TextArea(30, 25, "Manage Defense") {Color = "blue"});

            myClickState = null;
            myClickState = new Button<int>(0,
                                           20,
                                           50,
                                           100,
                                           25,
                                           (Func<string>) ( () => {
                                                                switch (myClickState.Data) {
                                                                    case 0:
                                                                        return "Move Kingdom";
                                                                    case 1:
                                                                        return "Move Waypoint";
                                                                    case 2:
                                                                        return "Add Waypoint";
                                                                    case 3:
                                                                        return "Place Tower";
                                                                }
                                                                return "";
                                                            } )) {
                                                                         Click = (p) => {
                                                                                     myClickState.Data++;
                                                                                     myClickState.Data = myClickState.Data % 4;
                                                                                 }
                                                                 };
            manageData.AddControl(myClickState);
            manageData.AddControl(new Button(20, 80, 100, 25, "Send Wave") {
                                                                                   Click = (p) => {
                                                                                               foreach (var kingdom in Kingdoms) {
                                                                                                   for (int i = 0; i < 4; i++) {
                                                                                                       KeyValuePair<string, Kingdom> kingdom1 = kingdom;
                                                                                                       Window.SetTimeout(() => {
                                                                                                                             kingdom1.Value.Units.Add(new QuickShooterUnit(kingdom1.Value.Waypoints[0].Travel(150, Scale), kingdom1.Value));
                                                                                                                             kingdom1.Value.Units.Add(new QuickShooterUnit(kingdom1.Value.Waypoints[1].Travel(150, Scale), kingdom1.Value));
                                                                                                                             kingdom1.Value.Units.Add(new QuickShooterUnit(kingdom1.Value.Waypoints[2].Travel(150, Scale), kingdom1.Value));
                                                                                                                         },
                                                                                                                         750 * i);
                                                                                                   }
                                                                                               }
                                                                                           }
                                                                           });

            manageData.AddControl(new Button(20, 125, 100, 25, ( (Func<string>) ( () => { return DRAWFAST ? "Draw Slow" : "Draw Fast"; } ) )) {Click = (p) => { DRAWFAST = !DRAWFAST; }});
        }