private void initTeam() { playerMap = new Dictionary <ImageItem, Player>(); Point p; for (int x, y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { Player player = null; if (Team != null) { p = new Point(x - width / 2, y); if (p.Equals(Point.Zero)) { player = Team.Leader; } else { KeyValuePair <Player, Point> pair = Team.Formation .Where(kv => kv.Value.Equals(p)) .FirstOrDefault(); if (!pair.Equals(default(KeyValuePair <Player, Point>))) { player = pair.Key; } } } StackPane cell = grid[x, y]; cell.remove(cell.Children.ToArray()); if (player != null) { ImageItem image = new ImageItem(player.Image); image.SourceRectangle = new Rectangle(0, 0, 16, 16); image.PercentWidth = image.PercentHeight = 80; playerMap.Add(image, player); cell.add(image); } } } }
public BattlePane(BattleManager battleManager) { BattleManager = battleManager; StackPane spMain = new StackPane(); spMain.PercentWidth = spMain.PercentHeight = 100; PercentWidth = PercentHeight = 100; hlThumbs = new HList(); hlThumbs.HAlignment = HAlignment.Left; hlThumbs.VAlignment = VAlignment.Top; hlThumbs.PercentWidth = 15; hlThumbs.PercentHeight = 15; hlThumbs.VisibleRange = 5; hlThumbs.Color = Color.Black; hlThumbs.Alpha = 0.5f; hpApCost = new HPane(); hpApCost.VAlignment = VAlignment.Top; hpApCost.PercentWidth = 100; hpApCost.Color = Color.Gray; hpApCost.Alpha = 0.5f; vlSkills = new VList(); vlSkills.PercentWidth = 100; vlSkills.VisibleRange = 3; vlSkills.IsStatic = false; vlSkills.Color = Color.Gray; vlSkills.Alpha = 0.5f; skillPane = new VPane(hpApCost, vlSkills); skillPane.HAlignment = HAlignment.Left; // skillPane.HAlignment = HAlignment.Left; // skillPane.VAlignment = VAlignment.Bottom; // skillPane.PercentWidth = 15; // skillPane.PercentHeight = 30; skillPane.PercentWidth = 100; skillPane.PercentHeight = 100; skillPane.Color = Color.Black; skillPane.Alpha = 0.5f; teamInfo = new TeamInfoPane(); teamInfo.HAlignment = HAlignment.Right; teamInfo.VAlignment = VAlignment.Bottom; teamInfo.PercentWidth = 40; teamInfo.PercentHeight = 20; teamInfo.Color = Color.Black; teamInfo.Alpha = 0.5f; objectInfo = new MapObjectInfoPane(); objectInfo.HAlignment = HAlignment.Right; objectInfo.VAlignment = VAlignment.Bottom; objectInfo.PercentWidth = 25; objectInfo.PercentHeight = 20; objectInfo.Color = Color.Black; objectInfo.Alpha = 0.5f; abilityInfo = new AbilityInfoPane(); abilityInfo.HAlignment = HAlignment.Left; abilityInfo.VAlignment = VAlignment.Bottom; // abilityInfo.HAlignment = HAlignment.Center; // abilityInfo.VAlignment = VAlignment.Bottom; abilityInfo.Color = Color.Black; abilityInfo.Alpha = 0.5f; HPane hpSkills = new HPane(skillPane, abilityInfo); hpSkills.HAlignment = HAlignment.Left; hpSkills.VAlignment = VAlignment.Bottom; hpSkills.PercentWidth = 15; hpSkills.PercentHeight = 30; vlSkills.ActionEvent += (sender, args) => { int s = args.SelectedIndex; if (player.ContainingMap.Slave is Cursor) { if (s == 0) { if (moveCost > player.AP || moveCost <= 0) { return; } movePath = new Queue <Point>(pathCache); moveCost = getMoveCost(player, movePath.Count); } else if (s > 0) { nextAbility = player.Abilities[s - 1]; } vlSkills.ControlLock = false; player.ContainingMap.hideCursor(); cursor.MoveStartedEvent -= onCursorMove; objectInfo.hide(); abilityInfo.hide(); hideSkillList(); // teamInfo.show(); // TODO looks to busy } else { int cost = s == 0 ? 10 : player.Abilities[s - 1].APCost; // TODO move cost if (cost > player.AP) { return; } playerPF = new Pathfinder(player); player.ContainingMap.showCursor(player.Position); cursor = player.ContainingMap.Cursor; cursor.MoveStartedEvent -= onCursorMove; cursor.MoveStartedEvent += onCursorMove; objectInfo.MapCursor = cursor; vlSkills.ControlLock = true; objectInfo.show(); teamInfo.hide(); abilityInfo.hide(); } }; vlSkills.CancelEvent += (sender, args) => { if (cursor == null) { return; } vlSkills.ControlLock = false; player.ContainingMap.hideCursor(); cursor.MoveStartedEvent -= onCursorMove; cursor = null; objectInfo.hide(); teamInfo.show(); }; vlSkills.SelectedEvent += (sender, args) => { int sel = args.SelectedIndex; if (sel > 0) { abilityInfo.Ability = player.Abilities[sel - 1]; abilityInfo.show(); } else { abilityInfo.hide(); } }; hlThumbs.SelectedEvent += (sender, args) => { int sel = args.SelectedIndex; int off = sel + hlThumbs.VisibleRange; if (off < hlThumbs.Children.Count) { (hlThumbs.Children[off] as MenuItem).Disabled = false; } }; // spMain.add(hlThumbs, skillPane, objectInfo, teamInfo, abilityInfo); spMain.add(hlThumbs, objectInfo, teamInfo, hpSkills); add(spMain); hide(); }
public ControlSettingsPane(GameConfig gameConfig) { StackPane spSettings = new StackPane(); VPane vpMain = new VPane(hlCategories, spSettings); hlCategories.PercentWidth = 100; spSettings.PercentWidth = 100; hlCategories.PercentHeight = 10; spSettings.PercentHeight = 90; hlCategories.Color = Color.Black; hlCategories.EffectAlpha = 0.5f; gameConfig.KeyMaps.Keys.ToList().ForEach(key => { hlCategories.add(new TextItem(key, "fonts/menu_font1")); VList vlNames = new VList(); VList vlKeys = new VList(); VList vlButtons = new VList(); HPane hpBorder = new HPane(); HPane hpControls = new HPane(vlNames, vlKeys, hpBorder, vlButtons); hpControls.PercentWidth = 100; hpControls.PercentHeight = 100; vlNames.PercentWidth = 25; vlKeys.PercentWidth = 25; hpBorder.PercentWidth = 5; vlButtons.PercentWidth = 45; vlNames.PercentHeight = 100; vlKeys.PercentHeight = 100; hpBorder.PercentHeight = 100; vlButtons.PercentHeight = 100; vlNames.Color = Color.Black; vlKeys.Color = Color.Gray; hpBorder.Color = Color.Black; vlButtons.Color = Color.Gray; vlNames.EffectAlpha = 0.5f; vlKeys.EffectAlpha = 0.5f; hpBorder.EffectAlpha = 0.5f; vlButtons.EffectAlpha = 0.5f; List <UserInput> input_refs = new List <UserInput>(); List <TextItem> key_refs = new List <TextItem>(); List <TextItem> button_refs = new List <TextItem>(); vlNames.ActionEvent += (sender, args) => { ParentScreen.ScreenManager.AddScreen(new InputDialog( (BesmashScreen)ParentScreen, input_refs[args.SelectedIndex], "Press a new Key or Button", 5, a => initKeyTextItems(input_refs[args.SelectedIndex], key_refs[args.SelectedIndex], button_refs[args.SelectedIndex]) ), null); }; spSettings.add(hpControls); hPanes.Add(hpControls); vLists.Add(vlNames); gameConfig.KeyMaps[key].Keys.ToList().ForEach(key2 => { List <Keys> keys = gameConfig.KeyMaps[key][key2].TriggerKeys; List <Buttons> buttons = gameConfig.KeyMaps[key][key2].TriggerButtons; string title_key = "", title_button = ""; int i; for (i = 0; i < keys.Count(); ++i) { title_key += (i > 0 ? ", " : "") + keys[i].ToString(); } for (i = 0; i < buttons.Count(); ++i) { title_button += (i > 0 ? ", " : "") + buttons[i].ToString(); } TextItem tiName = new TextItem(key2, "fonts/menu_font1"); TextItem tiKeys = new TextItem("", "fonts/menu_font1"); TextItem tiButtons = new TextItem("", "fonts/menu_font1"); initKeyTextItems(gameConfig.KeyMaps[key][key2], tiKeys, tiButtons); vlNames.add(new TextItem(key2, "fonts/menu_font1")); vlKeys.add(tiKeys); vlButtons.add(tiButtons); key_refs.Add(tiKeys); button_refs.Add(tiButtons); input_refs.Add(gameConfig.KeyMaps[key][key2]); }); vlNames.SelectedIndex = 0; }); hlCategories.SelectedEvent += (sender, args) => { if (hlCategories.IsFocused) { vLists[args.SelectedIndex].IsFocused = true; show(true, 1); } }; hlCategories.DeselectedEvent += (sender, args) => vLists[args.SelectedIndex].IsFocused = false; hlCategories.CancelEvent += (sender, args) => { vLists[hlCategories.SelectedIndex].IsFocused = false; hide(0.5f); }; FocusRequestEvent += (s, a) => { vLists[hlCategories.SelectedIndex].IsFocused = true; hlCategories.IsFocused = true; }; FocusLossEvent += (s, a) => hlCategories.IsFocused = false; vpMain.PercentWidth = 100; vpMain.PercentHeight = 100; hlCategories.IsFocused = false; hlCategories.select(0); add(vpMain); }