/// <summary> /// Creates the allowed targets. /// </summary> /// <returns>The allowed targets.</returns> /// <param name="origin">Origin.</param> /// <param name="entityManager">Entity manager.</param>` /// <param name="skill">Skill.</param> public static SelectableTargetManager CreateAllowedTargets(BattleEntity origin, BattleEntityManagerComponent entityManager, ICombatSkill skill) { HashSet<BattleEntity> entitySet = new HashSet<BattleEntity>(entityManager.allEntities); List<SelectableTarget> targetList = new List<SelectableTarget>(); Dictionary<BattleEntity, SelectableTarget> targetMap = new Dictionary<BattleEntity, SelectableTarget>(); // filter FilterSkill(entitySet, skill); // populate targets if(origin.isPC) { PopulateSelectableTargets(targetList, (PCBattleEntity) origin, entitySet, skill); } else { PopulateSelectableTargets(targetList, (EnemyBattleEntity) origin, entitySet, skill); } // create map foreach(SelectableTarget target in targetList) { foreach(BattleEntity entity in target.entities) { targetMap[entity] = target; } } return new SelectableTargetManager(skill, targetList, targetMap); }
public BattleEntity[] GetTargets(ICombatSkill skill) { if(HasValidTargets(skill)) { return mTargetEntity; } return new BattleEntity[0]; }
public BattleAction(ICombatSkill skill, BattleEntity sourceEntity, ITargetResolver targetResolver) { this.combatSkill = skill; this.sourceEntity = sourceEntity; this.targetResolver = targetResolver; this.mCombatRoundIndex = 0; this.mCombatRoundCount = skill.CombatRounds.Length; }
public bool HasValidTargets(ICombatSkill skill) { foreach(BattleEntity entity in mBattleEntityManager.GetRow(mRowPosition)) { if(skill.TargetRule.IsValidTarget(entity)) { return true; } } return false; }
public bool HasValidTargets(ICombatSkill skill) { foreach(BattleEntity entity in targetEntities) { if(skill.TargetRule.IsValidTarget(entity)) { return true; } } return false; }
public BattleEntity[] GetTargets(ICombatSkill skill) { List<BattleEntity> filteredEntities = new List<BattleEntity>(); foreach(BattleEntity entity in mBattleEntityManager.GetRow(mRowPosition)) { if(skill.TargetRule.IsValidTarget(entity)) { filteredEntities.Add(entity); } } return filteredEntities.ToArray(); }
public HotKey(ICombatSkill skill) { this.skill = skill; }
/// <summary> /// Set the action to the current top battle entity selected. /// </summary> /// <param name="action">Action.</param> public void SelectSkill(ICombatSkill skill) { if( mTurnQueue.Count == 0 ) { // do nothing bad state Debug.LogError("Bad state, PCTurnManager.SelectSkill when no PC available"); return; } currentSelectedSkill = skill; currentTargetManager = SelectableTargetManager.CreateAllowedTargets(mTurnQueue.Peek(), mEntityManager, skill); decisionState = DecisionState.TARGET; }
public static BattleAction CreateBattleAction(ICombatSkill fromSkill, BattleEntity origin, ITargetResolver targetResolver) { return new BattleAction(fromSkill, origin, targetResolver); }
public bool HasValidTargets(ICombatSkill skill) { return skill.TargetRule.IsValidTarget(mTargetEntity[0]); }
private SelectableTargetManager(ICombatSkill skill, List<SelectableTarget> targetList, Dictionary<BattleEntity, SelectableTarget> targetMap ) { this.skill = skill; this.targetList = targetList; this.mTargetMap = targetMap; }
/// <summary> /// Populates the selectable targets. /// </summary> /// <param name="entityList">Entity list.</param> /// <param name="origin">Origin.</param> /// <param name="entitySet">Entity set.</param> /// <param name="skill">Skill.</param> private static void PopulateSelectableTargets(List<SelectableTarget> entityList, PCBattleEntity origin, HashSet<BattleEntity> entitySet, ICombatSkill skill) { switch(skill.TargetRule.primaryTargetType) { case TargetingType.ALL: PopulateAllTargets(entityList, entitySet); break; case TargetingType.ROW: PopulateRowTargets(entityList, entitySet); break; case TargetingType.SELF: PopulateSelfTargets(entityList, entitySet, origin); break; case TargetingType.SELF_ROW: PopulateSelfRowTargets(entityList, entitySet, origin); break; case TargetingType.SINGLE: PopulateSingleTargets(entityList, entitySet); break; } }
/// <summary> /// Filters out battle entities from the set that are not valid targets for the skill. /// </summary> /// <param name="entitySet">Entity set.</param> /// <param name="skill">Skill.</param> private static void FilterSkill(HashSet<BattleEntity> entitySet, ICombatSkill skill) { // if we assigned a predicate, lets remove those entities entitySet.RemoveWhere(delegate(BattleEntity obj) { return !skill.TargetRule.IsValidTarget(obj); }); }