//Helper function to calculate defense resistance for damage calculation protected virtual float CalcResistDamage(IBattle attacker, float damage) { float typeMod = 1; if (currentType != IType.ElementType.NoType) { typeMod = statModifiers[(int)currentType, 1]; } float defense = baseStats[1] * typeMod; if (attacker.currentType == this.currentType) { //Reduce damage defense *= 1.25f; } for (int i = 0; i < turnEffects.Count; i++) { if (turnEffects[i].statType == IType.Stat.Defense) { defense *= turnEffects[i].value; if (attacker.currentType == turnEffects[i].elementType) { defense *= 1.25f; } } } damage /= defense; return(damage); }
/// <summary> /// 获取一个战场 /// </summary> /// <param name="id"></param> /// <returns></returns> static public IBattle GetBattle(Int64 id) { IBattle battle = null; battleMap.TryGetValue(id, out battle); return(battle); }
/// <summary> /// calculate NPC hit points based on battle mode /// </summary> /// <returns>NPC hit points</returns> private int CalculateNpcHitPoints(IBattle battleNpc) { int battleNpcHitPoints = 0; switch (NpcBattleResponse()) { case BattleModeName.ATTACK: battleNpcHitPoints = battleNpc.Attack(); break; case BattleModeName.DEFEND: battleNpcHitPoints = battleNpc.Defend(); break; case BattleModeName.RETREAT: battleNpcHitPoints = battleNpc.Retreat(); break; } if (_player.SpecialArmor == Player.Armor.High) { battleNpcHitPoints -= 2; } if (_player.SpecialArmor == Player.Armor.High) { battleNpcHitPoints -= 1; } return(battleNpcHitPoints); }
//Add Creature passed in to battle public bool AddCreature(GameObject obj, bool isEnemy) { bool canAdd = false; IBattle objComp = obj.GetComponent <IBattle>(); if (isEnemy) { for (int i = 0; i < 3; i++) { if (!enemies[i]) { enemiesAdded++; canAdd = true; objComp.OnBattleStart(i); objComp.inBattle = true; objComp.currentBattleArea = this; SetEnemy(obj, i); break; } } } else { //Save for summons } return(canAdd); }
public void InitBotBattle() { var userUnit = new BattleUnit() { UserName = Context.User.Identity.Name, ID = User.UserId, Bot = false, Characteristics = ChService.GetFullUserCharacteristics(User.UserId) }; var bot = new BattleUnit() { UserName = "******", ID = Guid.NewGuid().ToString(), Bot = true, Characteristics = ChService.GetFullUserCharacteristics(User.UserId) }; bot.Characteristics.Armor_head = 2; IBattle battle = Factory.Battle(userUnit, bot); Groups.Add(Context.ConnectionId, battle.ID).Wait(); Engine.RegisterBattle(battle); Clients.Group(battle.ID).battleRegistered(battle.ID); // TODO: Modify batle! It should know who must be next. //Clients.Group(battle.ID).sendData(battle.ID); //Information about user. It should send who will start battle }
public void Do(IBattle battle, IHeroFSM selfFSM, IHeroFSM targetFSM) { selfFSM.HeroGraphic.Trans.DOKill(); var pos = battle.World.GetPlayerPos(selfFSM.ID); selfFSM.HeroGraphic.Trans.DOMove(pos, (float)this.skillEvent.DoubleParams0 / 30f); }
//Update enemy UI in battle (updates health/energy) private void UpdateEnemyBar(bool[] alive, GameObject UI, int index) { if (alive[index]) { if (UI.activeSelf) { //Update Bar IBattle enemyScript = player.GetComponent <PlayerManager>().currentBattleArea.GetEnemyScripts()[index]; if (enemyScript) { enemyHealthBarImages[index].GetComponent <Image>().fillAmount = enemyScript.GetHealth() / enemyScript.MAX_HEALTH; enemyEnergyBarImages[index].GetComponent <Image>().fillAmount = enemyScript.GetEnergy() / enemyScript.MAX_ENERGY; enemyHealthBarText[index].GetComponent <Text>().text = Mathf.Ceil(enemyScript.GetHealth()).ToString(); enemyEnergyBarText[index].GetComponent <Text>().text = Mathf.Ceil(enemyScript.GetEnergy()).ToString(); } } else { UI.SetActive(true); } } else { if (UI.activeSelf) { UI.SetActive(false); } } }
//Trigger Debuffs/DoT for given creature private void LowerEffects(IBattle obj) { for (int j = obj.turnEffects.Count - 1; j >= 0; j--) { if (obj.turnEffects[j].numUses - 1 <= 0) { //remove obj.turnEffects.RemoveAt(j); } else { obj.turnEffects[j].numUses -= 1; } } for (int j = obj.turnDamage.Count - 1; j >= 0; j--) { if (obj.turnDamage[j].numUses - 1 <= 0) { //remove obj.turnDamage.RemoveAt(j); } else { obj.turnDamage[j].numUses -= 1; } } }
private int CalculateNpcHitPoints(IBattle battleNpc) { int battleNpcHitPoints = 0; if (battleNpc is Enemy /*playerHitPoints >= battleNpcHitPoints*/) { Enemy battlingNpc = _currentNpc as Enemy; switch (NpcBattleResponse()) { case BattleModeName.ATTACK: battleNpcHitPoints = battleNpc.Attack(); break; case BattleModeName.DEFEND: battleNpcHitPoints = battleNpc.Defend(); break; case BattleModeName.RETREAT: battleNpcHitPoints = battleNpc.Retreat(); break; } } return(battleNpcHitPoints); }
public BattleResult Execute(IMessage message) { if (message == null) { throw new ArgumentNullException("message"); } IBattle battle = ValidateAndGet(message); if (battle != null) { PreExecution(message, battle); IExecutableMessage execMessage = message as IExecutableMessage; if (execMessage != null) { execMessage.Execute(battle); } PostExecution(message, battle); var result = battle.GetResult(); Dictionary <string, Reward> reward = null; if (battle.Status == BattleStatus.Killed) { UnregisterBattle(battle.ID); reward = GenerateReward(battle); } return(new BattleResult() { Result = result, UserSpecificReward = reward, UsersStates = battle.Units }); } throw new ArgumentException("message"); //change to a custom error }
private IBattle ValidateAndGet(IMessage message) { IBattle battle = null; Battles.TryGetValue(message.BattleId, out battle); return(battle); }
/// <summary> /// battle method /// </summary> private void Battle() { if (_currentNPC is IBattle) { IBattle battleNPC = _currentNPC as IBattle; int playerHitPoints = 0; int battleNpcHitPoints = 0; playerHitPoints = CalculatePlayerHitPoints(); battleNpcHitPoints = CalculateNPCHitPoints(battleNPC); //bool battling = false; //do //{ // CurrentLocationInformation = // $"Player: {_player.BattleMode} Hit Points: {playerHitPoints}" + Environment.NewLine + // $"NPC: {battleNPC.BattleMode} Hit Points: {battleNpcHitPoints}" + Environment.NewLine; //} while (!battling); if (playerHitPoints >= battleNpcHitPoints) { _currentLocation.NPCS.Remove(_currentNPC); DetermineRewards(); } else { DetermineLosses(); } } else { CurrentLocationInformation = "It seems the enemy is not ready to meet us in battle, try again later."; } }
public EffectContext(IBattle battle, IBattlePokemon user, IMove move, IReadOnlySet <IBattlePokemon> targets) { Battle = battle; User = user; Move = move; Targets = targets; }
protected BattleEvent(IBattle battle, ICombatant combatant, IntVector2 startPosition, IntVector2 endPosition) { Battle = battle; Combatant = combatant; StartPosition = startPosition; EndPosition = endPosition; }
private void Battle() { // check to see if an NPC can battle if (_currentNpc is IBattle) { IBattle battleNpc = _currentNpc as IBattle; int playerHitPoints = 0; int battleNpcHitPoints = 0; string battleInformation = ""; // caculate hit points if the player and NPC have weapons if (_player.CurrentWeapon != null) { playerHitPoints = CalculatePlayerHitPoints(); } else { battleInformation = "It appears you are entering into a battle without a weapon."; } if (battleNpc.CurrentWeapon != null) { battleNpcHitPoints = CaculateNpcHitPoints(battleNpc); } else { battleInformation = $"It appears you are entering into battle with {_currentNpc.Name} who has no weapon."; } // build out the text for the current location information battleInformation += $"Player: {_player.BattleMode} Hit Points: {playerHitPoints}" + Environment.NewLine + $"NPC: {battleNpc.BattleMode} Hit Points: {battleNpcHitPoints}" + Environment.NewLine; // deterrmine results of battle if (playerHitPoints >= battleNpcHitPoints) { battleInformation += $"You have killed {_currentNpc.Name}."; _currentLocation.Npcs.Remove(_currentNpc); } else { battleInformation += $"You have killed by {_currentNpc.Name}."; _player.Lives--; } CurrentLocationInformation = battleInformation; if (_player.Lives <= 0) { OnPlayerDies("You have been slain and have no lives left"); } else { CurrentLocationInformation = "The current NPC will is not battle ready. Seems you are a bit jumpy and your experience suffers."; _player.Experience -= 10; } } }
public void Do(IBattle battle, IHeroFSM selfFSM, IHeroFSM targetFSM) { targetFSM.HeroGraphic.PlayAction("behurt"); IEnumeratorTool.StartCoroutine(CheckAniEnd(targetFSM, "behurt", () => { targetFSM.HeroGraphic.PlayAction("idle"); })); }
private void Battle() { if (CurrentNpc is IBattle) { IBattle battleNpc = CurrentNpc as IBattle; int playerHitPoints; int battleNpcHitPoints = 0; string battleInformation = ""; playerHitPoints = CalculatePlayerHitPoints(); if (battleNpc.CurrentWeapon != GameData.GameItemById(1000) as Weapon) { battleNpcHitPoints = CalculateNpcHitPoints(battleNpc); } else { battleInformation = "It appears you are attacking an unarmed assailant" + Environment.NewLine; } battleInformation += $"Player: {Player.BattleMode} Hit Points: {playerHitPoints} " + Environment.NewLine + $"NPC: {battleNpc.BattleMode} Hit Points: {battleNpcHitPoints} " + Environment.NewLine; if (playerHitPoints >= battleNpcHitPoints) { battleInformation += $"You have slain {CurrentNpc.Name}" + Environment.NewLine + "Check the items tab, the slain NPC may have dropped something"; //defeated Npc drops items if (CurrentNpc.Inventory != null) { foreach (var gameItem in CurrentNpc.Inventory) { _currentLocation.AddGameItemToLocation(gameItem); } } if (CurrentNpc.Id == 3003) { _currentLocation.Npcs.Add(GameData.NpcById(1008)); } _currentLocation.Npcs.Remove(CurrentNpc); } else { battleInformation += $"You have been slain by {_currentNpc.Name}"; Player.Lives--; OnPlayerDies("You have been slain."); } CurrentLocationInformation = battleInformation; if (Player.Lives <= 0) { OnPlayerDies("You have been slain."); } } else { CurrentLocationInformation = "The current NPC is not battle ready"; } }
public InflictMoveDamage(IBattle battle, IMove move, Slot user, IEnumerable <Slot> targets) { Battle = battle; this.move = move; User = user; this.targets = new List <Slot>(targets).AsReadOnly(); RandomModifier = 1.0f - (battle.RNG.Next(16) / 100.0f); IsCriticalHit = battle.RNG.NextDouble() < CriticalHitProbability(move.CriticalHitStage); }
private void CreateBattle() { var id = BattleFactory.CreateBattle(battleWorldId: 1); battle = BattleFactory.GetBattle(id); var input = new BattleInput(battle); battle.Input = input; }
private void Awake() { UnitView.Preload(); _battle = new Battle(_unitContainer); _button.onClick.AddListener(GameStart); GameStart(); }
public Inventar(string Text, MainWindow mainWindow, IBattle Object) : this() { label1.Text = Text; this.Object = Object; PictureType = new Dictionary <string, System.Drawing.Bitmap[]>(); comboBox1.Enabled = false; MainWindow = mainWindow; }
// public BattleInput(IBattle battle) { this.battle = battle; cmdCacheList = new List <Cmd>(); InputSate = new DataDrive_Service(); //所有状态 this.InputSate.RegisterData("OnInput"); }
public HeroFSM_TBS(int camp, HeroLogic logic, HeroGraphic graphic, IBattle battle) { this.Camp = camp; this.HeroLogic = logic; this.HeroGraphic = graphic; this.battle = battle; inputProcessMap = new Dictionary <string, Action <List <object> > >(); inputProcessMap["UseSkill"] = OnUseSkill; }
public void DisplayTalkToEnemy(Enemy enemy) { ISpeak speakingEnemy = enemy as ISpeak; string message = speakingEnemy.Speak(); IBattle battlingEnemy = enemy as IBattle; string attackMessage = battlingEnemy.AttackMessage; DisplayGamePlayScreen("Speak to Character", message + "\n " + attackMessage, ActionMenu.AttackMenu, ""); }
public void Dispose() { int count = this._entities.Count; for (int i = 0; i < count; i++) { Entity.Destroy(this._entities[i]); } this.DestroyEnties(); this._battle = null; }
private void Battle() { // check if an NPC can battle if (_currentNPC is IBattle) { IBattle battleNPC = _currentNPC as IBattle; int playerHitPoints = 0; int battleNPCHitPoints = 0; string battleInformation = ""; // calculate hit points if the player and NPC have weapons if (_player.CurrentWeapon != null) { playerHitPoints = CalculatePlayerHitPoints(); } else { battleInformation = "It appears you're entering into battle without a weapon."; } if (battleNPC.CurrentWeapon != null) { battleNPCHitPoints = CalculateNPCHitPoints(battleNPC); } else { battleInformation = $"It appears you're entering into battle with {_currentNPC.Name} who has no weapon."; } // build out text for current location information battleInformation += $"Player: {_player.BattleMode} Hit Points: {playerHitPoints}" + Environment.NewLine + $"NPC: {battleNPC.BattleMode} Hit Points: {battleNPCHitPoints}" + Environment.NewLine; // determine results of battle if (playerHitPoints >= battleNPCHitPoints) { battleInformation += $"You've defeated {_currentNPC.Name}."; _currentLocation.NPCs.Remove(_currentNPC); } CurrentLocationInformation = battleInformation; if (_player.Health <= 0) { OnPlayerDies($"You have been defeated by {_currentNPC.Name}."); } } else { CurrentLocationInformation = "The NPC isn't ready to fight. -10 experience."; _player.ExperiencePoints -= 10; } }
private void Battle() { if (_currentNPC is IBattle) { IBattle battleNPC = _currentNPC as IBattle; int playerHitPoints = _player.Health; int battleNPCHitPoints = 0; string battleInformation = ""; //if (_player.CurrentWeapon != null) //{ // playerHitPoints = CalculatePlayerHitPoints(); //} //else //{ // battleInformation = "You are entering battle without a weapon!"; //} if (battleNPC.CurrentWeapon != null) { battleNPCHitPoints = CalculateNPCHitPoints(battleNPC); } else { battleInformation = $"You are entering battle against {_currentNPC.Name} who appears to be unarmed."; } battleInformation += $"\nPlayer: {_player.BattleMode} Hit Points: {playerHitPoints}" + Environment.NewLine + $"NPC: {battleNPC.BattleMode} Hit Points: {battleNPCHitPoints}" + Environment.NewLine; if (playerHitPoints >= battleNPCHitPoints) { battleInformation += $"You have slain {_currentNPC.Name}"; _currentLocation.NPCs.Remove(_currentNPC); } else { battleInformation += $"You have been slain by {_currentNPC.Name}"; _player.Health = 0; } CurrentLocationInformation = battleInformation; if (_player.Health <= 0) { OnPlayerDies("You have been slain."); } } else { CurrentLocationInformation = "This NPC is angry that you tried to attack them \nand smacked you across the face!"; _player.Health -= 5; } }
public void BeforeEachTest() { _battleMock = new Mock <IBattle>(); _battle = _battleMock.Object; _battleServiceMock = new Mock <IBattleService>(); _battleServiceMock.Setup(service => service.SetupRandomBattle()).Returns(_battle); _window = new MainWindow(_battleServiceMock.Object); _window.Show(); _fightRoundButton = _window.GetPrivateFieldValueByName <Button>("FightRoundButton"); }
public BattleEffect(IBattle attacker, IType.Stat affectedStat, float val, IType.ElementType element, int turnsActive = 3) { statType = affectedStat; value = val; elementType = element; numUses = turnsActive; this.attacker = attacker; if (numUses < 0) { numUses = 0; } }
//Get IBattle scripts of each enemy public IBattle[] GetEnemyScripts() { IBattle[] enemyScripts = new IBattle[3]; for (int i = 0; i < 3; i++) { if (enemies[i]) { enemyScripts[i] = enemies[i].GetComponent <IBattle>(); } } return(enemyScripts); }
private int GetAttackerLossesForBattle(IBattle battle) { return battle.Attackers.Sum(a => a.Key.Cost * a.Value) - battle.SurvivingAttackers.Sum(a => a.Key.Cost * a.Value); }
private int GetDefenderLossesForBattle(IBattle battle) { return battle.Defenders.Sum(a => a.Key.Cost * a.Value) - battle.SurvivingDefenders.Sum(a => a.Key.Cost * a.Value); }