public DPong(string saveFileName, Canvas uiCanvas) { Assets = AssetLoader.Create(); Save = new SaveSystem(saveFileName); Ui = new UiSystem(Assets, uiCanvas); InputSources = new InputSourceProvider(); }
IEnumerator findUiSystem() { yield return(new WaitForSeconds(0.1f)); UiSystem = GameObject.FindObjectOfType <UiSystem>(); UiSystem.GameSystem = this; }
private void ShowError(UiSystem ui, string message) { var errMsg = ui.CreateErrorBox(false, message); errMsg.OnHideFinish += errMsg.Destroy; errMsg.Show(); }
public static void Clear(this UiSystem system) { foreach (var root in system.GetRootElements()) { system.Remove(root.Name); } }
public World(ContentManager Content, Game1 game, Player player, string filename) { this.game = game; this.Content = Content; this.scripts = new Queue <ScriptChain>(); this.ui = new UiSystem(Content); lua = new Lua(); lua.LoadCLRPackage(); this.player = player; this.player.setWorld(this); lua["l"] = new LuaAPI(game, this, ui, this.player, Content); lua["player"] = this.player; lua.DoString(@" import ('Lakeside2', 'Lakeside2') import ('Lakeside2', 'Lakeside2.UI') import ('Lakeside2', 'Lakeside2.Scripting')"); camera = new TilemapCamera(null); TileMap map; if (filename == null) { map = new TileMap(Content, 20, 10); } else { map = SerializableMap.Load(Content, filename); } setMap(map); camera.setCenteringEntity(this.player); }
private void OCREngine_combo_SelectedIndexChanged(object sender, EventArgs e) { //get OCR engine selected OCREngine = (UiOCREngine)OCREngine_combo.SelectedIndex; //get OCR specific languages UiSystem uiSystem = UiFactory.Instance.NewUiSystem(); try { string[] languages = uiSystem.GetOCRLanguages(OCREngine); //Set languages as items source for OCRLanguage combo SetOCRLanguages(languages); } catch (Exception) { System.Windows.Forms.MessageBox.Show("An error appeared while trying to retrive the languages for " + OCREngine.ToString()); return; } //Set english as default language if (OCREngine == UiOCREngine.UI_OCR_TESSERACT) { OCRLanguage_Combo.SelectedItem = "eng"; int index = OCRLanguage_Combo.SelectedIndex; } else { OCRLanguage_Combo.SelectedItem = "English"; } }
public GameEditor(Game1 game, ContentManager Content, TitleScreen titleScreen) { this.game = game; this.Content = Content; this.titleScreen = titleScreen; ui = new UiSystem(true); ui.addStripeElement(new UiTexture(Content, "gmhotkeys"), StripePosition.Left); }
public LuaAPI(Game1 game, World world, UiSystem ui, Player player, ContentManager Content) { this.game = game; this.world = world; this.ui = ui; this.player = player; this.Content = Content; }
public LevelUI(AssetLoader assetLoader, UiSystem uiSystem, ILevelUIListener listener) { _uiSystem = uiSystem; _listener = listener; _resources = assetLoader.Load <LevelUIResources>("Assets/Content/Level/LevelUIResources.asset"); _pausePanel = _uiSystem.Instantiate(_resources.PausePanel, UILayer.Background, true); _pausePanel.OnCLick += ShowPauseDialog; }
/// <summary> /// Writes a message using the specified channel. /// </summary> /// <param name="message">the message to write</param> public void Write(string message) { log.Debug(message); // New system that dispatches events using the ui event system GenericEventArgs eventArgs = new GenericEventArgs(); eventArgs.eventType = "CHAT_MSG_SYSTEM"; eventArgs.eventArgs = new string[2]; eventArgs.eventArgs[0] = message; eventArgs.eventArgs[1] = string.Empty; UiSystem.DispatchEvent(eventArgs); }
public OverworldEditor(ContentManager Content, Overworld map) { this.Content = Content; this.map = map; this.cursor = new OverworldCursor(Content); ui = new UiSystem(); ui.addStripeElement(new UiTexture(Content, "owhotkeys"), StripePosition.Left); ui.addStripeElement(new UiObjectMonitor <Cursor>(this.cursor, (cursor) => { return(cursor.getLocation().ToString()); }), StripePosition.Right); }
/// <summary> /// This method is called when the player enters the world. /// Generally this only happens when the player logs in. /// This injects 'PLAYER_ENTERING_WORLD' and 'UNIT_NAME_UPDATE' /// UI events so that any interested widgets can update their data. /// </summary> public void PlayerEnteringWorld() { GenericEventArgs eventArgs; eventArgs = new GenericEventArgs(); eventArgs.eventType = "PLAYER_ENTERING_WORLD"; UiSystem.DispatchEvent(eventArgs); eventArgs = new GenericEventArgs(); eventArgs.eventType = "UNIT_NAME_UPDATE"; eventArgs.eventArgs = new string[1]; eventArgs.eventArgs[0] = "player"; UiSystem.DispatchEvent(eventArgs); }
public WorldEditor(ContentManager Content, World world) { this.Content = Content; this.world = world; cursor = new Cursor(Content); ui = new UiSystem(); ui.addStripeElement(new UiTexture(Content, "editorhotkeys"), StripePosition.Left); ui.addStripeElement(new UiObjectMonitor <Cursor>(cursor, (cursor) => { return(cursor.getTileLocation().ToString()); }), StripePosition.Right); this.camera = world.camera; this.camera.setCenteringEntity(cursor); }
public Form1() { InitializeComponent(); Monitor.SelectedIndex = 0; SpecialKey_Combo.SelectedIndex = 0; BTN_Combo.SelectedIndex = 0; KeyModifier_Combo.SelectedIndex = 0; EventType_Combo.SelectedIndex = 0; Blocking_Combo.SelectedIndex = 0; //instantiate UiEvents objects uiNodeEvents = UiFactory.Instance.NewUiNodeMonitor(); uiSystemEvents = UiFactory.Instance.NewUiSystem(); //instantiate UiNode object uiNode = UiFactory.Instance.NewUiNode(); }
public GamePlay(Parameters parameters) { mProfile = new ProfileSystem(); mLevels = new LevelSystem(false, false); mCheats = new CheatsSystem(); mUi = new UiSystem(); mParameters = parameters; mGameProcess = false; mGameObjects = new Dictionary <string, ObjectBase>(); mGameObjects.Add("Hero", GameObject.Find("Sphere").GetComponent <Ball>()); mGameObjects.Add("Road", GameObject.Find("MainObject").GetComponent <Wall>()); mTimer = new Timer(this); mGameData.collisionCounter = 0; }
public Overworld(ContentManager Content, Game1 game, Player p, string current = null) { this.game = game; this.Content = Content; ui = new UiSystem(); player = new OWPlayer(Content, p, Vector2.Zero); // load map overworldLua = new Lua(); overworldLua.LoadCLRPackage(); overworldLua.DoString("import ('Lakeside2', 'Lakeside2')"); overworldLua["player"] = p; overworldLua["overworld"] = this; LuaScript locationScript = new LuaScript("map.lua"); locationScript.execute(null, overworldLua); // put player in the correct spot (the area they're coming out of) if (current == null) { index = 0; } else { for (int i = 0; i < locations.Count; i++) { if (locations[i].filename == current) { index = i; break; } } } // physically move player to index, set camera setPlayerLocation(); x = getCameraDesired(); ui.addStripeElement(new UiObjectMonitor <List <OWLocation> >(locations, locs => { return(Path.GetFileNameWithoutExtension(locs[index].filename)); }), StripePosition.Center); }
protected override void Initialize() { base.Initialize(); ConfigurationOptionsChanged(Configuration.Options); Mouse.SetCursor(MouseCursor.FromTexture2D(Content.Load <Texture2D>("images/cursor"), 0, 0)); IsMouseVisible = true; Storage.Initialize(Content, GraphicsDevice); InputListeners.Input = new InputListeners(this); Components.Add(InputListeners.Input); UiSystem = new UiSystem(this, style); UiSystem.OnRootAdded += root => root.OnElementRemoved += element => element.Dispose(); UiSystem.OnRootAdded += root => Log.Debug("Root '{Name}' added in UiSystem (class {FullName})", root.Name, root.Element.GetType().FullName); UiSystem.OnRootRemoved += root => Log.Debug("Root '{Name}' removed in UiSystem (class {FullName})", root.Name, root.Element.GetType().FullName); ElementSlot = new SwitchComponent(UiSystem); Components.Add(ElementSlot); ScreenManager.LoadScreen(new MainMenuScreen(this), new FadeTransition(GraphicsDevice, Color.Black, 0.5f)); }
public GameWindow() { InitializeComponent(); var boardRenderer = new BoardRenderer(this); Resize += (sender, args) => boardRenderer.Resize(); _uiSystem = new UiSystem(boardRenderer); var keyEvents = new KeyEvents(_uiSystem.Inputs); KeyDown += keyEvents.EventKeyDown; KeyUp += keyEvents.EventKeyUp; base.Text = "PacMan"; // Task.Run(Repeat); _tick.Interval = 1000 / 65; _tick.Tick += ProcessTick; _tick.Enabled = true; }
protected Game(UiSystem uiSystem, LevelSetup levelSetup, bool demoMode) { _uiSystem = uiSystem; _gameDraw = new GameDraw(uiSystem.SpriteSet, uiSystem.Display, uiSystem.ScoreBoard); _levelSetup = levelSetup; if (demoMode) { _demoMode = true; _lives = 0; _stateMachine.ChangeState(GameState.GetReady); } else { _lives = 3; _stateMachine.ChangeState(GameState.Intro); } _bonusFruit = new BonusFruit(_levelSetup.FruitLocation); StartLevel(); }
public UiManager(UiSystem ui, ContentManager content, SpriteBatch sb) { this.uiTextureMap = content.Load <Texture2D>("Textures/Ui/UiTextureMap"); this.ui = ui; this.ui.GlobalScale = 5f; this.ui.UpdateOrder = 0; this.ui.Controls.HandleKeyboard = false; this.ui.Style = new UntexturedStyle(sb) { Font = new GenericSpriteFont(LCMGame.Inst.Font), TextScale = 0.01f }; Panel root = new Panel(Anchor.AutoRight, new Vector2(0.2f, 1), Vector2.Zero) { ChildPadding = Vector2.Zero }; // Saving root.AddChild(new Button(Anchor.TopLeft, new Vector2(0.5f, 10), "Save") { OnPressed = save => { Group group = new Group(Anchor.TopLeft, Vector2.One, false) { CanBeMoused = true }; Panel panel = group.AddChild(new Panel(Anchor.Center, new Vector2(100, 40), Vector2.Zero) { OnUpdated = (p, gameTime) => { if (MlemGame.Input.IsKeyPressed(Keys.Escape)) { p.System.Remove(p.Root.Name); } } }); TextField textField = panel.AddChild(new TextField(Anchor.TopCenter, new Vector2(1, 0.5f))); panel.AddChild(new Button(Anchor.BottomLeft, new Vector2(0.5f, 0.5f), "Back") { OnPressed = saveBack => saveBack.System.Remove(saveBack.Root.Name) }); panel.AddChild(new Button(Anchor.BottomRight, new Vector2(0.5f, 0.5f), "Save") { OnPressed = saveSave => { string text = textField.Text; FileManager.SaveLevel(LevelManager.Level, text, true); saveSave.System.Remove(saveSave.Root.Name); }, OnUpdated = (e, time) => ((Button)e).IsDisabled = textField.Text.Length == 0 }); this.ui.Add("SavePopup", group); } }); // Loading root.AddChild(new Button(Anchor.TopRight, new Vector2(0.5f, 10), "Load") { OnPressed = load => { Group group = new Group(Anchor.TopLeft, Vector2.One, false) { CanBeMoused = true }; Panel panel = group.AddChild(new Panel(Anchor.Center, new Vector2(0.5f, 0.5f), Vector2.Zero) { OnUpdated = (p, gameTime) => { if (MlemGame.Input.IsKeyPressed(Keys.Escape)) { p.System.Remove(p.Root.Name); } }, ChildPadding = new Vector2(2) }); Panel levelSelect = group.AddChild(new Panel(Anchor.TopCenter, new Vector2(1, 0.7f), Vector2.Zero, false, true, new Point(5, 5)) { ChildPadding = new Vector2(2) }); foreach (FileInfo file in FileManager.ListLevels()) { string name = file.Name.Replace(".json", ""); levelSelect.AddChild(new Button(Anchor.AutoCenter, new Vector2(1, 20), name) { OnPressed = e => { if (FileManager.LoadLevel(name, out Level level)) { LevelManager.LoadLevel(level); } e.System.Remove(e.Root.Name); }, Padding = new Vector2(0, 0.5f) }); } panel.AddChild(levelSelect); panel.AddChild(new Button(Anchor.BottomCenter, new Vector2(1, 0.15f), "Back") { OnPressed = saveBack => saveBack.System.Remove(saveBack.Root.Name) }); this.ui.Add("LoadPopup", group); }
private void InitUiPathObjects() { uiNode = UiFactory.Instance.NewUiNode(); uiImage = UiFactory.Instance.NewUiImage(); uiSystem = UiFactory.Instance.NewUiSystem(); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); var tex = Content.Load <Texture2D>("TestTextures/Test"); var fengPortrait = new TextureRegion(Content.Load <Texture2D>("Portraits/framedFeng")); var knightPortrait = new TextureRegion(Content.Load <Texture2D>("Portraits/framedKnight")); var fengPortraitGolden = new TextureRegion(Content.Load <Texture2D>("Portraits/framedFengGolden")); var knightPortraitGolden = new TextureRegion(Content.Load <Texture2D>("Portraits/framedKnightGolden")); var titleStyle = new UntexturedStyle(_spriteBatch) { Font = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")), TextScale = 8.0f, PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8), ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4), }; var style = new UntexturedStyle(_spriteBatch) { Font = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")), TextScale = 2.25f, TextFieldTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4), PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8), ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4), ScrollBarBackground = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2), ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2) }; UiSystem = new UiSystem(Window, GraphicsDevice, style); titleUi = new UiSystem(Window, GraphicsDevice, titleStyle); var prgTitle = new Paragraph(Anchor.TopCenter, 1, "Way of The", true) { PositionOffset = new Vector2(0, 20) }; var prgSubTitle = new Paragraph(Anchor.TopCenter, 1, "Sword", true) { PositionOffset = new Vector2(0, 140) }; titleUi.Add("title", prgTitle); titleUi.Add("subTitle", prgSubTitle); var panel = new Panel(Anchor.Center, new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), positionOffset: Vector2.Zero); var imgFeng = new Image(Anchor.Center, new Vector2(200, 200), fengPortrait) { IsHidden = true, PositionOffset = new Vector2(-150, 20) }; var btnFeng = new Button(Anchor.Center, imgFeng.Size, "") { HoveredColor = Color.Transparent, NormalColor = Color.Transparent, PositionOffset = new Vector2(-150, 20), IsHidden = true }; var imgKnight = new Image(Anchor.Center, new Vector2(235, 235), knightPortrait) { IsHidden = true, PositionOffset = new Vector2(150, 32) };; var btnKnight = new Button(Anchor.Center, imgKnight.Size, "") { HoveredColor = Color.Transparent, NormalColor = Color.Transparent, PositionOffset = new Vector2(150, 32), IsHidden = true }; var prgAuthor = new Paragraph(Anchor.Center, 1, "By Ethan Eshed", true) { PositionOffset = new Vector2(0, 80) }; var btnPlay = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Play") { PositionOffset = new Vector2(0, 35) }; var btnFight = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Fight!") { IsHidden = true, PositionOffset = new Vector2(0, 35) }; var prgPlayers = new Paragraph(Anchor.Center, 1, "Select your Champion", true) { PositionOffset = new Vector2(0, -120), IsHidden = true }; var btnProceed = new Button(Anchor.BottomCenter, new Vector2(200, 50), "Proceed") { IsHidden = true, PositionOffset = new Vector2(0, 35) }; var prgNickName = new Paragraph(Anchor.Center, 1, "Enter your Name", true) { PositionOffset = new Vector2(-19, -80), IsHidden = true }; var txtBoxNickName = new TextField(Anchor.Center, new Vector2(400, 50)) { IsHidden = true, PositionOffset = new Vector2(0, 30) }; var btnBack = new Button(Anchor.TopRight, new Vector2(200, 50), "Back") { IsHidden = true, PositionOffset = new Vector2(15, 15), OnPressed = e => { if (!btnFight.IsHidden) // champion select screen { btnProceed.IsHidden = false; txtBoxNickName.IsHidden = false; prgNickName.IsHidden = false; e.IsHidden = false; prgPlayers.IsHidden = true; imgFeng.IsHidden = true; imgKnight.IsHidden = true; btnFight.IsHidden = true; btnFeng.IsHidden = true; btnKnight.IsHidden = true; } else { prgTitle.IsHidden = false; prgSubTitle.IsHidden = false; prgAuthor.IsHidden = false; btnPlay.IsHidden = false; btnProceed.IsHidden = true; txtBoxNickName.IsHidden = true; prgNickName.IsHidden = true; e.IsHidden = true; } } }; btnPlay.OnPressed = e => { prgTitle.IsHidden = true; prgSubTitle.IsHidden = true; prgAuthor.IsHidden = true; e.IsHidden = true; btnBack.IsHidden = false; btnProceed.IsHidden = false; txtBoxNickName.IsHidden = false; prgNickName.IsHidden = false; }; btnProceed.OnPressed = e => { if (!txtBoxNickName.Text.Equals("")) { prgPlayers.IsHidden = false; imgFeng.IsHidden = false; imgKnight.IsHidden = false; btnFight.IsHidden = false; btnFeng.IsHidden = false; btnKnight.IsHidden = false; btnProceed.IsHidden = true; txtBoxNickName.IsHidden = true; prgNickName.IsHidden = true; nickName = txtBoxNickName.Text; } }; btnFeng.OnPressed = e => { imgKnight.Texture = knightPortrait; imgFeng.Texture = fengPortraitGolden; champion = "feng"; }; btnFeng.OnMouseEnter = e => { imgFeng.Texture = fengPortraitGolden; }; btnFeng.OnMouseExit = e => { if (champion != "feng") { imgFeng.Texture = fengPortrait; } }; btnKnight.OnPressed = e => { imgFeng.Texture = fengPortrait; imgKnight.Texture = knightPortraitGolden; champion = "knight"; }; btnKnight.OnMouseEnter = e => { imgKnight.Texture = knightPortraitGolden; }; btnKnight.OnMouseExit = e => { if (champion != "knight") { imgKnight.Texture = knightPortrait; } }; btnFight.OnPressed = e => { if (champion != "none") { UiSystem.Dispose(); titleUi.Dispose(); Exit(); Communicator.Setup(champion, nickName); } }; panel.AddChild(prgPlayers); panel.AddChild(prgAuthor); panel.AddChild(btnPlay); panel.AddChild(btnBack); panel.AddChild(imgFeng); panel.AddChild(imgKnight); panel.AddChild(btnFight); panel.AddChild(btnFeng); panel.AddChild(btnKnight); panel.AddChild(btnPlay); panel.AddChild(txtBoxNickName); panel.AddChild(btnProceed); panel.AddChild(prgNickName); UiSystem.Add("StartMenu", panel); }
public UiNode(UiSystem system, UiElement element) { this.element = element; this.system = system; }
/// <summary> /// Sets up the default cursor. /// </summary> public void Initialize() { // Set up the default cursor UiSystem.SetCursor(3, "Interface\\Cursor\\Point"); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); var tex = Content.Load <Texture2D>("TestTextures/Test"); vicCount = 0; vicTimeCount = 0; var style = new UntexturedStyle(_spriteBatch) { Font = new GenericSpriteFont(Content.Load <SpriteFont>("Fonts/alagard")), TextScale = 2.0f, PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8), ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4), ScrollBarBackground = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2), ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2) }; UiSystem = new UiSystem(Window, GraphicsDevice, style); var pnlOptions = new Panel(Anchor.Center, new Vector2(350, 400), positionOffset: Vector2.Zero) { IsHidden = true }; var btnOptions = new Button(Anchor.TopLeft, new Vector2(200, 50), "Options") { PositionOffset = new Vector2(15, 15) }; var btnHitbox = new Button(Anchor.TopLeft, new Vector2(220, 50), "HitboxLayout:") { PositionOffset = new Vector2(25, 25) }; var prgHitbox = new Paragraph(Anchor.TopRight, 1, "Off", true) { PositionOffset = new Vector2(25, 33) }; var btnExit = new Button(Anchor.Center, new Vector2(220, 50), "Exit Game") { PositionOffset = new Vector2(0, 0) }; var btnOk = new Button(Anchor.BottomCenter, new Vector2(220, 50), "Ok") { PositionOffset = new Vector2(0, 30) }; var btnMainMenu = new Button(Anchor.Center, new Vector2(220, 50), "Main Menu") { PositionOffset = new Vector2(0, -70) }; pnlDefeat = new Panel(Anchor.Center, new Vector2(350, 400), positionOffset: Vector2.Zero) { IsHidden = true }; var prgDefeat = new Paragraph(Anchor.TopCenter, 1, "Defeat", true) { PositionOffset = new Vector2(0, 33) }; var btnMenu = new Button(Anchor.Center, new Vector2(220, 50), "Main Menu") { PositionOffset = new Vector2(0, 70) }; var btnExitGame = new Button(Anchor.BottomCenter, new Vector2(220, 50), "Exit Game") { PositionOffset = new Vector2(0, 30) }; var prgDeath = new Paragraph(Anchor.Center, 1, "You Died.", true) { PositionOffset = new Vector2(0, -50) }; btnVictory = new Button(Anchor.TopCenter, new Vector2(700, 50), "") { PositionOffset = new Vector2(0, 90), IsHidden = true, IsDisabled = true }; btnOptions.OnPressed = e => { pnlOptions.IsHidden = false; btnOptions.IsDisabled = true; }; btnOk.OnPressed = e => { pnlOptions.IsHidden = true; btnOptions.IsDisabled = false; }; btnHitbox.OnPressed = e => { if (prgHitbox.Text == "Off") { prgHitbox.Text = "On"; AnimationManager.HitboxLayout = true; } else { prgHitbox.Text = "Off"; AnimationManager.HitboxLayout = false; } }; btnExit.OnPressed = e => { Communicator.ExitSoftware = true; Exit(); }; btnExitGame.OnPressed = e => { Communicator.ExitSoftware = true; Exit(); }; btnMenu.OnPressed = e => { Exit(); }; btnMainMenu.OnPressed = e => { Exit(); }; pnlOptions.AddChild(btnHitbox); pnlOptions.AddChild(prgHitbox); pnlOptions.AddChild(btnExit); pnlOptions.AddChild(btnOk); pnlOptions.AddChild(btnMainMenu); pnlDefeat.AddChild(btnMenu); pnlDefeat.AddChild(prgDefeat); pnlDefeat.AddChild(btnExitGame); pnlDefeat.AddChild(prgDeath); UiSystem.Add("OptionsPanel", pnlOptions); UiSystem.Add("DefeatPanel", pnlDefeat); UiSystem.Add("OptionsButton", btnOptions); UiSystem.Add("VictoryStatement", btnVictory); int idCount1 = 0; int idCount2 = 0; animations = new Dictionary <champions, Dictionary <string, Animation> >() { { champions.Feng, new Dictionary <string, Animation>() { { "Run_Left", new Animation(Content.Load <Texture2D>("Feng/Run_Left"), 8, idCount1++) }, { "Run_Right", new Animation(Content.Load <Texture2D>("Feng/Run_Right"), 8, idCount1++) }, { "Jump_Right", new Animation(Content.Load <Texture2D>("Feng/Jump_Right"), 2, idCount1++) }, { "Jump_Left", new Animation(Content.Load <Texture2D>("Feng/Jump_Left"), 2, idCount1++) }, { "Fall_Right", new Animation(Content.Load <Texture2D>("Feng/Fall_Right"), 2, idCount1++) }, { "Fall_Left", new Animation(Content.Load <Texture2D>("Feng/Fall_Left"), 2, idCount1++) }, { "Idle_Right", new Animation(Content.Load <Texture2D>("Feng/Idle_Right"), 8, idCount1++) }, { "Idle_Left", new Animation(Content.Load <Texture2D>("Feng/Idle_Left"), 8, idCount1++) }, { "Attack1_Right", new Animation(Content.Load <Texture2D>("Feng/Attack1_Right"), 6, idCount1++) }, { "Attack_Right", new Animation(Content.Load <Texture2D>("Feng/Attack_Right"), 12, idCount1++) }, { "Attack1_Left", new Animation(Content.Load <Texture2D>("Feng/Attack1_Left"), 6, idCount1++) }, { "Attack_Left", new Animation(Content.Load <Texture2D>("Feng/Attack_Left"), 12, idCount1++) }, { "Hurt_Right", new Animation(Content.Load <Texture2D>("Feng/Hurt_Right"), 4, idCount1++) }, { "Hurt_Left", new Animation(Content.Load <Texture2D>("Feng/Hurt_Left"), 4, idCount1++) }, { "Death_Right", new Animation(Content.Load <Texture2D>("Feng/Death_Right"), 6, idCount1++) }, { "Death_Left", new Animation(Content.Load <Texture2D>("Feng/Death_Left"), 6, idCount1++) } } }, { champions.Knight, new Dictionary <string, Animation>() { { "Run_Left", new Animation(Content.Load <Texture2D>("Knight/Run_Left"), 10, idCount2++) }, { "Run_Right", new Animation(Content.Load <Texture2D>("Knight/Run_Right"), 10, idCount2++) }, { "Jump_Right", new Animation(Content.Load <Texture2D>("Knight/Jump_Right"), 3, idCount2++) }, { "Jump_Left", new Animation(Content.Load <Texture2D>("Knight/Jump_Left"), 3, idCount2++) }, { "Fall_Right", new Animation(Content.Load <Texture2D>("Knight/Fall_Right"), 4, idCount2++) }, { "Fall_Left", new Animation(Content.Load <Texture2D>("Knight/Fall_Left"), 4, idCount2++) }, { "Idle_Right", new Animation(Content.Load <Texture2D>("Knight/Idle_Right"), 8, idCount2++) }, { "Idle_Left", new Animation(Content.Load <Texture2D>("Knight/Idle_Left"), 8, idCount2++) }, { "Attack1_Right", new Animation(Content.Load <Texture2D>("Knight/Attack1_Right"), 6, idCount2++) }, { "Attack_Right", new Animation(Content.Load <Texture2D>("Knight/Attack_Right"), 6, idCount2++) }, { "Attack1_Left", new Animation(Content.Load <Texture2D>("Knight/Attack1_Left"), 6, idCount2++) }, { "Attack_Left", new Animation(Content.Load <Texture2D>("Knight/Attack_Left"), 6, idCount2++) }, { "Hurt_Right", new Animation(Content.Load <Texture2D>("Knight/Hurt_Right"), 3, idCount2++) }, { "Hurt_Left", new Animation(Content.Load <Texture2D>("Knight/Hurt_Left"), 3, idCount2++) }, { "Death_Right", new Animation(Content.Load <Texture2D>("Knight/Death_Right"), 10, idCount2++) }, { "Death_Left", new Animation(Content.Load <Texture2D>("Knight/Death_Left"), 10, idCount2++) } } } }; hitBoxManager.AquireData(GraphicsDevice); background = new Sprite(Content.Load <Texture2D>("maps/pixel hills")); Feng.ground = new Vector2(100, GraphicsDevice.Viewport.Height - 270); Knight.ground = new Vector2(100, GraphicsDevice.Viewport.Height - 130); // 200 champions champ = StartMenu.champion == "feng" ? champions.Feng : champions.Knight; Character character; Vector2 g; if (champ == champions.Feng) { character = new Feng(); g = Feng.ground; } else { character = new Knight(); g = Knight.ground; } Communicator.SetGround(g.Y); sprites = new List <Sprite>() { new Sprite(animations[champ], champ, StartMenu.nickName) { Position = new Vector2(g.X, g.Y), Id = Communicator.ClientId, Champion = character } }; UiSystem.Add(sprites[0].Id.ToString() + "h", sprites[0].healthBar); UiSystem.Add(sprites[0].Id.ToString() + "n", sprites[0].nickName); Thread thr = new Thread(Communicator.Receive); thr.Start(); StartMenu.champion = "none"; }
public LevelViewFactory(AssetLoader assetLoader, UiSystem uiSystem) { _assetLoader = assetLoader; _uiSystem = uiSystem; }
public void Show(UiSystem system) { system.Add(ELEMENT_NAME, this); }
public TitleScreen(Game1 game, ContentManager Content) { this.game = game; this.Content = Content; bg = Content.Load <Texture2D>(GameInfo.titleBackground); ui = new UiSystem(false); mainList = new UiList(Content, new string[4] { "New Game", "Load Game", "Options", "Quit" }); mainList.addCallback(element => { element.finished = false; // cancel removing the main list UiList list = (UiList)element; int selected = list.selected; switch (selected) { case -1: // thwart attempt to close the main menu { list.selected = 0; break; } case 0: // new game { TimeOfDay.restart(); Flags.reset(); if (GameInfo.startOverworld) { game.goToOverworld(new Player(Content, null, null), GameInfo.startMap); } else { game.goToWorld(new Player(Content, null, null), GameInfo.startMap); } break; } case 1: // load game { ui.pushElement(new UiSavePicker(Content, false).addCallback(element => { UiSavePicker saves = (UiSavePicker)element; string chosen = saves.selectedString; if (chosen == UiSavePicker.NO_FILES || chosen == null) { return; } SaveGame game = SaveGame.Load(Content, chosen); TimeOfDay.restart(); Flags.reset(); // restore data from save Player player = new Player(Content, null, null); foreach (string s in game.inventory.Keys) { player.addItem(s, game.inventory[s]); } Flags.setAllFlags(game.flags, game.strings); TimeOfDay.addMillis(game.time); player.setTileLocation(game.location); // go to overworld or map if (game.overworld) { this.game.goToOverworld(player, game.map); } else { this.game.goToWorld(player, game.map, false); } }), new Vector2(Tile.TILE_SIZE, Tile.TILE_SIZE)); break; } case 2: // options { ui.pushElement(new UiOptionsMenu(game, Content), new Vector2( Game1.INTERNAL_WIDTH / 2 - UiOptionsMenu.WIDTH / 2, Game1.INTERNAL_HEIGHT / 2 - UiOptionsMenu.HEIGHT / 2) ); break; } case 3: // quit { game.Exit(); break; } } }); Vector2 center = Vector2.Round(new Vector2( Game1.INTERNAL_WIDTH / 2 - mainList.size.X / 2, (Game1.INTERNAL_HEIGHT / 2 - mainList.size.Y / 2) + 20)); ui.pushElement(mainList, center); }
public SwitchComponent(UiSystem uiSystem) { _uiSystem = uiSystem; }