public override Entity Create(EntityCreateArgs args) { UICreateArgs ui = args as UICreateArgs; UIElement element = null; switch (ui.type.ToLower()) { case "button": element = new Button( (int)ui.position.x, (int)ui.position.y, 128, 32, null, "new button"); break; case "inputfield": element = new InputField( (int)ui.position.x, (int)ui.position.y, 120, 20); break; case "progressbar": element = new ProgressBar( new Rectangle((int)ui.position.x, (int)ui.position.y, 64, 8), Color.LightGreen, Color.DarkGreen); break; default: return(null); } return(SceneManager.Instance.CurrentScene.CreateEntity(element)); }
public override Entity Create(EntityCreateArgs args) { System.Console.WriteLine($"FACTORY UIFactory: Create()"); if (args == null || args.type == null || args.type == "" || args.type == "\0") { return(null); } UICreateArgs ui = args as UICreateArgs; UIElement element = null; switch (ui.type.ToLower()) { case "button": System.Console.WriteLine($"\tCreating UI Button"); element = new Button( (int)ui.position.x, (int)ui.position.y, 128, 32, null, "new button"); break; case "inputfield": System.Console.WriteLine($"\tCreating UI InputField"); element = new InputField( (int)ui.position.x, (int)ui.position.y, 120, 20); break; case "progressbar": System.Console.WriteLine($"\tCreating UI ProgressBar"); element = new ProgressBar( new Rectangle((int)ui.position.x, (int)ui.position.y, 64, 8), Color.LightGreen, Color.DarkGreen); break; case null: return(null); default: return(null); } return(SceneManager.Instance.CurrentScene.CreateEntity(element)); }