public void Cancel() { if (TargetSystem.Showing) { TargetSystem.Hide(); if (ActionMenu.ActiveAction.Options.Count() == 1) { ActionMenu.Show(); HealthCounter.Show(); } else { OptionsListMenu.Show(ActionMenu.ActiveAction.Options); } /* * ActionMenu.Hide(); * OptionsListMenu.Show(ActionMenu.ActiveAction.Options); * ActiveOption = OptionsListMenu.Active; * * ActiveOption = OptionsListMenu.Active; * OptionsListMenu.Hide(); * TargetSystem.Show(ActiveOption); * */ } else if (OptionsListMenu.Showing) { OptionsListMenu.Hide(); ActionMenu.Start(); HealthCounter.Show(); } }
public void SetMenu(ActionMenu menu) { if (Menus.ContainsKey(menu.GetMenuName)) { Menus[menu.GetMenuName] = menu; } else { Menus.Add(menu.GetMenuName, menu); } }
public void ExecuteFromActionMenu() { if (ActionMenu.ActiveAction.Options.Count() == 1) { ActionMenu.Hide(); ShowTargeting(ActionMenu.ActiveAction.Options[0]); } else { ShowOptionsMenu(); } }
public void MoveTargetUp() { if (OptionsListMenu.Showing) { OptionsListMenu.MoveTargetUp(); ActiveOption = OptionsListMenu.Active; } if (ActionMenu.Showing) { ActionMenu.MoveTargetUp(); } }
void AddMenuToActionPanel(ActionMenu menu) { // Instantiate button GameObject buttonGO = GameObject.Instantiate(actionButtonTemplate, Vector3.zero, Quaternion.identity, ActionPanel.transform) as GameObject; // Set buttons varables buttonGO.name = menu.GetMenuName + "_Button";//buttonName + "_Button"; Text buttonText = buttonGO.GetComponentInChildren <Text>(); buttonText.text = menu.GetMenuName; buttonGO.GetComponent <Button>().onClick.AddListener(MenuSelectButtonPressed); }
public ActionMenu PopulateHeroSummonMenu(HeroInfo heroInfo) { List <Ability> menuAbilities = new List <Ability>(); foreach (var monster in heroInfo.PlayerDemons) { if (!monster.IsDead && !monster.IsSummoned) { menuAbilities.Add(CreateAbilityFromData(heroInfo.SummonActions.Abilities[0], monster)); } } ActionMenu summonMenu = new ActionMenu(heroInfo.SummonActions.Name, menuAbilities); return(summonMenu); }
void MenuPanelSetup(Character character, ActionMenu menu) { // Clear existing MenuPanel ClearMenuPanel(); // Add button for each Ability foreach (var ability in menu.GetActionList) { // Abilites where Charges are not relevant have 'Charges' set to -1 by default // if 'charges' == 0, then they are both required and 'out of stock' if (ability.GetAbilityCharges != 0) { AddToMenuPanel(ability); } } }
public void Start() { CheckLoaded(); BattleStateStore.State = BattleState.STARTING; Enemies.ForEach(enemy => enemy.OnKilled += Enemy_OnKilled); events.ForEach(battleEvent => { if (battleEvent.IsAtStart(this) && battleEvent.IsReady(this)) { battleEvent.Execute(this); } }); bool allCompleted = true; foreach (var ev in events) { if (!ev.Completed) { allCompleted = false; break; } } if (!allCompleted) { foreach (var ev in events) { if (ev.IsAtStart(this) && !ev.Completed) { ev.OnCompleted((isCompleted) => { OnBattleEventCompleted(isCompleted, () => { ActionMenu.Start(); HealthCounter.Show(); BattleStateStore.State = BattleState.STARTED; }); }); } } } else { ActionMenu.Start(); HealthCounter.Show(); BattleStateStore.State = BattleState.STARTED; } }
public void MoveTargetDown() { if (SubOptionsListMenu.Showing) { SubOptionsListMenu.MoveTargetDown(); ActiveOption = SubOptionsListMenu.Active; } else if (OptionsListMenu.Showing) { OptionsListMenu.MoveTargetDown(); ActiveOption = OptionsListMenu.Active; } if (ActionMenu.Showing) { ActionMenu.MoveTargetDown(); } }
// This updates the player's MonsterList info with the new MP for the monsters void OnMPChange(MPChangedEventInfo mpChangedEventInfo) { Debug.Log("CombatManager Alerted to Character MP Change: " + mpChangedEventInfo.UnitGO.name); // We only care about freindly monsters at this point if (mpChangedEventInfo.UnitGO.GetComponent <Character>().GetTeam == TeamName.Friendly) { string uID = mpChangedEventInfo.UnitGO.GetComponent <Character>().GetUniqueID; // Also, we only care about monsters in our playerMonsterInfoList (i.e NOT the hero) <- this is because the hero Mana is tracked differently. if (playerMonsterinfoList.ContainsKey(uID)) { playerMonsterinfoList[mpChangedEventInfo.UnitGO.GetComponent <Character>().GetUniqueID].CurrentMana = mpChangedEventInfo.UnitGO.GetComponent <Character>().GetMP; // Update Summon Menu ActionMenu menu = monsterSpawner.PopulateHeroSummonMenu(GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo); playerCharacters[GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.PlayerName].GetComponent <Hero>().SetMenu(menu); } } }
public void EndTurn() { Console.WriteLine($"{GetType().Name} - ExecuteOption - End"); TurnSystem.End(); while (TurnSystem.Active is Enemy enemy && !enemy.IsDead && enemy.EnemyType != EnemyType.Enviroment) { enemyAISysytem.ExecuteEnemyTurn(this, TurnSystem.Active); } TargetSystem.Cleanup(); if (Enemies.TrueForAll(enemy => enemy.IsDead)) { BattleStateStore.State = BattleState.ENDED; Enemies.ForEach(enemy => enemy.OnKilled -= Enemy_OnKilled); } ActionMenu.Process(); HealthCounter.Show(); }
public void MenuSelectButtonPressed() { string buttonClicked = EventSystem.current.currentSelectedGameObject.name; Debug.Log(buttonClicked); buttonClicked = buttonClicked.Replace("_Button", ""); // Activate BackPanel - We might want to go back and change our mind BackPanel.SetActive(true); // deactivate action panel ActionPanel.SetActive(false); MenuPanel.SetActive(true); // Find which menu button was pressed ActionMenu selectedMenu = SelectedCharacter.GetComponent <Character>().GetMenuByName(buttonClicked); // Populate Menu MenuPanelSetup(SelectedCharacter.GetComponent <Character>(), selectedMenu); isMenuSetup = true; }
void OnUnitSpawn(UnitSpawnEventInfo unitSpawnEventInfo) { Debug.Log("CombatManager Alerted to unit Spawned: " + unitSpawnEventInfo.UnitGO.name); // We only care about freindly monsters at this point if (unitSpawnEventInfo.UnitGO.GetComponent <Character>().GetTeam == TeamName.Friendly) { // Also, we only care about monsters in out playerMonsterInfoList (i.e NOT the hero) <- this is because the hero can not be summoned if (playerMonsterinfoList.ContainsKey(unitSpawnEventInfo.UnitGO.GetComponent <Character>().GetUniqueID)) { playerMonsterinfoList[unitSpawnEventInfo.UnitGO.GetComponent <Character>().GetUniqueID].IsSummoned = true; // Update Summon Menu ActionMenu menu = monsterSpawner.PopulateHeroSummonMenu(GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo); playerCharacters[GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.PlayerName].GetComponent <Hero>().SetMenu(menu); } } // Add to character order list - All Charcaters AddToCharacterTurnOrder(unitSpawnEventInfo.UnitGO); }
public void PassChangedStatsToGM() { // TODO... i dont like how this info is passed back - rework // Update Stats for persistance in future battles // Update Hero HP int hp = playerCharacters[GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.PlayerName].GetComponent <Hero>().GetHP; GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.CurrentHP = hp; int mana = playerCharacters[GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.PlayerName].GetComponent <Hero>().GetMP; GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.CurrentMana = mana; GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.GoldOwned += battleLoot; //update Item charges // TODO... I don't like this // ALSO... This will need to be amended to include adding new loot items ActionMenu consumableMenu = playerCharacters[GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.PlayerName].GetComponent <Hero>().GetMenuByName("Items"); foreach (var item in consumableMenu.GetActionList) { for (int i = 0; i < GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables.Count; i++) { if (GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables[i].Name == item.GetAbilityName) { if (item.GetAbilityCharges > 0) { GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables[i].Charges = item.GetAbilityCharges; } else if (item.GetAbilityCharges == 0) { GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables.RemoveAt(i); } } } } // Add Consumable loot to hero Data after battle foreach (var item in consumableLoot) { bool isFound = false; for (int i = 0; i < GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables.Count; i++) { if (GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables[i].Name == item.Name) { GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables[i].Charges++; isFound = true; } } if (!isFound) { GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo.ConsumableActions.Consumables.Add(new Consumable { Name = item.Name, Charges = 1 }); } } // update Monster stats foreach (var kvp in playerMonsterinfoList) { GameManager.Instance.AddToPlayerMonsterParty(kvp.Value); } }
public void ShowOptionsMenu() { ActionMenu.Hide(); OptionsListMenu.Show(ActionMenu.ActiveAction.Options); ActiveOption = OptionsListMenu.Active; }
public GameObject SpawnHero(TeamName team, GameObject teamGroup, GameObject unitSlot) { // Get monster data from index HeroInfo heroInfo = GameManager.Instance.GetHeroData.heroWrapper.HeroData.HeroInfo; GameObject heroGO = GameObject.Instantiate(heroTemplateGO, unitSlot.transform.position, Quaternion.identity, teamGroup.transform) as GameObject; heroGO.name = heroInfo.PlayerName; if (team == TeamName.Friendly) { heroGO.GetComponent <Hero>().SetMonsterSprite(monsterSprites[heroInfo.FriendlySpriteName]); } else { Debug.Log("TEAM name not correct!!!!"); } heroGO.GetComponent <Hero>().SetTeam(team); heroGO.GetComponent <Hero>().SetUnitSlot(unitSlot); // Set Monster's ability List <Ability> abilities = new List <Ability>(); if (heroInfo.baseActions.Abilities.Count > 0) { foreach (var action in heroInfo.baseActions.Abilities) { abilities.Add(CreateAbilityFromData(action)); } } else { Debug.LogError("No Base abilities set for the hero, something may have gone wrong!"); } heroGO.GetComponent <Hero>().SetMonsterAbilities(abilities); #region Set up Hero's Menus List <ActionMenu> menus = new List <ActionMenu>(); // Summon Menu - Should only contain 1 ability if (heroInfo.SummonActions.Abilities.Count == 1) { menus.Add(PopulateHeroSummonMenu(heroInfo)); } // Item Menu if (heroInfo.ConsumableActions.Consumables.Count > 0) { List <Ability> menuAbilities = new List <Ability>(); foreach (var consumable in heroInfo.ConsumableActions.Consumables) { menuAbilities.Add(CreateConsumableAbilityFromData(consumable.Name, consumable.Charges)); } ActionMenu ItemMenu = new ActionMenu(heroInfo.ConsumableActions.Name, menuAbilities); menus.Add(ItemMenu); } // Spells Menu if (heroInfo.SpellActions.Abilities.Count > 0) { List <Ability> menuAbilities = new List <Ability>(); foreach (var ability in heroInfo.SpellActions.Abilities) { menuAbilities.Add(CreateAbilityFromData(ability)); } ActionMenu spellMenu = new ActionMenu(heroInfo.SpellActions.Name, menuAbilities); menus.Add(spellMenu); } // TODO... add this heroGO.GetComponent <Hero>().SetMenus(menus); #endregion // Set Hero HP, MP + Stats // HP and Mana specifically Must be set here or the UI at start doesn't update with correct HP/MP heroGO.GetComponent <Hero>().SetupHero(heroInfo); // Set Character Unique ID heroGO.GetComponent <Hero>().SetUniqueID(heroInfo.UniqueID); // Trigger Unit Spawn Event Callback EventCallbacks.UnitSpawnEventInfo usei = new EventCallbacks.UnitSpawnEventInfo(); usei.EventDescription = "Unit " + heroGO.name + " has spawned."; usei.UnitGO = heroGO; usei.UnitSlotGO = unitSlot; usei.FireEvent(); return(heroGO); }