public IEnumerator RunCombat() { while (attackQueue.Length() > 0) { CombatResponse attack = attackQueue.Next(); Debug.DrawLine(attack.Self.transform.position, player.transform.position); switch (attack.AttackType) { case "Slash": AddIndicator(attack.Self, Color.red); break; case "Parry": AddIndicator(attack.Self, Color.yellow); break; case "Feint": AddIndicator(attack.Self, Color.blue); break; } yield return(new WaitForSeconds(1)); FillAnimQueue(attack); } if (!Animating) { StartCoroutine(ExecuteCombat()); } }
public void Add(CombatResponse attack) { if (!IsLock) { combatQueue.Add(attack); } }
public int Battle(CombatResponse defender) { if (DirCheck(this.HorizDir, defender.HorizDir) && DirCheck(this.VertDir, defender.VertDir)) { return(SingletonsCreator.SingleMoveSetTable().Compare(this.AttackType, defender.AttackType)); } else { return(-1); } }
private CombatResponse DoMeleeAttack() { var cResponse = new CombatResponse(); try { var victim = SelectRandomPlayer(); var attackRoll = GetAttackRoll(); var Damage = GetDamageRoll(); int victimToHitValue = victim.Thaco.Value - CharacterCombatMaths.CalculateArmorClass(victim.EquippedGear); if (attackRoll < victimToHitValue) { // Missses cResponse.response = string.Format($"{CurrentPlayer().Name}'s attack misses against {victim.Name}"); cResponse.ResponseType = CombatResponseTypes.MISSED; } else { // Hits cResponse.response = string.Format($"{CurrentPlayer().Name} deals {Damage} damage to {victim.Name}"); cResponse.ResponseType = CombatResponseTypes.DAMAGED; if (victim.TmpHitPoints - Damage <= 0) { cResponse.response = string.Format($"{CurrentPlayer().Name} kills {victim.Name}"); cResponse.ResponseType = CombatResponseTypes.KILLED; } members = DoDamage(victim, Damage); } } catch (InvalidCombatMechanicException ex) { cResponse.success = false; cResponse.response = ex.Message; } /* * Console.WriteLine($"-- {CurrentPlayer().Name}'s Turn --"); * Console.WriteLine($" (HP: {CurrentPlayer().TmpHitPoints}/{CurrentPlayer().HitPoints} AC: {CurrentPlayer().ArmorClass})"); * Console.WriteLine($" Attacking: {victim.Name}"); * Console.WriteLine($" Weapon: {CurrentPlayer().PrimaryWeapon.Name} ({CurrentPlayer().PrimaryWeapon.Damage.Amount}d{CurrentPlayer().PrimaryWeapon.Damage.SidedDie})"); * Console.WriteLine($" Roll: {attackRoll} (need to match or beat {victimToHitValue})"); * Console.WriteLine($" Damage: {Damage}"); */ return(cResponse); }
public CombatResponse Next() { if (combatQueue.Count > 0) { CombatResponse firstItem = combatQueue[0]; combatQueue.RemoveAt(0); return(firstItem); } else { throw new System.Exception("Combat Queue is empty!"); } }
public CombatResponse Attack(CombatResponse expected) { var player = expected.Player; var npc = expected.Npc; var damage = initiative.Next((int)player.MinDamage, (int)player.MaxDamage); //npc.CurrentHealth = Convert.ToInt32((npc.CurrentHealth - ((damage / (double)100) * npc.AC))); npc.CurrentHealth = Convert.ToInt32(npc.CurrentHealth - ((damage / npc.AC))); if (npc.CurrentHealth <= 0) { npc.CurrentHealth = 0; } return(expected); }
public static CombatResponse MeleeAttack(ICharacter person, ICharacter target, IWeapon specificWeapon = null) { CombatResponse resp = new CombatResponse(); try { _person = person; _target = target; if (specificWeapon != null) { _specificWeapon = specificWeapon; } int attackRoll = GetAttackRoll(); int targetToHitValue = target.Thaco.Value - CharacterCombatMaths.CalculateArmorClass(target.EquippedGear); if (attackRoll < targetToHitValue) { // Attack missed resp.response = string.Format($"{person.Name}'s attack misses against {target.Name}"); resp.ResponseType = CombatResponseTypes.MISSED; } else { // Attack Hit int Damage = GetMeleeDamageTotal(); resp.response = string.Format($"{person.Name} deals {Damage} damage to {target.Name}"); resp.ResponseType = CombatResponseTypes.DAMAGED; if (target.TmpHitPoints <= 0) { resp.response = string.Format($"{person.Name} deals {Damage} and kills {target.Name}"); resp.ResponseType = CombatResponseTypes.KILLED; } target = DoDamageToTarget(Damage); } resp.success = true; } catch (InvalidCombatMechanicException ex) { resp.success = false; resp.response = ex.Message; } return(resp); }
public void FillAnimQueue(CombatResponse attack) { if (defenseQueue.Length() > 0) { CombatResponse defense = defenseQueue.Next(); bool victor = attack.Battle(defense); if (victor == WIN) { animQueue.Add(new AnimationBean(attack.AttackType, defense.AttackType, WIN, attack.Self.GetComponent <EnemyLogic>())); } else { animQueue.Add(new AnimationBean(attack.AttackType, defense.AttackType, LOSE, attack.Self.GetComponent <EnemyLogic>())); } } else { animQueue.Add(new AnimationBean(attack.AttackType, "nothing", LOSE, attack.Self.GetComponent <EnemyLogic>())); } }