/// <summary> /// Process shot will throw an exception in the case of AI error resulting in a square being hit twice /// </summary> /// <param name="result">The result of the shot</param> /// <param name="row">the row shot</param> /// <param name="col">the column shot</param> protected override void ProcessShot(int row, int col, AttackResult result) { if (result.Value == ResultOfAttack.ShotAlready) { throw new ApplicationException("Error in AI"); } }
/// <summary> /// ProcessShot will be called uppon when a ship is found. /// It will create a stack with targets it will try to hit. These targets /// will be around the tile that has been hit. /// </summary> /// <param name="row">the row it needs to process</param> /// <param name="col">the column it needs to process</param> /// <param name="result">the result og the last shot (should be hit)</param> protected override void ProcessShot(int row, int col, AttackResult result) { if (result.Value == ResultOfAttack.Hit) { _CurrentState = AIStates.Searching; } else if (result.Value == ResultOfAttack.ShotAlready) { throw new ApplicationException("Error in AI"); } }
/// <summary> /// ProcessShot will be called uppon when a ship is found. /// It will create a stack with targets it will try to hit. These targets /// will be around the tile that has been hit. /// </summary> /// <param name="row">the row it needs to process</param> /// <param name="col">the column it needs to process</param> /// <param name="result">the result og the last shot (should be hit)</param> protected override void ProcessShot(int row, int col, AttackResult result) { if (result.Value == ResultOfAttack.Hit) { _CurrentState = AIStates.TargetingShip; AddTarget(row - 1, col); AddTarget(row, col - 1); AddTarget(row + 1, col); AddTarget(row, col + 1); } else if (result.Value == ResultOfAttack.ShotAlready) { throw new ApplicationException("Error in AI"); } }
public void Show(AttackResult result) { gameObject.SetActive(true); labelNumber.color = result.IsCritical ? Color.red : Color.white; transform.localScale = Vector3.one * 4; tween.DORewind(); tween.DOPlayForward(); if (!result.IsDodge) { Show(result.Damage.ToString()); } else { Show("Miss"); } }
/// <summary> /// The AI takes its attacks until its go is over. /// </summary> /// <returns>The result of the last attack</returns> public override AttackResult Attack() { AttackResult result = default(AttackResult); int row = 0; int column = 0; //keep hitting until a miss do { Delay(); GenerateCoords(ref row, ref column); //generate coordinates for shot result = _game.Shoot(row, column); //take shot ProcessShot(row, column, result); } while (result.Value != ResultOfAttack.Miss && result.Value != ResultOfAttack.GameOver && !SwinGame.WindowCloseRequested()); return(result); }
/// <summary> /// Shoot at a given row/column /// </summary> /// <param name="row">the row to attack</param> /// <param name="col">the column to attack</param> /// <returns>the result of the attack</returns> internal AttackResult Shoot(int row, int col) { _shots += 1; AttackResult result = default(AttackResult); result = EnemyGrid.HitTile(row, col); switch (result.Value) { case ResultOfAttack.Destroyed: case ResultOfAttack.Hit: _hits += 1; break; case ResultOfAttack.Miss: _misses += 1; break; } return(result); }
private async Task <AttackOpponentResult> PostAttackOpponent(AttackRequest attackRequest, Guid newBoardId) { using var client = IntegrationFixture.Server.CreateClient(); var response = await client.PostAsJsonAsync($"Gameplay/boards/{newBoardId}/attack", attackRequest); AttackResult attackResult = null; try { attackResult = await response.Content.ReadAsAsync <AttackResult>(); } catch (Exception) { } var attackOpponentResult = new AttackOpponentResult() { AttackResult = attackResult, Response = response }; return(attackOpponentResult); }
/// <summary> /// Shoot at a given row/column /// </summary> /// <param name="row">the row to attack</param> /// <param name="col">the column to attack</param> /// <returns>the result of the attack</returns> internal AttackResult Shoot(int row, int col) { _shots += 1; AttackResult result = default(AttackResult); result = EnemyGrid.HitTile(row, col); switch (result.Value) { case ResultOfAttack.Destroyed: case ResultOfAttack.Hit: _hits += 1; break; case ResultOfAttack.Miss: _misses += 1; break; } if (_playerGrid.ShipsKilled > 1) { if (win == 0) { SwinGame.StopMusic(); SwinGame.PlayMusic(GameResources.GameMusic("deadlock")); } win++; } if (_playerGrid.ShipsKilled > 3) { if (winning == 0) { SwinGame.StopMusic(); SwinGame.PlayMusic(GameResources.GameMusic("final")); } winning++; } return(result); }
public AttackResult Attack(AttackAttempt attackAttempt) { var result = new AttackResult(); if (HitPoints == 0) { result.Message = $"The {Type} is already dead."; return(result); } result.ValidAttack = true; var hitRoll = DiceRoller.Roll(1, DiceType.d20); if (hitRoll >= ArmorClass) { result.DidHit = true; var damage = DiceRoller.Roll(1, DiceType.d4); result.Damage = damage; HitPoints = Math.Max(HitPoints - damage, 0); if (HitPoints == 0) { result.Killed = true; result.Message = $"The {Type} was hit for {damage} and was killed."; } else { result.Message = $"The {Type} was hit for {damage} but was not killed."; } } else { result.Message = $"The attack missed the {Type}!"; } result.HitRoll = hitRoll; result.RemainingHitPoints = HitPoints; result.TargetAC = ArmorClass; return(result); }
public void HandKillingAttackHitsDefenderWithResistantDefense_DefenseSubtractedFromDamge() { HeroSystemCharacter character = characterFactory.BaseCharacterWithOneKillingAttackCombatManuever; HeroSystemCharacter defender = characterFactory.BaseCharacter; defender.RPD.CurrentValue = 10; AttackResult result = character.Attack("Basic Killing", defender); int expectedStunDamageRolled = 20; int expectedBodyDamageRolled = 10; Assert.AreEqual(expectedStunDamageRolled, result.DamageResult.STUN); Assert.AreEqual(expectedBodyDamageRolled, result.DamageResult.BOD); int expectedStunLeft = defender.STUN.MaxValue - (result.DamageResult.STUN - defender.RPD.CurrentValue); int expectedBodyLeft = defender.BOD.MaxValue - (result.DamageResult.BOD - defender.RPD.CurrentValue);; Assert.AreEqual(expectedStunLeft, defender.STUN.CurrentValue); Assert.AreEqual(expectedBodyLeft, defender.BOD.CurrentValue); }
public Int32 CalculateResistanceIgnoreValue(AttackResult p_result) { MonsterAbilityBase ability = GetAbility(EMonsterAbilityType.PIERCING_STRIKES); if (ability == null) { return(0); } if (p_result.Result == EResultType.CRITICAL_HIT) { return((Int32)ability.StaticData.GetValues(ability.Level)[1]); } if (p_result.Result == EResultType.HIT) { Single num = Random.Range(0f, 1f); if (num < ability.StaticData.GetValues(ability.Level)[0]) { return((Int32)ability.StaticData.GetValues(ability.Level)[1]); } } return(0); }
public override AttackResult Attack() { var attackresult = new AttackResult(); if (StatusState == StatusEffect.Paralyzed) { Console.WriteLine($"{GetName()} is paralyzed and cannot attack!"); return(attackresult); } var dmg = AttackDice.GetRoll(); attackresult.AttackRoll = dmg; attackresult.DamageType = DamageType.Range; if (dmg == 6) { attackresult.DidCrit = true; attackresult.AttackDmg = (dmg * 2); attackresult.StatusEffect = StatusEffect.Poisoned; } return(attackresult); }
/// <summary> /// ProcessShot is able to process each shot that is made and call the right methods belonging /// to that shot. For example, if its a miss = do nothing, if it's a hit = process that hit location /// </summary> /// <param name="row">the row that was shot at</param> /// <param name="col">the column that was shot at</param> /// <param name="result">the result from that hit</param> protected override void ProcessShot(int row, int col, AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: break; case ResultOfAttack.Hit: _CurrentState = AIStates.TargetingShip; AddTarget(row - 1, col); AddTarget(row, col - 1); AddTarget(row + 1, col); AddTarget(row, col + 1); break; case ResultOfAttack.Destroyed: break; case ResultOfAttack.ShotAlready: throw new ApplicationException("Error in AI"); } }
private void PerformRangedAttack() { //Calculate the damage this projectile will cause. float atkDefRatio = (float)user.stats.Att / (float)target.stats.Att; float power = basicAttackPowers[range][user.stats.BasicAttackLevel]; float agiRatio = Mathf.Sqrt((float)user.stats.Agi / (float)target.stats.Agi); AttackResult hit = AttackResultUtils.TryToHit(agiRatio); float damage = atkDefRatio * hit.DamageMultiplier() * power; HitsplatInfo info = new HitsplatInfo { damage = (int)damage, type = DamageType.STAB, result = hit }; //Send the projectile on its way. It handles its own animation, etc, after that. RangedProjectile projectile = GameObject.Instantiate <RangedProjectile>(user.basicRangedProjectile); projectile.Init(10, user.transform.position, target, info, (int)damage); user.currentMP -= (int)basicAttackCosts[user.stats.BasicAttackLevel]; }
/// <summary> /// ''' Checks the results of the attack and switches to /// ''' Ending the Game if the result was game over. /// ''' </summary> /// ''' <param name="result">the result of the last /// ''' attack</param> /// ''' <remarks>Gets the AI to attack if the result switched /// ''' to the AI player.</remarks> private static void CheckAttackResult(AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: { if (HumanPlayer.Missed > 14 && _aiSetting == AIOption.Insane) { SwitchState(GameState.EndingGame); } if (_theGame.Player == ComputerPlayer) { AIAttack(); } break; } case ResultOfAttack.GameOver: { SwitchState(GameState.EndingGame); break; } } }
protected override void HandleMonsters(Character p_attacker, SpellEventArgs p_result, List <Object> p_targets, Single p_magicFactor) { if (p_targets.Count > 0 && p_targets[0] is Monster) { Monster monster = (Monster)p_targets[0]; AttackResult attackResult = DoAttackMonster(p_attacker, monster, p_magicFactor); p_result.SpellTargets.Add(new AttackedTarget(monster, attackResult)); if (attackResult.Result == EResultType.EVADE) { return; } if (attackResult.DamageDone > 0) { Single num = attackResult.DamageDone * 0.3f; List <Object> otherMonstersOnSlot = LegacyLogic.Instance.MapLoader.Grid.GetOtherMonstersOnSlot(monster); AttackMonsters(p_attacker, otherMonstersOnSlot, p_result, (Int32)num); otherMonstersOnSlot.Add(monster); SetMonsterBuffs(p_attacker, otherMonstersOnSlot, p_result, p_magicFactor); } monster.ApplyDamages(attackResult, p_attacker); } }
private void HandleHittingEvent(AttackPackage attack, AttackResult result) { _decayTimer = _decayDelay; _disappearTimer = _disappearDelay; var totalComboTimes = _state._currentMeleeComboTimes + _state._currentRangeComboTimes; var comboDamage = _state._currentMeleeComboTimes * _state._meleeComboAdditiveDamage + _state._currentRangeComboTimes * _state._rangeComboAdditiveDamage; if (totalComboTimes == _lastComboTime) { _currentBaseDamage += result._finalDamage; } else { if (_lastComboTime == _state._comboMaxTimes) { _decaying = true; } _lastComboTime = totalComboTimes; var baseDamage = result._finalDamage - comboDamage; if (baseDamage > _state._hitPoints) { baseDamage = _state._hitPoints; } if (_currentExtraDamage > _state._hitPoints) { _currentExtraDamage = _state._hitPoints; } _currentBaseDamage += baseDamage; _currentExtraDamage += comboDamage; } UpdateSlider(); }
/// <summary> /// Checks the results of the attack and switches to /// Ending the Game if the result was game over. /// </summary> /// <param name="result">the result of the last /// attack</param> /// <remarks>Gets the AI to attack if the result switched /// to the AI player.</remarks> private static void CheckAttackResult(AttackResult result) { var switchExpr = result.Value; switch (switchExpr) { case var @case when @case == ResultOfAttack.Miss: { if (_theGame.Player == ComputerPlayer) { AIAttack(); } break; } case var case1 when case1 == ResultOfAttack.GameOver: { SwitchState(GameState.EndingGame); break; } } }
protected override void ProcessShot(int row, int col, AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: break; case ResultOfAttack.Hit: break; case ResultOfAttack.Destroyed: break; case ResultOfAttack.ShotAlready: throw new ApplicationException("Error in AI"); } if (_Targets.Count == 0) { _CurrentState = AIStates.Searching; } }
public override AttackResult Attack() { var attackresult = new AttackResult(); if (StatusState == StatusEffect.Paralyzed) { Console.WriteLine($"{GetName()} is paralyzed and cannot attack!"); return(attackresult); } var dmg = AttackDice.GetRoll(); attackresult.AttackRoll = dmg; attackresult.DamageType = DamageType.Magic; if (dmg == 8) { attackresult.DidCrit = true; attackresult.AttackDmg = (dmg * 2); //changed from AttackRoll to AttackDmg, to prevent the writline from displaying the roll as double attackresult.StatusEffect = StatusEffect.Frozen; } return(attackresult); }
public override void PlayerAttacked(BasePlayer player, Point from, Point to, GamePieceType piece, AttackResult result) { EstimatedState[from.x, from.y] = null; if (result == AttackResult.Win) { if (player != this) { EstimatedState[to.x, to.y] = GamePieceFactory.Create(piece, !this.IsRed); } } else if (result == AttackResult.Tie) { EstimatedState[to.x, to.y] = null; } else if (result == AttackResult.Lose) { if (player == this) { EstimatedState[to.x, to.y] = GamePieceFactory.Create(piece, !this.IsRed); } } }
/// <summary> /// ''' Checks the results of the attack and switches to /// ''' Ending the Game if the result was game over. /// ''' </summary> /// ''' <param name="result">the result of the last /// ''' attack</param> /// ''' <remarks>Gets the AI to attack if the result switched /// ''' to the AI player.</remarks> private static void CheckAttackResult(AttackResult result) { if (result.Value == ResultOfAttack.Hit) { if (ReferenceEquals(_theGame.Player, ComputerPlayer)) { AIAttack(); } } if (result.Value == ResultOfAttack.Miss) { if (ReferenceEquals(_theGame.Player, ComputerPlayer)) { AIAttack(); } } else if (result.Value == ResultOfAttack.GameOver) { SwitchState(GameState.EndingGame); } }
// '' <summary> // '' Shoot will swap between players and check if a player has been killed. // '' It also allows the current player to hit on the enemygrid. // '' </summary> // '' <param name="row">the row fired upon</param> // '' <param name="col">the column fired upon</param> // '' <returns>The result of the attack</returns> public AttackResult Shoot(int row, int col) { AttackResult newAttack; int otherPlayer = ((_playerIndex + 1) % 2); newAttack = Player.Shoot(row, col); // Will exit the game when all players ships are destroyed if (_players[otherPlayer].IsDestroyed) { newAttack = new AttackResult(ResultOfAttack.GameOver, newAttack.Ship, newAttack.Text, row, col); } AttackCompleted(this, newAttack); // change player if the last hit was a miss if ((newAttack.Value == ResultOfAttack.Miss)) { _playerIndex = otherPlayer; } return(newAttack); }
public void Fire(IFleet enemyFleet, BattleStratageyType battleStratageyType) { if (AmmoAvailable) { if (Ammo.HasValue) { Ammo = Ammo - 1; } IStarShip ship = GetTargetShip(battleStratageyType, enemyFleet); if (ship != null) { AttackResult result = new AttackResult { Damage = CalculateDamage() }; AttackAggregator battleAttackAggregator = new AttackAggregator(); battleAttackAggregator.RegisterObserver(ship); battleAttackAggregator.NotifyObservers(result); battleAttackAggregator.UnregisterObserver(ship); } } }
/// <summary> /// Checks the results of the attack and switches to /// Ending the Game if the result was game over. /// </summary> /// <param name="result">the result of the last /// attack</param> /// <remarks>Gets the AI to attack if the result switched /// to the AI player.</remarks> private static void CheckAttackResult(AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: if (object.ReferenceEquals(_theGame.Player, ComputerPlayer)) { AIAttack(); } break; case ResultOfAttack.GameOver: SwitchState(GameState.EndingGame); break; //case ResultOfAttack.Mine: // if (object.ReferenceEquals (_theGame.Player, ComputerPlayer)) // AIAttack (); // AIAttack (); // AIAttack (); // break; } }
public static void Print(HUDDamageText pDamageText, AttackResult pAttackResult, Boolean pIsMagical) { if (!ConfigManager.Instance.Options.ShowFloatingDamageMonsters) { return; } if (pAttackResult.Result == EResultType.BLOCK) { pDamageText.Add(LocaManager.GetText("SCROLLING_COMBAT_SHIELD"), false, Color.white, 0f); } else if (pAttackResult.Result == EResultType.EVADE) { if (pIsMagical) { pDamageText.Add(LocaManager.GetText("SCROLLING_COMBAT_RESISTED"), false, Color.white, 0f); } else { pDamageText.Add(LocaManager.GetText("SCROLLING_COMBAT_MISS"), false, Color.white, 0f); } } else if (pAttackResult.Result == EResultType.IMMUNE) { pDamageText.Add(LocaManager.GetText("SCROLLING_COMBAT_IMMUNE"), false, Color.white, 0f); } else if (pAttackResult.Result == EResultType.CRITICAL_HIT) { pDamageText.Add(pAttackResult, true, new Color32(245, 240, 135, Byte.MaxValue), 0f); } else if (pAttackResult.Result == EResultType.HEAL) { pDamageText.Add(pAttackResult, false, Color.green, 0f); } else { pDamageText.Add(pAttackResult, false, Color.white, 0f); } }
public AttackResult Check(AttackRequest request) { var result = new AttackResult(); if (_masterIgnoreList.Contains(request.Domain)) { return(result); } HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(request.Body); List <string> linksFound = new List <string>(); List <HtmlNode> anchorLinks = htmlDoc.DocumentNode.Descendants("a").ToList(); foreach (HtmlNode node in anchorLinks) { if (node.Attributes["href"] != null) { string value = node.Attributes["href"].Value; if (!value.StartsWith("mailto")) { if (CheckURL(request.Domain, value) && !linksFound.Contains(value)) { result.Success = true; linksFound.Add(value + " - Dormant social media account"); } } } } linksFound.ForEach(x => result.Results.Enqueue(x)); //result.Results.AddRange(linksFound); return(result); }
//检查一次更新过后 未执行的单位 private void checkAction() { if (willActionActor != null) { iswait = true; if (!willActionActor.IsPlayer)//敌人攻击 { Debug.Log("【敌人攻击】"); //轮到敌人攻击 拿到一个攻击数据组 AnalyzeResult aiAction = willActionActor.Analyse.analyseCombatAttack(messageActor, willActionActor, combat.playerActor); //获取一个分析后数据 调用战斗数据缓存器attackAction存储缓存数据 AttackResult animData = attackAction.normalAction(aiAction); //根据计算结果 调用动画播放器 播放完动画后进行下一步 AnimationController.Instance.playCombatBeHit(combat, animData); } else { //+++dosomething 轮到玩家操作 combat.playerRound(); Debug.Log("【玩家攻击】"); } } }
public override void ResolveEffect(Party p_party) { Damage p_damages = Damage.Create(new DamageData(EDamageType.DARK, m_staticData.AbsoluteValueMin, m_staticData.AbsoluteValueMax), 1f); Attack p_attack = new Attack(1f, 0f, p_damages); for (Int32 i = 0; i < 4; i++) { Character member = p_party.GetMember(i); AttackResult attackResult = member.FightHandler.AttackEntity(p_attack, false, EDamageType.DARK, false, 0, false); member.ChangeHP(-attackResult.DamageDone); if (Random.Range(0, 100) < m_staticData.PercentageValue) { if (!member.ConditionHandler.HasCondition(ECondition.CONFUSED)) { conditionsReceived[i] = ECondition.CONFUSED; } member.ConditionHandler.AddCondition(ECondition.CONFUSED); conditionsReceived[i] = ECondition.CONFUSED; } attackResults[i] = attackResult; } NotifyListeners(p_party); }
/// <summary> /// Processes an attack. /// </summary> /// <param name="xCoordinate"></param> /// <param name="yCoordinate"></param> /// <returns></returns> public AttackResult ProcessAttack(int xCoordinate, int yCoordinate) { if (Status == GameStatus.Ended) { throw new Exception("The game has ended"); } if (xCoordinate < 0 || yCoordinate < 0 || xCoordinate >= BoardSize || yCoordinate >= BoardSize) { return(AttackResult.InvalidCoordinate); } var playerToGuess = _players.First(); AttackResult attackResult = playerToGuess.ProcessAttack(xCoordinate, yCoordinate); if (playerToGuess.Ships.All(s => s.HasSunk)) { attackResult = AttackResult.Win; Status = GameStatus.Ended; } return(attackResult); }
private AttackResult CalculateCriticalDamage(int damage) { var result = new AttackResult(); switch (DrawLotsCritical()) { case ResultType.Critical: result.ResultType = ResultType.Critical; result.Damage = (int)(damage * ConstValue.CriticalDamageRate); break; case ResultType.Normal: result.ResultType = ResultType.Normal; result.Damage = damage; break; case ResultType.Fumble: result.ResultType = ResultType.Fumble; result.Damage = 0; break; } return(result); }
public AttackResult Check(AttackRequest request) { var result = new AttackResult(); WebPageRequest webRequest = new WebPageRequest(request.URL); webRequest.FollowRedirects = false; WebPageLoader.Load(webRequest); if (webRequest.Response.Code == "401" && request.URL.StartsWith("http:")) { result.Success = true; result.Results.Enqueue("401 over HTTP found at " + request.URL); } if ((webRequest.Response.Code == "302" || webRequest.Response.Code == "301") && webRequest.Response.Body.Length != 0) { result.Success = true; result.Results.Enqueue("302/301 response with body " + request.URL);//possibly add a post check here as well } return(result); }
/// <summary> /// Attack a position with X & Y Coordinates for all ships whether they occupy the position in the board. /// </summary> /// <param name="coordinate">The X & Y coordinates</param> /// <returns>Returns the attack result which could be Hit or Miss orelse Lost Game if the hit resulted in sinking the ship</returns> public AttackResult AttackPosition(Coordinate coordinate) { AttackResult attackResult = AttackResult.None; // Is this coordinate on the board? // Or Is the same Slot already fired? then just ignore the shot if (!IsCoordinateValid(coordinate) || _firedSlots.Contains(coordinate)) { return(attackResult); } // Set Default attack result as Miss if it's not hit attackResult = AttackResult.Miss; // Check whether the shot hits any of the ships, so loop through all the ships on the board foreach (var ship in _ships) { // If the shot resulted in hit, set result as a hit if (ship.FireSlot(coordinate)) { attackResult = AttackResult.Hit; break; } } // The hit could have resulted in sinking the last ship if it has hit the last slot for the last ship making it sunk if (attackResult == AttackResult.Hit) { // Check if all ships are sunk then return result as Lost Game if (_ships.TrueForAll(ship => ship.HasSunk)) { attackResult = AttackResult.LostGame; } } return(attackResult); }
/// <summary> /// Shoot will swap between players and check if a player has been killed. /// It also allows the current player to hit on the enemygrid. /// </summary> /// <param name="row">The row fired upon.</param> /// <param name="col">The column fired upon.</param> /// <returns>The result of the attack.</returns> public AttackResult Shoot(int row, int col) { AttackResult newAttack = default(AttackResult); int otherPlayer = System.Convert.ToInt32((_playerIndex + 1) % 2); newAttack = Player.Shoot(row, col); // Will exit the game when all players ships are destroyed. if (_players[otherPlayer].IsDestroyed) { newAttack = new AttackResult(ResultOfAttack.GameOver, newAttack.Ship, newAttack.Text, row, col); } if (AttackCompleted != null) { AttackCompleted(this, newAttack); } // Change player if the last hit was a miss. if (newAttack.Value == ResultOfAttack.Miss) { if (_players[_playerIndex].GetType() == typeof(AIInsanePlayer)) { InsaneMissCounter++; if (InsaneMissCounter == 2) { InsaneMissCounter = 0; _playerIndex = otherPlayer; } } else { _playerIndex = otherPlayer; } } return(newAttack); }
public override void ConfirmAttackKillResult(AttackResult attackResult, int attackingMonsterTypeId, int defendingMonsterTypeId, int actionNumber, int subActionNumber) { bool isFriendlyMonster = _actionNumber == 1 || _actionNumber == 2; Monster attacker = FriendlyMonsters.SingleOrDefault(m => m.MonsterTypeId == attackingMonsterTypeId) ?? EnemyMonsters.SingleOrDefault(m => m.MonsterTypeId == attackingMonsterTypeId); Monster defender = FriendlyMonsters.SingleOrDefault(m => m.MonsterTypeId == defendingMonsterTypeId) ?? EnemyMonsters.SingleOrDefault(m => m.MonsterTypeId == defendingMonsterTypeId); Vector3 battlePosition = new Vector3(BattleSmoke.transform.localPosition.x, BattleSmoke.transform.localPosition.y, BattleSmoke.transform.localPosition.z); if (attackResult == AttackResult.Kill) { AttackResultTextPrefab.GetComponent <TextMesh>().text = "KiLL"; AttackResultTextPrefab.gameObject.SetActive(true); AttackResultTextPrefab.transform.localPosition = battlePosition; AttackResultTextPrefab.LerpDestination = AttackResultTextPrefab.transform.localPosition + Vector3.up; ProcessKill(defender, !isFriendlyMonster); } else if (attackResult == AttackResult.CounterKill) { AttackResultTextPrefab.GetComponent <TextMesh>().text = "Counter KiLL"; AttackResultTextPrefab.gameObject.SetActive(true); AttackResultTextPrefab.transform.localPosition = battlePosition; AttackResultTextPrefab.LerpDestination = AttackResultTextPrefab.transform.localPosition + Vector3.up; ProcessKill(attacker, isFriendlyMonster); SelectedMonster = null; } _actionNumber = actionNumber; _subActionNumber = subActionNumber; }
public void UpdateAttackResults(Coordinate lastAttack, AttackResult result, bool sunkShip) { ((MainWindow)wdw).Dispatcher.Invoke(new UpdateAttackResultsDelegate(wdw.UpdateAttackResults), lastAttack, result, sunkShip); }
/// <summary> /// ProcessShot will be called uppon when a ship is found. /// </summary> /// <param name="row">the row it needs to process</param> /// <param name="col">the column it needs to process</param> /// <param name="result">the result og the last shot (should be hit)</param> protected override void ProcessShot(int row, int col, AttackResult result) { //easyAI does nothing with a shot }
public SkillArgs(byte skillType, AttackResult isCritical, uint skillID, uint targetActorID, uint damage) { this.skillType = skillType; this.isCritical = isCritical; this.skillID = (Skills.SkillIDs)skillID; this.targetActorID = targetActorID; this.damage = damage; this.casting = false; this.castcancel = false; this.failed = false; }
/// <summary> /// Shoot will swap between players and check if a player has been killed. /// It also allows the current player to hit on the enemygrid. /// </summary> /// <param name="row">the row fired upon</param> /// <param name="col">the column fired upon</param> /// <returns>The result of the attack</returns> public AttackResult Shoot(int row, int col) { AttackResult newAttack = default(AttackResult); int otherPlayer = (_playerIndex + 1) % 2; newAttack = Player.Shoot(row, col); //Will exit the game when all players ships are destroyed if (_players[otherPlayer].IsDestroyed) { newAttack = new AttackResult(ResultOfAttack.GameOver, newAttack.Ship, newAttack.Text, row, col); } if (AttackCompleted != null) { AttackCompleted(this, newAttack); } //change player if the last hit was a miss if (newAttack.Value == ResultOfAttack.Miss) { _playerIndex = otherPlayer; } return newAttack; }
// Takes the attack from an enemy unit, returning the counter-attack and attack results. // TODO: fix this weird attack problem // on counters it attacks itself? public List<AttackResult> takeAttackFrom(Unit enemy, int distance, bool firstAttack) { Attack atk = new Attack(enemy, this); List<AttackResult> attacks = new List<AttackResult>(); AttackResult result = new AttackResult(HitType.Miss, 0, false, atk); AttackResult counter = new AttackResult(HitType.CannotCounter, 0, false); string statStr = "stats1 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater; statStr += "\nstats1 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater; statStr += "\nAttack info: " + atk; Debug.Log(statStr); Debug.Log("taking attack from: " + ident() + ", enemy doing this: " + enemy.ident()); string playType = (isEnemy()) ? "enemy" : "player"; if (Random.value <= atk.getHitChance()) { result.setType(HitType.Hit); result.setDamageTaken(atk.getDamage()); Debug.Log(playType + " was Hit!"); if (Random.value <= atk.getCritChance()) { clay -= (3 * atk.getDamage()); result.setType(HitType.Crit); result.setDamageTaken(3 * atk.getDamage()); Debug.Log("Crit!"); } else clay -= atk.getDamage(); } else Debug.Log(playType + " was Missed!"); if(clay <= 0) result.setKilled(true); // Only counter if it is the first attack in a set and the enemy's range allows it else if(firstAttack && enemy.getMinAttackRange() <= distance && enemy.getMaxAttackRange() >= distance) counter = enemy.takeAttackFrom(this, distance, false)[0]; // Add this enemy's result first, then the counter result attacks.Add(result); attacks.Add(counter); statStr = "\nstats2 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater; statStr += "\nstats2 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater; Debug.Log(statStr); return attacks; }
private static int TotalDamageFromResult(AttackResult attackResult, int damage) { switch (attackResult) { case AttackResult.Hit: return damage; case AttackResult.Miss: return 0; case AttackResult.Critical: return damage * 2; case AttackResult.Glancing: return damage / 2; } return 0; }
/// <summary> /// ProcessShot will be called uppon when a ship is found. /// It will create a stack with targets it will try to hit. These targets /// will be around the tile that has been hit. /// </summary> /// <param name="row">the row it needs to process</param> /// <param name="col">the column it needs to process</param> /// <param name="result">the result og the last shot (should be hit)</param> protected override void ProcessShot(int row, int col, AttackResult result) { if (result.Value == ResultOfAttack.Hit) { row = _Random.Next(0, EnemyGrid.Height); col = _Random.Next(0, EnemyGrid.Width); } else if (result.Value == ResultOfAttack.ShotAlready) { throw new ApplicationException("Error in AI"); } }
protected override void ProcessShot(int row, int col, AttackResult result) { }
public void UpdateAttackResults(Coordinate lastAttack, AttackResult result, bool sunkShip) { if (uiState == UIState.Attacking) { uiState = UIState.WaitingToAttack; ShowNotification(string.Format("Waiting for {0} to attack...", opponent.PlayerName)); } else { HandleBadUIState(); } // update attacks and ui elements Attacks[lastAttack.X, lastAttack.Y].Result = result; }
private Uri GetImageForAttackResult(AttackResult result) { switch (result) { default: case AttackResult.Unknown: return new Uri("resources/images/attacks/attackResult_Unknown.png", UriKind.Relative); case AttackResult.Miss: return new Uri("resources/images/attacks/attackResult_Miss.png", UriKind.Relative); case AttackResult.Hit: return new Uri("resources/images/attacks/attackResult_Hit.png", UriKind.Relative); } }
public UnitStrike( Unit attacker, Unit attackee, MeleeWeapon weapon ) : base("Strike", attacker) { this.attacker = attacker; this.attackee = attackee; this.weapon = weapon; result = attacker.relations.GetAttackResult( attackee ); }
public AttackInfo(Coordinate coord, AttackResult result, bool sunkShip) { this.coord = coord; this.result = result; this.sunkShip = sunkShip; }
/// <summary> /// The last shot had the following result. Child classes can use this /// to prepare for the next shot. /// </summary> /// <param name="result">The result of the shot</param> /// <param name="row">the row shot</param> /// <param name="col">the column shot</param> protected abstract void ProcessShot(int row, int col, AttackResult result);
private static string CombatMessageFromResult(Unit source, Unit target, String skill, AttackResult attackResult, int damage) { var effectString = String.Empty; switch (attackResult) { case AttackResult.Hit: effectString = String.Format("dealing {0} damage", damage); break; case AttackResult.Miss: effectString = String.Format("but misses, dealing no damage."); break; case AttackResult.Critical: effectString = String.Format("dealing a critical blow for {0} total damage!", damage); break; case AttackResult.Glancing: effectString = String.Format("dealing {0} damage with a glancing attack", damage); break; } return String.Format("{0} fires off a {1} at {2}, {3}.", source.Name, skill, target.Name, effectString); }
protected void OnPropertyChanged(AttackResult result) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("result")); } }
public override void UpdateAttackResults(Coordinate lastAttack, AttackResult result, bool sunkShip) { switch (atkState) { case AtkState.StabInTheDark: if (result == AttackResult.Hit) { atkState = AtkState.FindFollowUp; firstHit = new AttackInfo(lastAttack, result, sunkShip); targets = CalcAdjCoords(lastAttack).FindAll(t => Attacks[t.X, t.Y].Result == AttackResult.Unknown); } break; case AtkState.FindFollowUp: if (sunkShip) { atkState = AtkState.StabInTheDark; break; } if (result == AttackResult.Hit) { atkState = AtkState.FinishEmOff; secondHit = new AttackInfo(lastAttack, result, sunkShip); targets.Clear(); } break; case AtkState.FinishEmOff: if (result == AttackResult.Hit && sunkShip) { atkState = AtkState.StabInTheDark; firstHit = null; secondHit = null; } break; default: atkState = AtkState.StabInTheDark; break; } base.UpdateAttackResults(lastAttack, result, sunkShip); }
/// <summary> /// ProcessShot is able to process each shot that is made and call the right methods belonging /// to that shot. For example, if its a miss = do nothing, if it's a hit = process that hit location /// </summary> /// <param name="row">the row that was shot at</param> /// <param name="col">the column that was shot at</param> /// <param name="result">the result from that hit</param> protected override void ProcessShot(int row, int col, AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: _CurrentTarget = null; break; case ResultOfAttack.Hit: ProcessHit(row, col); break; case ResultOfAttack.Destroyed: ProcessDestroy(row, col, result.Ship); break; case ResultOfAttack.ShotAlready: throw new ApplicationException("Error in AI"); } if (_Targets.Count == 0) _CurrentState = AIStates.Searching; }
public UnitAttack( Unit attacker, Unit attackee ) : base("Attack", attacker) { this.attacker = attacker; this.attackee = attackee; result = attacker.relations.GetAttackResult( attackee ); weapon = attacker.currentWeapon; }
/// <summary> /// Checks the results of the attack and switches to /// Ending the Game if the result was game over. /// </summary> /// <param name="result">the result of the last /// attack</param> /// <remarks>Gets the AI to attack if the result switched /// to the AI player.</remarks> private static void CheckAttackResult(AttackResult result) { switch (result.Value) { case ResultOfAttack.Miss: if (object.ReferenceEquals(_theGame.Player, ComputerPlayer)) AIAttack(); break; case ResultOfAttack.GameOver: SwitchState(GameState.EndingGame); break; } }
public abstract void PlayerAttacked(BasePlayer player, Point from, Point to, GamePieceType piece, AttackResult result);
public UnitShoot( Unit attacker, Unit attackee, Firearm weapon ) : base("Shoot", attacker) { this.attacker = attacker; this.attackee = attackee; this.weapon = weapon; result = attacker.relations.GetAttackResult( attackee ); }
/// <summary> /// Listens for attacks to be completed. /// </summary> /// <param name="sender">the game</param> /// <param name="result">the result of the attack</param> /// <remarks> /// Displays a message, plays sound and redraws the screen /// </remarks> private static void AttackCompleted(object sender, AttackResult result) { bool isHuman = false; isHuman = object.ReferenceEquals(_theGame.Player, HumanPlayer); if (isHuman) { Message = "You " + result.ToString(); } else { Message = "The AI " + result.ToString(); } switch (result.Value) { case ResultOfAttack.Destroyed: PlayHitSequence(result.Row, result.Column, isHuman); Audio.PlaySoundEffect(GameSound("Sink")); break; case ResultOfAttack.GameOver: PlayHitSequence(result.Row, result.Column, isHuman); Audio.PlaySoundEffect(GameSound("Sink")); while (Audio.SoundEffectPlaying(GameSound("Sink"))) { SwinGame.Delay(10); SwinGame.RefreshScreen(); } if (HumanPlayer.IsDestroyed) { Audio.PlaySoundEffect(GameSound("Lose")); } else { Audio.PlaySoundEffect(GameSound("Winner")); } break; case ResultOfAttack.Hit: PlayHitSequence(result.Row, result.Column, isHuman); break; case ResultOfAttack.Miss: PlayMissSequence(result.Row, result.Column, isHuman); break; case ResultOfAttack.ShotAlready: Audio.PlaySoundEffect(GameSound("Error")); break; } }
public virtual void UpdateAttackResults(Coordinate lastAttack, AttackResult result, bool sunkShip) { Attacks[lastAttack.X, lastAttack.Y].Result = result; }
public static NumberItem Create(Vector3 worldPosition, AttackResult result) { NumberItem numberItem = DoCreate(worldPosition); numberItem.Show(result); return numberItem; }
public Attack() { this.result = AttackResult.Unknown; }