/// <summary> /// Constructor for the Battle Form. Only supports Singleplayer combat atm /// </summary> /// <param name="_listOfChars"></param> /// <param name="_difficulty"></param> public BattleForm(List <Core.Units.Character> _listOfChars, int _difficulty, RPG.Core.PlayerSettings settings) { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; this.BackgroundImage = GeneralFunctions.ResizeImage(Properties.Resources.background, labelBackgroundIGNORE.Size); Function.SoundManager.PlayMain(settings.SoundOn, this, settings.SoundVolume); numberOfPlayers = _listOfChars.Count; battleChars = _listOfChars; int sum = 0; foreach (var item in battleChars) { sum += item.UnitLevel; liveChars.Add(item.UnitName); } int average = (int)(sum / battleChars.Count); enemy = WorldGeneration.GenerateNPC(null, average, _difficulty, EnumMonsterType.Null, battleChars.Count); ai = WorldGeneration.GenerateNPCAI(enemy, battleChars); enemy = ai.ModifiedNPC; foreach (var item in battleChars) { ucCharacterBattle ucb = new ucCharacterBattle(item, battleChars.Count); ucb.AttackClicked += ucb_AttackClicked; flpCharacters.Controls.Add(ucb); } flpNPCs.Controls.Add(new ucNPC(enemy)); }
/// <summary> /// This method generates an NPC, along with a random AI /// </summary> /// <param name="_npcName">The name of the NPC - set to null for generated name</param> /// <param name="_npcLevel">The level the NPC should be</param> /// <param name="_npcType">The Monster Type of the NPC - set to null for generated type</param> /// <param name="_numberOfChars">The amount of targets, that the NPC should go for</param> /// <returns></returns> public static Core.Units.NPC GenerateNPC(string _npcName, int _npcLevel, int _difficulty, EnumMonsterType _npcType, int numberOfChars) { int realLevel = _npcLevel + _difficulty; int expGained = 0; int hp = 0; if (realLevel <= 1) hp = (int)(5 * numberOfChars*1.2 * ((_npcLevel/10)+1)); else if (realLevel == 2) hp = (int)((realLevel * 4) * numberOfChars * 1.2 + (realLevel / 10) * 2); else hp = (int)((realLevel * (realLevel - 1)) * numberOfChars * 1.2 + (_npcLevel / 10) * 2); if (_difficulty == -4) expGained = 0; else if (_difficulty == -2) expGained = (int)(realLevel * 0.5); else if (_difficulty == 0) expGained = realLevel; else if (_difficulty == 2) expGained = (int)(realLevel * 1.2); else if (_difficulty == 4) expGained = (int)(realLevel * 1.5); expGained *= (int)(0.9 + (double)numberOfChars/6.0); Core.Units.NPC returnedNPC = new Core.Units.NPC(_npcName, realLevel, hp, hp, _npcType, expGained, null, null); if (_npcType == EnumMonsterType.Null) returnedNPC.TypeOfNPC = GenerateMonterType(); if (_npcName == null) returnedNPC.UnitName = GenerateMonterName(returnedNPC.TypeOfNPC); return returnedNPC; }
public ucNPC(NPC _npc) { InitializeComponent(); this.BackColor = Color.Transparent; npc = _npc; lbNPCName.Text = npc.UnitName + " the Level " + npc.UnitLevel + " " + npc.TypeOfNPC; labelHealthRemaining.Width = flpHealthBar.Width; labelHealthRemaining.Text = npc.CurrentHP.IntValue + "/" + npc.BuffedHP.IntValue + " (100%)"; foreach (var item in _npc.UnitActiveAbilities) { flpAbilitiesAndPassives.Controls.Add(new ucAbilityIcon(item)); } switch (_npc.TypeOfNPC) { case EnumMonsterType.Dragon: pictureBoxNPC.Image = Properties.Resources.dragon; break; case EnumMonsterType.Humanoid: pictureBoxNPC.Image = Properties.Resources.humanoid; break; case EnumMonsterType.Beast: pictureBoxNPC.Image = Properties.Resources.beast; break; case EnumMonsterType.Undead: pictureBoxNPC.Image = Properties.Resources.undead; break; case EnumMonsterType.Null: break; default: break; } }
/// <summary> /// This is the NPC AI. It is used by using the Run() function. /// </summary> /// <param name="_npc">The NPC this AI is for</param> /// <param name="_aiNumber">The AI to be choosen</param> /// <param name="_targets">The targets the AI should go for</param> public NPCAI(Core.Units.NPC _npc, List <Core.Units.Character> _targets) { int averagelevel = 0; int sum = 0; foreach (var item in _targets) { sum += item.UnitLevel; } averagelevel = (int)((double)sum / (double)_targets.Count); this.npc = _npc; if (averagelevel < 10) { this.aiScript = 0; } else { this.aiScript = r.Next(0, 7); } this.targets = _targets; AddAbilities(); }
/// <summary> /// This is the NPC AI. It is used by using the Run() function. /// </summary> /// <param name="_npc">The NPC this AI is for</param> /// <param name="_aiNumber">The AI to be choosen</param> /// <param name="_targets">The targets the AI should go for</param> public NPCAI(Core.Units.NPC _npc, List<Core.Units.Character> _targets) { int averagelevel = 0; int sum = 0; foreach (var item in _targets) { sum += item.UnitLevel; } averagelevel = (int)((double)sum / (double)_targets.Count); this.npc = _npc; if (averagelevel < 10) { this.aiScript = 0; } else { this.aiScript = r.Next(0, 6); } this.targets = _targets; AddAbilities(); }
/// <summary> /// This method generates an NPC, along with a random AI /// </summary> /// <param name="_npcName">The name of the NPC - set to null for generated name</param> /// <param name="_npcLevel">The level the NPC should be</param> /// <param name="_npcType">The Monster Type of the NPC - set to null for generated type</param> /// <param name="_numberOfChars">The amount of targets, that the NPC should go for</param> /// <returns></returns> public static Core.Units.NPC GenerateNPC(string _npcName, int _npcLevel, int _difficulty, EnumMonsterType _npcType, int numberOfChars) { int realLevel = _npcLevel + _difficulty; int expGained = 0; int hp = 0; if (realLevel <= 1) { hp = (int)(5 * numberOfChars * 1.2 * ((_npcLevel / 10) + 1)); } else if (realLevel == 2) { hp = (int)((realLevel * 4) * numberOfChars * 1.2 + (realLevel / 10) * 2); } else { hp = (int)((realLevel * (realLevel - 1)) * numberOfChars * 1.2 + (_npcLevel / 10) * 2); } if (_difficulty == -4) { expGained = 0; } else if (_difficulty == -2) { expGained = (int)(realLevel * 0.5); } else if (_difficulty == 0) { expGained = realLevel; } else if (_difficulty == 2) { expGained = (int)(realLevel * 1.2); } else if (_difficulty == 4) { expGained = (int)(realLevel * 1.5); } expGained *= (int)(0.9 + (double)numberOfChars / 6.0); Core.Units.NPC returnedNPC = new Core.Units.NPC(_npcName, realLevel, hp, hp, _npcType, expGained, null, null); if (_npcType == EnumMonsterType.Null) { returnedNPC.TypeOfNPC = GenerateMonterType(); } if (_npcName == null) { returnedNPC.UnitName = GenerateMonterName(returnedNPC.TypeOfNPC); } return(returnedNPC); }
public Battle(List <Core.Units.Character> _listOfChars, int _difficulty) { battleChars = _listOfChars; int sum = 0; foreach (var item in battleChars) { sum += item.UnitLevel; } int average = (int)(sum / battleChars.Count); enemy = WorldGeneration.GenerateNPC("", average, _difficulty, EnumMonsterType.Null, battleChars.Count); ai = WorldGeneration.GenerateNPCAI(enemy, battleChars); }
/// <summary> /// This function generates a random NPC AI based on the NPC, an integer and a list of it's possible targets. /// </summary> /// <param name="npc">The NPC to generate from</param> /// <param name="random">Make it a random ai (true) or base it on the NPC type</param> /// <param name="_characters">The targets for the NPC</param> /// <returns></returns> public static NPCAI GenerateNPCAI(Core.Units.NPC npc, List <Character> _characters) { NPCAI ai = new NPCAI(npc, _characters); return(ai); }