// returns max join animation duration private float playJoinFightAnimations(List <FightEventTarget> targetList) { float maxAnimationDuration = 0; foreach (FightEventTarget target in targetList) { FightCharacter character = fightCharacters[target.id]; // Old as animation start character.animationFromX = character.gridX; character.animationFromY = character.gridY; // Set new location (target) character.gridY = character.teamGridY == team1TeamRow ? team1FightRow : team2FightRow; // TODO if we want to group together in X // Set animation target character.animationToX = character.gridX; character.animationToY = character.gridY; float animationDuration = playJoinAnimation(character); if (animationDuration > maxAnimationDuration) { maxAnimationDuration = animationDuration; } } return(maxAnimationDuration); }
private float playJoinCombatAnimations(List <FightEventTarget> targetList) { if (targetList.Count != 2) { return(0); } float maxAnimationDuration = 0; FightCharacter character = fightCharacters[targetList[0].id]; // Old as animation start character.animationFromX = character.gridX; character.animationFromY = character.gridY; // Set new location (target) character.gridY = combatRow; character.gridX = -1; // TODO if we want to group together in X // Set animation target character.animationToX = character.gridX; character.animationToY = character.gridY; float animationDuration = playJoinAnimation(character); if (animationDuration > maxAnimationDuration) { maxAnimationDuration = animationDuration; } return(maxAnimationDuration); }
private float playDeathAnimations(List <FightEventTarget> targetList) { foreach (FightEventTarget target in targetList) { FightCharacter character = fightCharacters[target.id]; character.animatorScript.Die(); } return(1f); }
public static string GetFightCharacterDamageDoneTooltip(this FightCharacter fightCharacter, string title, int displayIndex, double?percentOfTotal, double?percentOfMax) => $@"{displayIndex}. {title} {fightCharacter.TotalDamageDonePlusPets:N0} total dmg {percentOfTotal.FormatPercent()} of fight's total dmg {percentOfMax.FormatPercent()} of fight's max dmg {fightCharacter.WeaponDamageDonePMPlusPets.Format()} ({fightCharacter.WeaponPercentOfTotalDamageDonePlusPets.FormatPercent()}) weapon dmg / min {fightCharacter.NanoDamageDonePMPlusPets.Format()} ({fightCharacter.NanoPercentOfTotalDamageDonePlusPets.FormatPercent()}) nano dmg / min {fightCharacter.IndirectDamageDonePMPlusPets.Format()} ({fightCharacter.IndirectPercentOfTotalDamageDonePlusPets.FormatPercent()}) indirect dmg / min {(!fightCharacter.HasCompleteAbsorbedDamageDoneStats ? "≥ " : "")}{fightCharacter.AbsorbedDamageDonePMPlusPets.Format()} ({fightCharacter.AbsorbedPercentOfTotalDamageDonePlusPets.FormatPercent()}) absorbed dmg / min {fightCharacter.TotalDamageDonePMPlusPets.Format()} total dmg / min {(!fightCharacter.HasCompleteMissStatsPlusPets ? "≤ " : "")}{fightCharacter.WeaponHitDoneChancePlusPets.FormatPercent()} weapon hit chance {fightCharacter.CritDoneChancePlusPets.FormatPercent()} crit chance {fightCharacter.GlanceDoneChancePlusPets.FormatPercent()} glance chance" + (!fightCharacter.Fight.HasObservedBlockedHits ? null : $@" {(!fightCharacter.HasCompleteBlockedHitStatsPlusPets ? "≥ " : "")}{fightCharacter.BlockedHitDoneChancePlusPets.FormatPercent()} blocked hit chance") + $@" {(!fightCharacter.HasCompleteMissStatsPlusPets ? "≥ " : "")}{fightCharacter.WeaponHitAttemptsDonePMPlusPets.Format()} weapon hit attempts / min {fightCharacter.WeaponHitsDonePMPlusPets.Format()} weapon hits / min {fightCharacter.RegularsDonePMPlusPets.Format()} regulars / min {fightCharacter.NormalsDonePMPlusPets.Format()} normals / min {fightCharacter.CritsDonePMPlusPets.Format()} crits / min {fightCharacter.GlancesDonePMPlusPets.Format()} glances / min" + (!fightCharacter.Fight.HasObservedBlockedHits ? null : $@" {(!fightCharacter.HasCompleteBlockedHitStatsPlusPets ? "≥ " : "")}{fightCharacter.BlockedHitsDonePMPlusPets.Format()} blocked hits / min") + $@" {fightCharacter.SpecialsDonePMPlusPets.Format()} specials / min {fightCharacter.NanoHitsDonePMPlusPets.Format()} nano hits / min {fightCharacter.IndirectHitsDonePMPlusPets.Format()} indirect hits / min {(!fightCharacter.HasCompleteAbsorbedDamageDoneStats ? "≥ " : "")}{fightCharacter.AbsorbedHitsDonePMPlusPets.Format()} absorbed hits / min {fightCharacter.TotalHitsDonePMPlusPets.Format()} total hits / min {fightCharacter.AverageWeaponDamageDonePlusPets.Format()} weapon dmg / hit {fightCharacter.AverageRegularDamageDonePlusPets.Format()} regular dmg / hit {fightCharacter.AverageNormalDamageDonePlusPets.Format()} normal dmg / hit {fightCharacter.AverageCritDamageDonePlusPets.Format()} crit dmg / hit {fightCharacter.AverageGlanceDamageDonePlusPets.Format()} glance dmg / hit {fightCharacter.AverageSpecialDamageDonePlusPets.Format()} special dmg / hit {fightCharacter.AverageNanoDamageDonePlusPets.Format()} nano dmg / hit {fightCharacter.AverageIndirectDamageDonePlusPets.Format()} indirect dmg / hit {fightCharacter.AverageAbsorbedDamageDonePlusPets.Format()} absorbed dmg / hit" + (!fightCharacter.HasSpecialsDonePlusPets ? null : $@" {fightCharacter.GetSpecialsDonePlusPetsInfo()}") + (fightCharacter.TotalDamageDonePlusPets == 0 ? null : $@" {fightCharacter.GetDamageTypesDonePlusPetsInfo()}") + (fightCharacter.HealthDrained == 0 ? null : $@" {fightCharacter.HealthDrainedPM.Format()} health drained / min {fightCharacter.NanoDrainedPM.Format()} nano drained / min");
public static void RemoveRegistration(FightCharacter fightPet, FightCharacter fightPetMaster) { if (_petRegistrations.TryGetValue(fightPet.Name, out string currentPetMasterName)) { if (currentPetMasterName == fightPetMaster.Name) { _petRegistrations.Remove(fightPet.Name); Settings.Default.PetRegistrations.Remove($"{fightPet.Name}{Separator}{currentPetMasterName}"); } } }
void Awake() { RectTransform rectTransform = GetComponent <RectTransform>(); areaSize = rectTransform.sizeDelta; if (areaSize.x > areaSize.y) { tileHeight = areaSize.y / 5; tileWidth = tileHeight; } else { tileHeight = areaSize.x / 5; tileWidth = tileHeight; } fightCharacters = new FightCharacter[10]; for (int i = 0; i < 10; i++) { GameObject character = Instantiate(characterPrefab) as GameObject; FightCharacterAnimatorScript animatorScript = character.GetComponent <FightCharacterAnimatorScript>(); character.transform.parent = transform; character.transform.localRotation = Quaternion.identity; int gridX, gridY; if (i < 5) { // -2 because we have 5 heroes per side so the third goes to middle // i:th hero goes from 0 to 5. gridX = centerColumn - 2 + i; gridY = team1TeamRow; } else { // same as in if true part but -5 more because we are handling next team of heroes gridX = centerColumn - 7 + i; gridY = team2TeamRow; } Vector3 newPosition = getWorldPosition(gridX, gridY); character.transform.localPosition = newPosition; // Scale char to tile size character.transform.localScale = Vector3.one * tileHeight; FightCharacter fightCharacter = new FightCharacter(); fightCharacter.animatorScript = animatorScript; fightCharacter.gridX = gridX; fightCharacter.gridY = gridY; fightCharacter.teamGridX = gridX; fightCharacter.teamGridY = gridY; fightCharacter.transform = character.transform; fightCharacters[i] = fightCharacter; } }
private bool tryGetCharacter(string name, out FightCharacter character) { for (int i = 0; i < this.AllCharacter.Length; ++i) { if (!string.IsNullOrEmpty(this.AllCharacter [i].CharacterName) && this.AllCharacter [i].CharacterName.Equals(name)) { character = this.AllCharacter [i]; return(true); } } character = null; return(false); }
private IEnumerator verticalMoveAnimation(FightCharacter character) { if (character.animationFromY != character.animationToY) { Vector3 newWorldPosition = getWorldPosition(character.animationToX, character.animationToY); Vector3 startingPos = character.transform.localPosition; float t = 0.0f; while (t < 1.0f) { t += Time.deltaTime * (Time.timeScale / (secondsPerSquare * Mathf.Abs(character.animationToY - character.animationFromY))); float newY = Mathf.Lerp(startingPos.y, newWorldPosition.y, t); character.transform.localPosition = new Vector3(character.transform.localPosition.x, newY, character.transform.localPosition.z); yield return(0); } } }
private bool tryGetCharacter(string[] names, out FightCharacter[] characters) { FightCharacter[] AllFightCharacter = new FightCharacter[names.Length]; for (int i = 0; i < names.Length; ++i) { if (tryGetCharacter(names [i], out AllFightCharacter [i])) { if ((i + 1) == names.Length) { characters = AllFightCharacter; return(true); } } else { break; } } characters = null; return(false); }
public static string GetFightCharacterDamageTakenTooltip(this FightCharacter fightCharacter, string title, int displayIndex, double?percentOfTotal, double?percentOfMax) => $@"{displayIndex}. {title} {fightCharacter.TotalDamageTaken:N0} total dmg {percentOfTotal.FormatPercent()} of fight's total dmg {percentOfMax.FormatPercent()} of fight's max dmg {fightCharacter.WeaponDamageTakenPM.Format()} ({fightCharacter.WeaponPercentOfTotalDamageTaken.FormatPercent()}) weapon dmg / min {fightCharacter.NanoDamageTakenPM.Format()} ({fightCharacter.NanoPercentOfTotalDamageTaken.FormatPercent()}) nano dmg / min {fightCharacter.IndirectDamageTakenPM.Format()} ({fightCharacter.IndirectPercentOfTotalDamageTaken.FormatPercent()}) indirect dmg / min {fightCharacter.TotalDamageTakenPM.Format()} total dmg / min {(fightCharacter.HasIncompleteMissStats ? "≤ " : "")}{fightCharacter.WeaponHitTakenChance.FormatPercent()} weapon hit chance {fightCharacter.CritTakenChance.FormatPercent()} crit chance {fightCharacter.GlanceTakenChance.FormatPercent()} glance chance {(fightCharacter.HasIncompleteMissStats ? "≤ " : "")}{fightCharacter.WeaponHitAttemptsTakenPM.Format()} weapon hit attempts / min {fightCharacter.WeaponHitsTakenPM.Format()} weapon hits / min {fightCharacter.CritsTakenPM.Format()} crits / min {fightCharacter.GlancesTakenPM.Format()} glances / min {fightCharacter.NanoHitsTakenPM.Format()} nano hits / min {fightCharacter.IndirectHitsTakenPM.Format()} indirect hits / min {fightCharacter.TotalHitsTakenPM.Format()} total hits / min {fightCharacter.AverageWeaponDamageTaken.Format()} weapon dmg / hit {fightCharacter.AverageCritDamageTaken.Format()} crit dmg / hit {fightCharacter.AverageGlanceDamageTaken.Format()} glance dmg / hit {fightCharacter.AverageNanoDamageTaken.Format()} nano dmg / hit {fightCharacter.AverageIndirectDamageTaken.Format()} indirect dmg / hit" + (!fightCharacter.HasSpecialsTaken ? null : $@" {fightCharacter.GetSpecialsTakenInfo()}") + (fightCharacter.HitsAbsorbed == 0 ? null : $@" {fightCharacter.DamageAbsorbed:N0} dmg absorbed {fightCharacter.HitsAbsorbedPM.Format()} hits absorbed / min {fightCharacter.DamageAbsorbedPM.Format()} dmg absorbed / min {fightCharacter.AverageDamageAbsorbed.Format()} dmg absorbed / hit");
public static string GetFightCharacterDamageDoneTooltip(this FightCharacter fightCharacter, string title, int displayIndex, double?percentOfTotal, double?percentOfMax) => $@"{displayIndex}. {title} {fightCharacter.TotalDamageDonePlusPets:N0} total dmg {percentOfTotal.FormatPercent()} of fight's total dmg {percentOfMax.FormatPercent()} of fight's max dmg {fightCharacter.WeaponDamageDonePMPlusPets.Format()} ({fightCharacter.WeaponPercentOfTotalDamageDonePlusPets.FormatPercent()}) weapon dmg / min {fightCharacter.NanoDamageDonePMPlusPets.Format()} ({fightCharacter.NanoPercentOfTotalDamageDonePlusPets.FormatPercent()}) nano dmg / min {fightCharacter.IndirectDamageDonePMPlusPets.Format()} ({fightCharacter.IndirectPercentOfTotalDamageDonePlusPets.FormatPercent()}) indirect dmg / min {fightCharacter.TotalDamageDonePMPlusPets.Format()} total dmg / min {(fightCharacter.HasIncompleteMissStatsPlusPets ? "≤ " : "")}{fightCharacter.WeaponHitDoneChancePlusPets.FormatPercent()} weapon hit chance {fightCharacter.CritDoneChancePlusPets.FormatPercent()} crit chance {fightCharacter.GlanceDoneChancePlusPets.FormatPercent()} glance chance {(fightCharacter.HasIncompleteMissStatsPlusPets ? "≥ " : "")}{fightCharacter.WeaponHitAttemptsDonePMPlusPets.Format()} weapon hit attempts / min {fightCharacter.WeaponHitsDonePMPlusPets.Format()} weapon hits / min {fightCharacter.CritsDonePMPlusPets.Format()} crits / min {fightCharacter.GlancesDonePMPlusPets.Format()} glances / min {fightCharacter.NanoHitsDonePMPlusPets.Format()} nano hits / min {fightCharacter.IndirectHitsDonePMPlusPets.Format()} indirect hits / min {fightCharacter.TotalHitsDonePMPlusPets.Format()} total hits / min {fightCharacter.AverageWeaponDamageDonePlusPets.Format()} weapon dmg / hit {fightCharacter.AverageCritDamageDonePlusPets.Format()} crit dmg / hit {fightCharacter.AverageGlanceDamageDonePlusPets.Format()} glance dmg / hit {fightCharacter.AverageNanoDamageDonePlusPets.Format()} nano dmg / hit {fightCharacter.AverageIndirectDamageDonePlusPets.Format()} indirect dmg / hit" + (!fightCharacter.HasSpecialsDone ? null : $@" {fightCharacter.GetSpecialsDoneInfo()}") + (fightCharacter.HealthDrained == 0 ? null : $@" {fightCharacter.HealthDrainedPM.Format()} health drained / min {fightCharacter.NanoDrainedPM.Format()} nano drained / min");
public static string GetCharacterTooltip(this FightCharacter fightCharacter, int?displayIndex = null) => fightCharacter.Character.GetCharacterTooltip(displayIndex);
private float horizontalMoveAnimationDuration(FightCharacter character) { return(Mathf.Abs(character.animationFromX - character.animationToX) * secondsPerSquare); }
private float moveAnimationDuration(FightCharacter character) { return(horizontalMoveAnimationDuration(character) + verticalMoveAnimationDuration(character)); }
private IEnumerator moveAnimation(FightCharacter character, bool horizontalFirst) { int startDirection = character.animatorScript.GetFacing(); int verticalDirection, horizontalDirection; if (character.animationToX > character.animationFromX) { horizontalDirection = character.animatorScript.RIGHT; } else if (character.animationToX < character.animationFromX) { horizontalDirection = character.animatorScript.LEFT; } else { horizontalDirection = startDirection; } if (character.animationToY > character.animationFromY) { verticalDirection = character.animatorScript.UP; } else if (character.animationToY < character.animationFromY) { verticalDirection = character.animatorScript.DOWN; } else { verticalDirection = startDirection; } character.animatorScript.Walk(); if (horizontalFirst) { character.animatorScript.Face(horizontalDirection); float animationDuration = horizontalMoveAnimationDuration(character); StartCoroutine(horizontalMoveAnimation(character)); yield return(new WaitForSeconds(animationDuration)); character.animatorScript.Face(verticalDirection); animationDuration = verticalMoveAnimationDuration(character); StartCoroutine(verticalMoveAnimation(character)); yield return(new WaitForSeconds(animationDuration)); } else { character.animatorScript.Face(verticalDirection); float animationDuration = verticalMoveAnimationDuration(character); StartCoroutine(verticalMoveAnimation(character)); yield return(new WaitForSeconds(animationDuration)); character.animatorScript.Face(horizontalDirection); animationDuration = horizontalMoveAnimationDuration(character); StartCoroutine(horizontalMoveAnimation(character)); yield return(new WaitForSeconds(animationDuration)); } character.animatorScript.Face(startDirection); character.animatorScript.Idle(); }
// returns join animation duration private float playJoinAnimation(FightCharacter character) { StartCoroutine(moveAnimation(character, false)); return(moveAnimationDuration(character)); }
public DamageTakenViewingModeDetailRow(FightViewModel fightViewModel, FightCharacter fightCharacter) : base(fightViewModel, fightCharacter, showIcon: true) { }
public FightCharacterMainRowBase(FightViewModel fightViewModel, FightCharacter fightCharacter) : base(fightViewModel) => FightCharacter = fightCharacter;
public DamageTakenInfoDetailRow(FightViewModel fightViewModel, FightCharacter target, FightCharacter source) : base(fightViewModel, source) { Target = target; Source = source; }
private float verticalMoveAnimationDuration(FightCharacter character) { return(Mathf.Abs(character.animationFromY - character.animationToY) * secondsPerSquare); }
public DamageTakenMainRow(FightViewModel fightViewModel, FightCharacter fightCharacter) : base(fightViewModel, fightCharacter) { }
public OwnersHealingDoneDetailRow(FightViewModel fightViewModel, FightCharacter source, FightCharacter target) : base(fightViewModel, source) { Source = source; Target = target; }
public FightCharacterDetailRowBase(FightViewModel fightViewModel, FightCharacter fightCharacter, bool showIcon = false) : base(fightViewModel, showIcon) => FightCharacter = fightCharacter;
public static string GetSpecialsTakenInfo(this FightCharacter fightCharacter) => string.Join(Environment.NewLine, DamageTypeHelpers.SpecialDamageTypes .Where(t => fightCharacter.HasDamageTypeDamageTaken(t)) .Select(t => $@"{fightCharacter.GetAverageDamageTypeDamageTaken(t).Value.Format()} dmg" + $", {fightCharacter.GetSecondsPerDamageTypeHitTaken(t).Value.Format()} secs / {t.GetName()}"));
public static string GetDamageTypesTakenInfo(this FightCharacter fightCharacter) => string.Join(Environment.NewLine, DamageTypeHelpers.AllDamageTypes .Where(fightCharacter.HasDamageTypeDamageTaken) .OrderByDescending(fightCharacter.GetDamageTypeDamageTaken) .Select(t => $@"{fightCharacter.GetPercentDamageTypeDamageTaken(t).FormatPercent()} {t.GetName()} dmg, {fightCharacter.GetPercentDamageTypeHitsTaken(t).FormatPercent()} of hits"));
public DamageDoneInfoDetailRow(FightViewModel fightViewModel, FightCharacter source, FightCharacter target) : base(fightViewModel, source) { Source = source; Target = target; }
public DamageDoneDetailRow(FightViewModel fightViewModel, FightCharacter fightCharacter) : base(fightViewModel, fightCharacter) { }
public OwnersHealingTakenDetailRow(FightViewModel fightViewModel, FightCharacter source) : base(fightViewModel, source) => Source = source;