public ChooseScenarioScreen() { GameButton FirstBloodButton = new TextGameButton(new Vector2(300, 25), new Vector2(GameCamera.GetScreenWidth() / 2 - 150, 400), FirstBloodScenario.NAME); FirstBloodButton.RegisterOnClick(ChooseScenario); FirstBloodButton.RegisterCallbackObject<Scenario>(new FirstBloodScenario()); AddButton(FirstBloodButton); }
public ChooseNumberOfHeroesScreen() { GameButton TwoPlayersButton = new TextGameButton(new Vector2(300, 25), new Vector2(GameCamera.GetScreenWidth() / 2 - 150, 400), "2 Heroes"); GameButton ThreePlayersButton = new TextGameButton(new Vector2(300, 25), new Vector2(GameCamera.GetScreenWidth() / 2 - 150, 450), "3 Heroes"); GameButton FourPlayersButton = new TextGameButton(new Vector2(300, 25), new Vector2(GameCamera.GetScreenWidth() / 2 - 150, 500), "4 Heroes"); ThreePlayersButton.SetDisabled(true); FourPlayersButton.SetDisabled(true); AddButton(TwoPlayersButton); AddButton(ThreePlayersButton); AddButton(FourPlayersButton); var i = 2; foreach (var button in GetButtons()) { button.RegisterOnClick(ChooseNumberOfHeroes); button.RegisterCallbackObject<int>(i); i++; } }
private void ShowPossibleActions(Character character) { ClearButtons(); if (character != null) { List<IAction> actions = character.GetPossibleActions(); var i = 0; foreach (var action in actions) { var labelSize = FontFactory.Font.MeasureString(action.GetLabel()); TextGameButton button = new TextGameButton(new Vector2(labelSize.X / 2 + 40, 40), new Vector2(Rect.X + Rect.Width / 2 - (labelSize.X / 2 + 40) / 2, 500 + 50 * i), action.GetLabel()); button.Show(); button.RegisterCallbackObject(action); button.RegisterOnClick(OnActionClick); buttons.Add(button); i++; } } }
public void OnClick(ClickMessage sourceEvent) { if (!GameCamera.Instance.ScreenViewport.Bounds.Contains(sourceEvent.MousePosition.ToPoint())) { return; } switch(GameplayProgress.Instance.Scenario.Stage) { case ScenarioStageEnum.HERO_SETUP: PickHeroesPlace(); break; case ScenarioStageEnum.OVERLORD_SETUP: PickMonstersPlace(); break; case ScenarioStageEnum.HERO_TURN: var character = GameplayProgress.Instance.ActCharacter; var focusedField = GameplayProgress.Instance.Scenario.GetFocusedField(); if (character != null && focusedField != null) { var movement = character.GetFieldsForMovement(); foreach (var field in movement) { if (field == focusedField && character.ActualAction is MoveAction) { GameplayProgress.Instance.Scenario.ClearMarkedFields(); character.MoveToField(field); } } if (character.ActualAction is AttackAction) { var enemy = focusedField.GetCharacterOnSelf(); if (enemy != null && character.IsEnemy(enemy) && ((Hero)character).CanAttackOn(enemy)) { var resolver = new CombatResolver(character, enemy); resolver.DoAttack(); combatDialog = new Dialog(400, 200, "Combat result"); var a = 0; foreach (var dice in resolver.Attack.AttackDices) { combatDialog.AddRendable(a, new ScaledImage(new Vector2(10 + a * 40, 10), dice.GetResultImage())); a++; } var b = 0; foreach (var dice in resolver.Defense.DefenseDices) { combatDialog.AddRendable(a + b, new ScaledImage(new Vector2(10 + b * 40, 50), dice.GetResultImage())); b++; } GameButton button = new TextGameButton(new Vector2(80, 30), new Vector2(10, 120), "Close"); button.RegisterOnClick(DialogCloseAction); combatDialog.AddRendable(a + b + 1, button); combatDialog.Show(); OnUnfocus(); } } } break; } }