public virtual IEnumerator SlideIn(FightingEntity user, List <FightingEntity> targets) { if (slideType == SlideType.STEP_FORWARD) { Vector3 destination = user.transform.position; destination.x += user.IsHeroTeam() ? -stepForwardDistance : stepForwardDistance; yield return(GameManager.Instance.time.GetController().StartCoroutine(Slide(user.transform, user.transform.position, destination))); } else if (slideType == SlideType.MELEE) { Vector3 destination = Vector3.zero; float averageTargetRadius = 0; foreach (FightingEntity target in targets) { destination += target.transform.position; averageTargetRadius += target.GetComponent <FighterPositions>().fighterRadius; } destination /= targets.Count; averageTargetRadius /= targets.Count; // Distance target and destination based on the reach of this attack and the width of the target float distance = meleeReach + averageTargetRadius; destination.x += user.IsHeroTeam() ? distance : -distance; yield return(GameManager.Instance.time.GetController().StartCoroutine(Slide(user.transform, user.transform.position, destination))); } }
public void Initialize(FightingEntity target, int damage, DamageType damageType) { // Format based on damage type if (damageType == DamageType.HEALING) { damage = Mathf.Abs(damage); _damageText.color = _healColour; } else if (damageType == DamageType.MANA_RECOVERY) { _damageText.color = _manaRecoveryColour; } // Set position FighterPositions uiPositions = target.GetComponent <FighterPositions>(); if (uiPositions != null) { _worldPosition = uiPositions.damagePopup.position; } else { Debug.LogWarning(target.name + " has no damagePopupLocation"); } _worldToScreen.SetWorldPoint(_worldPosition); SetText(damage); GameManager.Instance.time.GetController().StartCoroutine(Fade()); }
public override bool QueueAction(FightingEntity user, string[] splitCommand) { List <int> targetIds = this.GetAllPossibleTargetIds(); user.SetQueuedAction(this, targetIds); return(true); }
public BattleFight(BattleField field, FightingEntity fighter, QueuedAction action, BattleUI ui) { this._field = field; this.fighter = fighter; this.queuedAction = action; this._ui = ui; }
public void FinishQTE(FightingEntity user, List <FightingEntity> targets, float power) { PlayerStats before, after; List <DamageReceiver> receivers = new List <DamageReceiver>(); int rawDamage = GetRawDamage(user.stats, power); foreach (FightingEntity target in targets) { int damage = (int)(rawDamage * target.stats.GetDamageMultiplierResistance()); if (!target.IsHeroTeam()) { damage *= 2; } InstantiateDamagePopup(target, damage); before = (PlayerStats)target.stats.Clone(); target.stats.hp.ApplyDelta(-damage); after = (PlayerStats)target.stats.Clone(); receivers.Add(new DamageReceiver(target, before, after)); } FightResult result = new FightResult(user, this, receivers); _battleFight.EndFight(result, this); }
public DamageReceiver(FightingEntity fighter, PlayerStats before, PlayerStats after, List <StatusAilment> ailments) { this.fighter = fighter; this.before = before; this.after = after; this.ailments = ailments; }
public FightResult(FightingEntity fighter, ActionBase action, DamageReceiver receiver) { this.fighter = fighter; this.action = action; this.receivers = new List <DamageReceiver>(); this.receivers.Add(receiver); }
private void UpdateTargetSelectionUI() { if (potentialTargets == null) { return; } for (int i = 0; i < potentialTargets.Count; i++) { this.SetMaterialOutline(i, false); } if (this._commandSelector != null) { // Single target int index = _commandSelector.GetChoice(); FightingEntity target = potentialTargets[index]; this.SetMaterialOutline(index, true); } else { // All targets for (int i = 0; i < potentialTargets.Count; i++) { this.SetMaterialOutline(i, true); } } }
private void SetHeroTarget() { HeroActionConfirmed(); HeroMenuAction menuAction = GetHeroMenuAction(); menuAction.targetIndex = this._commandSelector.GetChoice(); menuAction.onBackCallback = this.OnTargetChooseBackCallback; HeroMenuAction moveMenuAction = GetPreviousHeroMenuAction(); ActionBase heroAction = moveMenuAction.currentHeroChoices[moveMenuAction.targetIndex].action; switch (heroAction.targetInfo.targetType) { case TargetType.SINGLE: List <FightingEntity> possibleTargets = heroAction.GetAllPossibleActiveTargets(this._field.GetHeroPlayer()); FightingEntity target = possibleTargets[menuAction.targetIndex]; this._field.GetHeroPlayer().SetQueuedAction(heroAction, new List <int> { target.targetId }); break; case TargetType.ALL: List <int> allEnemies = this._field.GetActiveEnemyObjects().Map((EnemyObject enemy) => enemy.targetId); this._field.GetHeroPlayer().SetQueuedAction(heroAction, allEnemies); break; default: break; } this._field.GetHeroPlayer().PlaySound("confirm"); //TODO: Look towards consolidating use here this._heroMenuActions.Push(new HeroMenuAction(MenuState.WAITING)); }
private List <HeroActionChoice> GetHeroActionChoices(ActionType type) { FightingEntity heroPlayer = this._field.GetHeroPlayer(); List <ActionBase> actions = this._field.GetHeroPlayer().GetFilteredActions(type); List <HeroActionChoice> currentHeroChoices = new List <HeroActionChoice>(); foreach (ActionBase action in actions) { currentHeroChoices.Add(new HeroActionChoice(action.name, action)); } if (type == ActionType.BASIC) { if (_field.GetHeroPlayer().GetFilteredActions(ActionType.MAGIC).Count != 0) { currentHeroChoices.Insert(1, new HeroActionChoice("Magic", null)); } } HeroMenuAction menuAction = GetHeroMenuAction(); menuAction.targetIndex = 0; menuAction.currentHeroChoices = currentHeroChoices; return(currentHeroChoices); }
public void SetTurnOrder(List <FightingEntity> fighters) { this.turnOrderHeaderText.gameObject.SetActive(true); turnTexts = new List <BasicText>(); this.arrows = new List <GameObject>(); this.index = 0; for (int i = 0; i < fighters.Count; i++) { FightingEntity fighter = fighters[i]; BasicText instantiatedText = Instantiate <BasicText>(turnTextPrefab); instantiatedText.text.SetText(fighter.Name); instantiatedText.text.color = fighter.GetOrderColor(); instantiatedText.transform.SetParent(turnOrderParent); turnTexts.Add(instantiatedText); if (i != fighters.Count - 1) { GameObject arrow = Instantiate(arrowPrefab); arrow.transform.SetParent(turnOrderParent); arrows.Add(arrow); } } }
public override IEnumerator SlideIn(FightingEntity user, List <FightingEntity> targets) { // Slide toward enemies despite Explosion targeting all fighters List <FightingEntity> enemyTargets = targets.Filter(target => target.isEnemy()); yield return(GameManager.Instance.time.GetController().StartCoroutine(base.SlideIn(user, enemyTargets))); }
public override FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets) { PlayerStats before, after; List <DamageReceiver> receivers = new List <DamageReceiver>(); foreach (FightingEntity target in targets) { before = (PlayerStats)target.stats.Clone(); // Debuff user, buff others if (target == user) { target.ailmentController.TryInflictAilment(debuffAilment); } else { target.ailmentController.TryInflictAilment(buffAilment); } after = (PlayerStats)target.stats.Clone(); receivers.Add(new DamageReceiver(user, before, after, new List <StatusAilment>() { debuffAilment.statusAilment })); } return(new FightResult(user, this, receivers)); }
public int GetManaRestored(FightingEntity user, float power) { float baseMana = user.stats.physical.GetValue() * effects.physicalScaling + user.stats.special.GetValue() * effects.specialScaling; int manaRestored = (int)(baseMana * power); return(manaRestored); }
public override bool QueueAction(FightingEntity user, string[] splitCommand) { user.SetQueuedAction(this, new List <int> { GameManager.Instance.battleComponents.field.GetHeroPlayer().targetId }); return(true); }
private bool CheckCost(FightingEntity user, ActionChoiceResult response) { PlayerStats stats = user.stats; if (stats.hp.GetValue() <= actionCost.HP) { response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST); response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "HP", name, actionCost.HP)); return(false); } else if (stats.mana.GetValue() < actionCost.mana) { response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST); response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "MANA", name, actionCost.mana)); return(false); } else if (currPP < actionCost.PP) { response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST); response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "PP", name, actionCost.PP)); return(false); } else if (user is Mook && ((Mook)user).stamina.GetStamina() < actionCost.stamina) { response.SetState(ActionChoiceResult.State.INSUFFICIENT_COST); response.AddMessage(string.Format(Messages.INSUFFICIENT_COST, "STAMINA", name, actionCost.stamina)); return(false); } return(true); }
public override FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets) { ManaShiftQTE qte = Instantiate(_manaShiftQTE).GetComponent <ManaShiftQTE>(); qte.Initialize(user, targets, this); return(new FightResult(user, this)); }
public virtual FightResult ApplyEffect(FightingEntity user, List <FightingEntity> targets) { PlayerStats before, after; List <DamageReceiver> receivers = new List <DamageReceiver>(); foreach (FightingEntity target in targets) { int damage = GetDamageToTarget(user, target); InstantiateDamagePopup(target, damage); before = (PlayerStats)target.stats.Clone(); target.stats.hp.ApplyDelta(-damage); List <StatusAilment> inflicted = InflictStatuses(target); after = (PlayerStats)target.stats.Clone(); // TODO: Unit test this //if (before.hp.GetValue() - after.hp.GetValue() != damage) { // Debug.LogError("ERROR: Logging stats doesn't match real thing!: " + after.hp.GetValue() + " " + before.hp.GetValue() + " " + damage); //} receivers.Add(new DamageReceiver(target, before, after, inflicted)); } return(new FightResult(user, this, receivers)); }
protected void TargetFlash(FightingEntity target) { if (targetFlash) { GameManager.Instance.time.GetController().StartCoroutine(target.GetAnimController().Flash()); } }
public virtual bool QueueAction(FightingEntity user, string[] splitCommand) { if (targetInfo.targetType == TargetType.SINGLE && splitCommand.Length == 2) { int targetId = this.GetTargetIdFromString(splitCommand[1], user); user.SetQueuedAction(this, new List <int> { targetId }); } else if (targetInfo.targetType == TargetType.ALL && splitCommand.Length == 1) { List <int> targetIds = GetAllPossibleActiveTargets(user).Map(target => target.targetId); user.SetQueuedAction(this, targetIds); } else if (targetInfo.targetType == TargetType.RANDOM && splitCommand.Length == 1) { user.SetQueuedAction(this, new List <int> { }); } else if (targetInfo.targetType == TargetType.NONE && splitCommand.Length == 1) { user.SetQueuedAction(this, new List <int> { }); } return(true); }
private bool CheckValidTarget(FightingEntity user, string[] splitCommand, ActionChoiceResult response) { bool res = false; if (targetInfo.targetType == TargetType.SINGLE && splitCommand.Length == 2) { int targetId = this.GetTargetIdFromString(splitCommand[1], user); res = targetId != -1; } else if (targetInfo.targetType == TargetType.ALL && splitCommand.Length == 1) { res = true; } else if (targetInfo.targetType == TargetType.RANDOM && splitCommand.Length == 1) { res = true; } else if (targetInfo.targetType == TargetType.NONE && splitCommand.Length == 1) { res = true; } if (!res) { response.SetState(ActionChoiceResult.State.INVALID_TARGET); response.AddMessage(string.Format(Messages.WRONG_NUMBER_OF_TARGETS, name, this.GetExampleCommandString())); } return(res); }
private float _avgEffectiveness = -1f; // [-1 , 1], try some moves before effectiveness goes up public FightingEntityAI(FightingEntity fe, float precision, float weight) { this._char = fe; _precision = precision; _weight = weight; InitializeMovesetScore(this._char.actions, _precision); }
public override bool QueueAction(FightingEntity user, string[] splitCommand) { user.SetQueuedAction(this, new List <int> { user.targetId }); return(true); }
protected void InstantiateDamagePopup(FightingEntity target, int damage, DamageType damageType) { if (damagePopupCanvasPrefab != null) { DamagePopup popup = Instantiate(damagePopupCanvasPrefab).GetComponent <DamagePopup>(); popup.Initialize(target, damage, damageType); } }
public bool TargetsDead(FightingEntity user, List <int> targetIds) { if (targetInfo.targetType == TargetType.NONE || targetInfo.targetType == TargetType.RANDOM) { return(false); } return(GetTargets(user, targetIds).Count == 0); }
protected List <FightingEntity> SetTargets(FightingEntity user, List <FightingEntity> targets) { if (targetInfo.targetType == TargetType.RANDOM) { return(GetNewTargets(user)); } return(targets); }
protected override void AnimateUser(FightingEntity user) { AnimationController controller = user.GetAnimController(); controller.AddToTrack("idle", "defend start", false, 0); controller.AddToTrack("idle", "defend end", false, 2f); controller.AddToTrack("idle", "idle", true, 0); }
// Return targets that should be focused during this action public List <FightingEntity> GetFocusedTargets(FightingEntity user, List <int> targetIds) { if (targetInfo.targetType == TargetType.RANDOM) { return(GetAllPossibleActiveTargets(user)); } return(GetTargets(user, targetIds)); }
public override bool QueueAction(FightingEntity user, string[] splitCommand) { // Can only use mana pot on Hero user.SetQueuedAction(this, new List <int> { 0 }); return(true); }
protected override void AnimateUser(FightingEntity user) { AnimationController controller = user.GetAnimController(); int track = controller.TakeFreeTrack(); controller.AddToTrack(track, "heal start", false, 0); controller.AddToTrack(track, "heal end", false, 1.5f); controller.EndTrackAnims(track); }