void _selectUnit(Player p, UIUnitTypeIndexCallback next) { _BattleUnitPositionManager.ShowUnitSelectionUI(UnitSelection.Active); UIPlayerUnitTypeIndexCallback selectUnit = null; selectUnit = (PlayerType PlayerType, UnitType ut, int i) => { _BattleUnitPositionManager._ArmyUI.OnClickUnit -= selectUnit; _BattleUnitPositionManager.HideUnitSelectionUI(); next(ut, i); }; _BattleUnitPositionManager._ArmyUI.OnClickUnit += selectUnit; }
public void RemoveListeners() { OnClickUnit = delegate { }; foreach (UnitTypeUI u in battlebeardUIData) { u.RemoveListeners(); } foreach (UnitTypeUI u in stormshaperUIData) { u.RemoveListeners(); } }
void _CardSystem_RequestUnitSelection(CardData c, int numSelection, Player p, CardAction action, EndCardAction done) { // assume P is going to be the current player UnitSelection flags = UnitSelection.None; if (c.Type == CardType.Healing_Card) { flags = flags | UnitSelection.Inactive; } if (c.Type == CardType.Upgrade_Card) { flags = flags | UnitSelection.Active; flags = flags | UnitSelection.NotUpgraded; } if (c.Type == CardType.Tactic_Card) { flags = flags | UnitSelection.Active; flags = flags | UnitSelection.NotTempUpgraded; } _BattleUnitPositionManager.ShowUnitSelectionUI(flags); int selectedUnits = 0; UIPlayerUnitTypeIndexCallback selectUnit = null; selectUnit = (PlayerType pt, UnitType u, int i) => { Unit unit = _GameStateHolder._ActivePlayer.PlayerArmy.GetUnits(u)[i]; selectedUnits++; // perform the action each time something is selected. This will only effect healing. // we don't want the player to be stuck with no units to select action(c, p, unit); // we reached the total? if (selectedUnits == numSelection) { // don't listen for namy more and hide the UI _BattleUnitPositionManager._ArmyUI.OnClickUnit -= selectUnit; _BattleUnitPositionManager.HideUnitSelectionUI(); done(true, c, p, unit); } }; _BattleUnitPositionManager._ArmyUI.OnClickUnit += selectUnit; }
void SetupDefendedTile(Unit u, Player p, TileData t, UnityAction onDone, UIPlayerUnitTypeIndexCallback remove) { t.SetDefender(u); u.SetPosition(t); u.SetDefending (true); _Board.SetTileDefence (t); _OverworldUI._ArmyUI.OnClickUnit -= remove; _OverworldUI.HideUnitSelectionUI(); onDone(); }
public void RemoveListeners() { OnClickUnit = delegate { }; foreach(UnitTypeUI u in battlebeardUIData) { u.RemoveListeners(); } foreach (UnitTypeUI u in stormshaperUIData) { u.RemoveListeners(); } }