// Initializes the Battle to begin public bool StartBattle(bool isAutoBattle) { if (!isAutoBattle) { BattleEngineClearData(); BattleScore.AutoBattle = false; } else { BattleScore = new Score(); BattleScore.AutoBattle = true; BattleMessages = new BattleMessages(); ItemPool.Clear(); MonsterList.Clear(); //do not clear char list bc this has already been populated } isBattleRunning = true; // Characters not Initialized, so false start... if (CharacterList.Count < 1) { return(false); } return(true); }
// Sets the new state for the variables for Battle public void BattleEngineClearData() { BattleScore = new Score(); BattleMessages = new BattleMessages(); RoundStateEnum = RoundEnum.NewRound; ItemPool.Clear(); MonsterList.Clear(); CharacterList.Clear(); // Reset current player PlayerCurrent = null; }
// Sets the new state for the variables for Battle public void BattleEngineClearData() { // Create a score object BattleScore = new Score(); // Create a BattleMessages object BattleMessage = new BattleMessages(); // Clear the lists ItemPool.Clear(); MonsterList.Clear(); CharacterList.Clear(); // Reset current player PlayerCurrent = null; }
// Sets the new state for the variables for Battle private void BattleEngineClearData() { BattleScore = new Score(); BattleMessages = new BattleMessages(); ItemPool.Clear(); MonsterList.Clear(); CharacterList.Clear(); HealAllCharactersAndMonsters(); // Reset current player PlayerCurrent = null; }
/// <summary> /// Swap the Item the character has for one from the pool /// /// Drop the current item back into the Pool /// /// </summary> /// <param name="character"></param> /// <param name="setLocation"></param> /// <param name="PoolItem"></param> /// <returns></returns> private ItemModel SwapCharacterItem(CharacterModel character, ItemLocationEnum setLocation, ItemModel PoolItem) { // Put on the new ItemModel, which drops the one back to the pool var droppedItem = character.AddItem(setLocation, PoolItem); // Update BattleMessage BattleMessages.AddItemEquipped(character.Name, PoolItem.Name); // Remove the ItemModel just put on from the pool ItemPool.Remove(PoolItem); if (droppedItem != null) { // Add the dropped ItemModel to the pool ItemPool.Add(droppedItem); } return(droppedItem); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { discardMessage = GetNode <Control>("DiscardMessage"); instance = this; }
/// <summary> /// Process the attack. Use BattleMessagesModel to communicate actions. /// </summary> /// <param name="attacker"></param> /// <param name="target"></param> /// <returns></returns> public bool TurnAsAttack(BattleEntityModel attacker, BattleEntityModel target) { if (attacker == null) { return(false); } if (target == null) { return(false); } // refresh battle messages for turn BattleMessages.ClearMessages(); // Hackathon // Hackathon Scenario 2, Bob alwasys misses if (attacker.Name.Equals("Bob")) { BattleMessages.HitStatus = HitStatusEnum.Miss; BattleMessages.TurnMessage = "Bob always Misses"; Debug.WriteLine(BattleMessages.TurnMessage); return(true); } BattleMessages.PlayerType = EntityTypeEnum.Monster; var AttackScore = GetAttack(attacker); var DefenseScore = GetDefense(target); // Choose who to attack BattleMessages.TargetName = target.Name; BattleMessages.AttackerName = attacker.Name; BattleMessages.HitStatus = RollToHitTarget(AttackScore, DefenseScore); Debug.WriteLine(BattleMessages.GetTurnMessage()); // It's a Miss if (BattleMessages.HitStatus == HitStatusEnum.Miss) { BattleMessages.TurnMessage = attacker.Name + " blunders and misses " + target.Name; // Check if Critical Miss is enabled (hackathon rule) if (CriticalMissEnabled) { if (BattleMessages.CriticalMiss) { CriticalMiss(attacker); BattleMessages.TurnMessage += BattleMessages.CriticalMissMessage; // toggle flag BattleMessages.CriticalMiss = false; } } Debug.WriteLine(BattleMessages.TurnMessage); return(true); } // It's a Hit if (BattleMessages.HitStatus == HitStatusEnum.Hit) { //Calculate Damage BattleMessages.DamageAmount = GetDamage(attacker); // Calculate Critical Hit if enabled if (CriticalHitsEnabled) { if (BattleMessages.CriticalHit) { BattleMessages.DamageAmount *= 2; } } if (target.EntityType == EntityTypeEnum.Monster) { double FractionalExperience = (double)BattleMessages.DamageAmount / (double)target.MaxHealth; int ExperienceGained = (int)Math.Ceiling(FractionalExperience * (double)target.ExperiencePoints); TakeDamage(target, BattleMessages.DamageAmount); // If monster takes damage he loses proportional amount of remaining experience points to attacker AddExperience(attacker, ExperienceGained); target.ExperiencePoints -= ExperienceGained; } else { TakeDamage(target, BattleMessages.DamageAmount); } } // update battle messages BattleMessages.CurrentHealth = target.CurrentHealth; BattleMessages.AttackStatus = " strikes "; BattleMessages.TurnMessage = attacker.Name + BattleMessages.AttackStatus + target.Name + BattleMessages.GetCurrentHealthMessage(); if (CriticalHitsEnabled) { if (BattleMessages.CriticalHit) { BattleMessages.TurnMessage += "\nCritical Hit!!!"; BattleMessages.CriticalHit = false; // toggle flag } } Debug.WriteLine(BattleMessages.TurnMessage); RemoveIfDead(target); return(true); }