Esempio n. 1
0
 /// <summary>
 /// Should be called after damage is dealt to ensure a check is run for combat end.
 /// </summary>
 private void CheckForCombatEnd()
 {
     // Iterates through the combat queue to find if any new characters died.
     foreach (Character character in combatQueue)
     {
         bool isDead = character.CheckForDeath();
         if (isDead)
         {
             CombatLog.AddMessageToQueue(character.CharacterName + " has died!");
         }
     }
     // Checks to see if the combat end requiriments have been reached.
     if (combatQueue.Any(combatant => combatant.PlayerControlled && combatant.IsAlive))
     {
         if (combatQueue.Any(combatant => !combatant.PlayerControlled && combatant.IsAlive))
         {
             // Battle continues
             return;
         }
         else
         {
             // Victory
             EndCombat(true);
         }
     }
     else
     {
         // The party loses
         EndCombat(false);
     }
 }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     CombatLog.AddMessageToQueue("The party has entered combat.");
     // Roll initiative for all the combatants at the first frame and place them in the combat queue accordingly
     combatQueue = combatQueue.OrderByDescending(combatant => combatant.Initiative).ToList();
     CombatLog.AddMessageToQueue("Initiative rolled");
     nextActiveCharacterIndex = 0;
 }
Esempio n. 3
0
 /// <summary>
 /// Needs to be called to progress the combat queue.
 /// If the next character is dead, it proceeds to the next one without needing to be called again.
 /// </summary>
 private void NextActiveCharacter()
 {
     do
     {
         activeCharacter          = combatQueue[nextActiveCharacterIndex];
         nextActiveCharacterIndex = (nextActiveCharacterIndex + 1) % combatQueue.Count(); // Go through the list, rotating between the combatants
     } while (!activeCharacter.IsAlive);
     CombatLog.AddMessageToQueue("It's " + activeCharacter.CharacterName + "'s turn!");
 }
Esempio n. 4
0
 public void Cast(List <Character> Targets)
 {
     foreach (Character target in Targets)
     {
         int value = new Die(Effect.Amount).RollDie();
         target.Heal(value);
         CombatLog.AddMessageToQueue(target.CharacterName + " was healed for " + value + " hitpoints!");
     }
 }
Esempio n. 5
0
    /// <summary>
    /// Needs to be called when a character wants to move and returns true if able.
    /// </summary>
    /// <param name="distance">The distance in unity units(meters)</param>
    /// <returns>Returns true if the character can move or false if not.</returns>
    public bool ActiveCharacterMoves(double distance)
    {
        bool canMove = activeCharacter.Move(distance);

        if (!canMove)
        {
            CombatLog.AddMessageToQueue(activeCharacter.CharacterName + " can't move that far this round!");
        }
        return(canMove);
    }
Esempio n. 6
0
 /// <summary>
 /// Needs to be called when a character wants to attack.
 /// </summary>
 /// <param name="weapon">The equipped weapon</param>
 /// <param name="target">The target of the attack</param>
 internal void ActiveCharacterAttacks(Weapon weapon, Character target, double distance)
 {
     if (weapon.Range >= HelperFunctions.MetersToFeet(distance))
     {
         activeCharacter.Attack(weapon, target);
         CheckForCombatEnd();
     }
     else
     {
         CombatLog.AddMessageToQueue("Not enough range to attack!");
     }
 }