private async Task FinishFight(User attacker, User opponent, BattleResult result, int attackerDamageSum, int opponentDamageSum) { result.AttackerDamageSum = attackerDamageSum; result.OpponentDamageSum = opponentDamageSum; attacker.Battles++; opponent.Battles++; if (result.IsVictory) { attacker.Victories++; opponent.Defeats++; attacker.Bananas += opponentDamageSum; opponent.Bananas += attackerDamageSum * 10; } else { attacker.Defeats++; opponent.Victories++; attacker.Bananas += opponentDamageSum * 10; opponent.Bananas += attackerDamageSum; } StoreBattleHistory(attacker, opponent, result); await _context.SaveChangesAsync(); }
void OnBattleEnd(BattleResult result) { switch (result) { case BattleResult.Win: { string bonusText = CalExpGot(m_battleParams.battleData); GameUtil.ShowFullSuggest(bonusText, "<color=yellow><size=50>战斗胜利</size></color>", delegate { EndBattle(); m_battleParams.callback?.Invoke(result); m_battleParams = null; }); break; } case BattleResult.Lose: { GameUtil.ShowFullSuggest("胜败乃兵家常事,请大侠重新来过。", "<color=red><size=80>战斗失败!</size></color>", delegate { EndBattle(); m_battleParams.callback?.Invoke(result); if (m_battleParams.backToBigMap) { LevelLoader.LoadGameMap("Level_BigMap"); } m_battleParams = null; }); break; } } }
public void HandleBattleResult(BattleResult result, Weapon yourWeapon, Weapon enemiesWeapon) { if (result == BattleResult.Win) { myWins += 1 + currentDrawStreak; } if (result == BattleResult.Lose) { enemyWins += 1 + currentDrawStreak; } if (yourWeapon == Weapon.Dynamite) { dynamiteCounter++; } if (enemiesWeapon == Weapon.Dynamite) { enemyDynamiteCounter++; } if (result == BattleResult.Draw) { currentDrawStreak++; } else { currentDrawStreak = 0; } }
public PhaseCreator(Area battleArea, Province friendProvince, Action battleFinish) { _result = BattleResult.None; _battleArea = battleArea; _friendProvince = friendProvince; _battleFinish = battleFinish; }
public void SetBattleResult(BattleResult result) { rewardSlots.ToList().ForEach(slot => { if (slot.item != null) { Destroy(slot.item); } }); ServiceRegistry.Currency.CreditCurrency(Currency.Coins, result.Gold); ServiceRegistry.Characters.ApplyExperience(result.Experience); if (result.Victorious) { finishFeedback.SetActive(true); for (var i = 0; i < result.Items.Count; i++) { var item = ScriptableObject.CreateInstance <Item>(); item.SetData(result.Items[i]); _items.Add(item); var itemController = Instantiate(itemPrefab); itemController.SetData(item, () => { itemInfo.SetData(item); itemInfo.gameObject.SetActive(true); _currentSelectedItem = item; }); rewardSlots[i].item = itemController.gameObject; } } }
/// <summary> /// Creates a request containing battle results /// </summary> /// <param name="res">The result</param> public static NetworkRequest Prepare(BattleResult res) { NetworkRequest request = new NetworkRequest(NetworkCode.CLASH_END_BATTLE); request.AddInt32((int)res); return request; }
public void HandleBattleResult(BattleResult result, Weapon yourWeapon, Weapon enemiesWeapon) { int approxWinsLeft = 2000 - 2 * Math.Max(myWins, enemyWins); double ed = -1 + (Math.Log((double)approxWinsLeft) - Math.Log(100 - enemyDynamiteCounter)) / Math.Log(3.0); //Approx number Of Consecutive Draws Whereby dynamite can be thrown one third of the time. double ev = CalculateDynamiteValue(ed); //Very approx value of dynamite //memory.addEnemyMove(currentDrawStreak, ev, enemiesWeapon); //waveMemory.addEnemyMove(currentDrawStreak, ev, enemiesWeapon); masterMemory.addEnemyMove(currentDrawStreak, ev, enemiesWeapon); if (result == BattleResult.Win) { myWins += 1 + currentDrawStreak; } if (result == BattleResult.Lose) { enemyWins += 1 + currentDrawStreak; } if (yourWeapon == Weapon.Dynamite) { dynamiteCounter++; } if (enemiesWeapon == Weapon.Dynamite) { enemyDynamiteCounter++; } if (result == BattleResult.Draw) { currentDrawStreak++; } else { currentDrawStreak = 0; } }
private void FinalizeBattle(Unit Attacker, Squad AttackerSquad, int AttackerPlayerIndex, Unit Defender, Squad DefenderSquad, int DefenderPlayerIndex, BattleResult Result, List <Unit> ListDeadDefender) { if (Attacker.CurrentAttack != null && !ListDeadDefender.Contains(Result.Target)) { FinalizeAttack(Attacker, Result); //Will Gains if (Result.Target.HP <= 0) { ListDeadDefender.Add(Result.Target); FinalizeDeath(AttackerSquad, AttackerPlayerIndex, DefenderSquad, DefenderPlayerIndex, Result.Target); for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++) { Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainDestroyedEnemy; } for (int U = 0; U < AttackerSquad.UnitsAliveInSquad; U++) { if (Attacker == AttackerSquad[U]) { continue; } for (int C = 1; C < AttackerSquad[U].ArrayCharacterActive.Length; C++) { AttackerSquad[U].ArrayCharacterActive[C].Will += 2; } } } else if (Result.AttackMissed) { for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++) { Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainMissedEnemy; } for (int C = 0; C < Result.Target.ArrayCharacterActive.Length; C++) { Result.Target.ArrayCharacterActive[C].Will += Result.Target.ArrayCharacterActive[C].Personality.WillGainEvaded; } } else if (!Result.AttackMissed) { for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++) { Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainHitEnemy; } for (int C = 0; C < Result.Target.ArrayCharacterActive.Length; C++) { Result.Target.ArrayCharacterActive[C].Will += Result.Target.ArrayCharacterActive[C].Personality.WillGainGotHit; } } } }
public FleetInfo(BattleResult.Result.FleetState state) { Ships = new ShipInfo[] { new ShipInfo(state.Ships[0]),new ShipInfo(state.Ships[1]),new ShipInfo(state.Ships[2]), new ShipInfo(state.Ships[3]),new ShipInfo(state.Ships[4]),new ShipInfo(state.Ships[5]), }; }
private void bs_onBattleComplete(string charId, BattleResult bt) { try { UserManagerHub.GetClients(charId).battleLog(JsonUtil.Serialize(bt)); } catch { } }
public UnitBattleResultEvent(UnitPiece attacker, UnitPiece defender, BoardPosition attackerPosition, BoardPosition defenderPosition, BattleResult result) : base(attacker) { this.defender = defender; this.result = result; this.attackerPosition = attackerPosition; this.defenderPosition = defenderPosition; }
public string SubmitSpringBattleResult(BattleContext context, string password, BattleResult result, List <BattlePlayerResult> players, List <string> extraData) { return(BattleResultHandler.SubmitSpringBattleResult(context, password, result, players, extraData)); }
private void CreateBattleResult() { int winnerIndex = rule.GetWinnerTeamIndex(); int battleDuration = statistics.GetTimeInSeconds(); BattleResult battleResult = new BattleResult(winnerIndex, battleDuration); StaticEvents.hasBattleResultsEvent?.Invoke(battleResult); }
// get from stream static public UInt32 get(mln.EndianStream rEs, out BattleResult rOut) { UInt32 ret = 0; rEs.get(out ret); rOut = (BattleResult)ret; return(4); }
public async Task <BattleResult> StartBattle(int opponentId) { var result = await _http.PostAsJsonAsync("api/Battle", opponentId); LastBattle = await result.Content.ReadFromJsonAsync <BattleResult>(); return(LastBattle); }
/// <summary> /// Creates a request containing battle results /// </summary> /// <param name="res">The result</param> public static NetworkRequest Prepare(BattleResult res) { NetworkRequest request = new NetworkRequest(NetworkCode.CLASH_END_BATTLE); request.AddInt32((int)res); return(request); }
/// <summary> /// 装備した /// </summary> private void Equip(UserData.Equipment.EquipmentUserData entity) { Utility.Log.Print($"アイテムを装備or外す {entity.ID}, {entity.Name}"); // シーンを戻る var result = BattleResult.CreateAtEquip(entity); _sceneManager.CloseSceneAsync(this, result).Forget(); }
// Use this for initialization void Start() { //Generate first row of defender foreach (UnitRank rank in Enum.GetValues(typeof(UnitRank))) { if (!rank.Equals(UnitRank.Unknown)) { GameObject cell = Instantiate(UnitImage); cell.transform.SetParent(Parent); Image i = cell.GetComponent <Image>(); i.sprite = UnitImageManager.GetRankImage(rank); } } //Generate the attacker rows foreach (UnitRank attacker in Enum.GetValues(typeof(UnitRank))) { if (!attacker.Equals(UnitRank.Unknown)) { //Generate attacker cell GameObject cell = Instantiate(UnitImage); cell.transform.SetParent(Parent); Image i = cell.GetComponent <Image>(); i.sprite = UnitImageManager.GetRankImage(attacker); //Iterate over possibles foreach (UnitRank rank in Enum.GetValues(typeof(UnitRank))) { if (!rank.Equals(UnitRank.Unknown)) { GameObject rCell = Instantiate(UnitImage); rCell.transform.SetParent(Parent); Image ri = rCell.GetComponent <Image>(); BattleResult result = UnitUtilities.ResolveBattle(attacker, rank); switch (result) { case BattleResult.Success: { ri.sprite = check; break; } case BattleResult.Fail: { ri.sprite = redx; break; } case BattleResult.Split: { ri.sprite = split; break; } } } } } } }
/// <summary> /// アイテムを使用する /// </summary> private void UseItem(Common.Item.ItemEntity itemEntity) { Utility.Log.Print($"アイテムを使用する {itemEntity.ID}, {itemEntity.Name}"); // シーンを戻る var result = BattleResult.CreateAtItemUse(itemEntity); _sceneManager.CloseSceneAsync(this, result).Forget(); }
private void GenerateMessenger(BattleResult result) { var pos = transform.position; var rot = transform.rotation; var parent = transform.parent; var messanger = Instantiate(Resources.Load("Prefabs/Messenger"), pos, rot, parent) as GameObject; messanger.GetComponent <Messenger>().Run(result, this.parent); messanger.transform.SetSiblingIndex(0); // 目隠しの下に来るように }
private static string WinnerMessage(BattleResult result) { return(result.Winner switch { BattleWinner.None => $"No one won the battle! The attacker was left with {result.FinalAttacker}, and the " + $"defender was left with {result.FinalDefender}.", BattleWinner.Tie => "The battle was a tie! Both teams lost all their troops.", _ => $"The {result.Winner.ToString().ToLower()} won, with {result.RemainingArmy} left." });
public void EnemyTurnEnd(BattleResult result) { if (result == BattleResult.win) { lastAttack.CombinationCity(lastDeffece); lastDeffece.Lose(); aliveCities.Remove(lastDeffece); lastDeffece = null; } }
private Ranking[] GetMatchResult( User current, User user, BattleResult result ) { Ranking one = new Ranking(); one.EloRanking = current.EloRanking; Ranking two = new Ranking(); two.EloRanking = user.EloRanking; Ranking.Update(one, two, result); return new Ranking[] { one, two }; }
public void OnBattleComplete(MapRouting routing, Battle battle, BattleResult result) { foreach (var c in Counters) { if (c is BattleResultCounter bc) { bc.OnBattleComplete(StatePersist, routing, battle, result); } } UpdateProgress(); }
private void OnBattleFinished(BattleResult Result) { if (Result == BattleResult.Lose) { BattleState = new LoseBattleState(this); } else if (Result == BattleResult.Win) { BattleState = new WinBattleState(this); } }
public void OnExerciseComplete(HomeportFleet fleet, BattleResult currentBattleResult) { foreach (var c in Counters) { if (c is ExerciseCounter ec) { ec.OnExerciseComplete(StatePersist, fleet, currentBattleResult); } } UpdateProgress(); }
public void PostBattleReport() { Commander winner = commanderA.isDefeated() ? commanderB : commanderA; this.Result = new BattleResult { Winner = winner.Army, Remaining = winner.Remaining(), Mvp = winner.CalcMVP() }; }
void CheckDeath(BattleResult battleResult) { if (battleResult == BattleResult.YouLose) { SceneChangeManager.ChangeResultScene(false); } else { SceneChangeManager.ChangeResultScene(true); } gameSignalingClient.Dispose(); }
// se-param: 伝令, 3種類, 上から勝ち、引き分け、負け private string GetVoiceName(BattleResult result) { switch (result) { case BattleResult.Win: return("decision9"); case BattleResult.Tie: return("decision10"); case BattleResult.Lose: return("decision11"); } return(""); }
private void StoreBattleHistory(User attacker, User opponent, BattleResult result) { var battle = new Battle(); battle.Attacker = attacker; battle.Opponent = opponent; battle.RoundsFought = result.RoundsFought; battle.WinnerDamage = result.IsVictory ? result.AttackerDamageSum : result.OpponentDamageSum; battle.Winner = result.IsVictory ? attacker : opponent; _context.Battles.Add(battle); }
/// <summary> /// テスト専用 /// </summary> public void InjectResultStatus(ShipStatus[] main, ShipStatus[] guard, ShipStatus[] enemy, ShipStatus[] enemyGuard) { Result = new BattleResult { Friend = new BattleResult.Combined { Main = main, Guard = guard }, Enemy = new BattleResult.Combined { Main = enemy, Guard = enemyGuard } }; }
private void StoreBattleHistory(User attacker, User opponent, BattleResult result) { var battle = new Battle() { Attacker = attacker, Opponent = opponent, RoundsFought = result.RoundsFought, WinnerDamage = result.IsVictory ? result.AttackerDamageSum : result.OpponentDamageSum, Winner = result.IsVictory ? attacker : opponent }; _dataContext.Battles.Add(battle); }
private void PlayerCastSpell(Spell spell, BattleResult battleResult) { int spellEffectValue = CurrentPlayer.CastSpell(CurrentEnemy, spell, ref battleResult); if (spell is DamageSpell) { PlayerCastDamageSpell(battleResult, spellEffectValue, (DamageSpell)spell); } else if (spell is ReplenishSpell) { PlayerCastReplenish(spellEffectValue, (ReplenishSpell)spell); } }
public static void AssertBattleModifierAccuracy(int i) { //Arrange BattleConfig battleConfig = (BattleConfig)BattleSimulatorTestData.BattleTestCases[i][0]; RealBattleResult realBattleResult = (RealBattleResult)BattleSimulatorTestData.BattleTestCases[i][1]; //Act BattleResult result = GameData.SimulateBattle(battleConfig); //Assert Assert.Equal(realBattleResult.AtkBattleModifier, result.AtkBattleModifier); Assert.Equal(realBattleResult.DefModifierBeforeBattle, result.DefModifierBeforeBattle); Assert.Equal(realBattleResult.DefModifierDuringBattle, result.DefModifierDuringBattle); }
private Ranking[] GetMatchResult(User current, User user, BattleResult result) { Ranking one = new Ranking(); one.EloRanking = current.EloRanking; Ranking two = new Ranking(); two.EloRanking = user.EloRanking; Ranking.Update(one, two, result); return(new Ranking[] { one, two }); }
public ShipInfo(BattleResult.Result.FleetState.ShipState state) { if (!state.Valid) { Name = ""; return; } Name = state.ShipName; MaxHP = state.MaxHP; CurrentHP = state.CurrentHP; }
public void HandleBattleResult(BattleResult result) { var belligs = WarBelligerents[result.WarID]; if (belligs.AttackingLeader == result.Winner) { Warscores[result.WarID] += result.Losses * 2; } else if (belligs.DefendingLeader == result.Winner) { Warscores[result.WarID] -= result.Losses * 2; } else { Debug.Assert(result.Winner == -1); } }
public void NextTurn() { ++turn; Left.Move (); Right.Move (); moveHitCheck (); Done = Left.Finish || Right.Finish; var rv = Right.AliveCount; var lv = Left.AliveCount; Result = BattleResult.Draw; if(rv > lv) { Result = BattleResult.Win; } else if (rv < lv) { Result = BattleResult.Lose; } }
protected virtual void CreateTurnPhase(WarPresentationModel model, List<List<WarUnit>> friendUnits, List<WarUnit> enemyUnits, MainWindow mainWindow) { Phases.TurnPhase.Start = situation_ => { situation_.TurnManager.Turn++; mainWindow.SetTurn(situation_.TurnManager.Turn); var unit = situation_.TurnManager.GetInitiativeUnit(situation_); if (unit != null) { situation_.ActiveUnit = unit; situation_.PhaseManager.StartPhase(situation_, Phases.InitiativePhase); } else { situation_.PhaseManager.ExitPhase(situation_); } }; Phases.TurnPhase.Exit = situation_ => { if (situation_.TurnCount >= 20) _result = BattleResult.TwentyTurn; if (_result != BattleResult.None) { situation_.PhaseManager.ExitPhase(situation_); return; } foreach (var unit in situation_.Units.Alive) { if (unit.Status.HpAutoHeal > 0) { unit.HealHP(situation_, unit, unit.Status.HpAutoHeal); model.SetHealAnimationOnMap(unit.Status.HpAutoHeal, unit.Location, null); } if (unit.Status.MpAutoHeal > 0) { unit.HealMP(situation_, unit, unit.Status.MpAutoHeal); var anime = model.CreateStringAnimationOnMap(unit.Status.MpAutoHeal.ToString(), unit.Location, Color.Blue, 500); model.ChipAnimations.Add(new ExtendTimeAnimationSprite(anime, 700, 0)); } } situation_.PhaseManager.StartPhase(situation_, Phases.TurnPhase); }; }
// get from stream public static UInt32 get( mln.EndianStream rEs, out BattleResult rOut ) { UInt32 ret=0; rEs.get( out ret ); rOut = (BattleResult)ret; return 4; }
// set in stream public static UInt32 set( mln.EndianStream rEs, BattleResult rIn ) { rEs.put((UInt32)rIn); return 4; }
IEnumerator DelayShowAttackAnimation(Summon redSummon, Summon blueSummon, BattleResult result) { float timeDelta = 0f; while (timeDelta < showAttackGraphicDelay) { timeDelta += Time.deltaTime; yield return null; } if (result != BattleResult.Draw) { attackAnimations.PlayAnimation((int)(result == BattleResult.RedVictory ? redSummon : blueSummon)); } }
// convert id to string public static string BattleResultToString( BattleResult v ) { switch(v){ case BattleResult.BATTLERESULT_SUCCESS : return "BATTLERESULT_SUCCESS"; case BattleResult.BATTLERESULT_FAILURE : return "BATTLERESULT_FAILURE"; case BattleResult.BATTLERESULT_FAILURE_BATTLING : return "BATTLERESULT_FAILURE_BATTLING"; case BattleResult.BATTLERESULT_FAILURE_MAX_OVER : return "BATTLERESULT_FAILURE_MAX_OVER"; case BattleResult.BATTLERESULT_FAILURE_NOT_FOUND : return "BATTLERESULT_FAILURE_NOT_FOUND"; } return "unknown"; }
/// <summary> /// Factory method to generate info about the outcome of the battle. /// </summary> private BattleResult GetOutcome() { string winner = ""; int unitsLeft = 0; foreach (GameObject unit in controllers.Keys) { if (!unit.GetComponent<UnitInfo>().isDead) { winner = controllers[unit].name; unitsLeft++; } } BattleResult result = new BattleResult(winner, unitsLeft); return result; }
public static void Update( Ranking one, Ranking two, BattleResult result ) { double expectedOne = 0.5; double expectedTwo = 0.5; if( result != BattleResult.Draw ) { expectedOne = (result == BattleResult.NumberOneVictory) ? 1 : 0; expectedTwo = (result == BattleResult.NumberTwoVictory) ? 1 : 0; } double realOne = RealScore(one, two); double realTwo = RealScore(two, one); double oneDistance = (one.EloRanking - two.EloRanking) / 200 * expectedOne; double twoDistance = (two.EloRanking - one.EloRanking) / 200 * expectedTwo; one.EloRanking = FinalScore(one, realOne, expectedOne, oneDistance); two.EloRanking = FinalScore(two, realTwo, expectedTwo, twoDistance); }
public static void Update( AllianceInfo one, AllianceInfo two, BattleResult result ) { Ranking r1 = new Ranking(); r1.EloRanking = one.Ranking; Ranking r2 = new Ranking(); r2.EloRanking = two.Ranking; Update( r1, r2, result ); one.Ranking = r1.EloRanking; two.Ranking = r2.EloRanking; }
public void BeginWaitForNightBattle(int estimatedTickCount,BattleResult.Result result) { if (InvokeRequired) Invoke((MethodInvoker)(() => _beginWaitForNightBattle(estimatedTickCount,result))); else _beginWaitForNightBattle(estimatedTickCount, result); }
/// <summary> /// Calculates the battle between <paramref name="yourCreatures"/> and <paramref name="opponentsCreatures"/> and /// returns the the result as a <see cref="BattleResult"/>. /// </summary> public static BattleResult CalculateBattle(List<Creature> yourCreatures, List<Creature> opponentsCreatures) { if (opponentsCreatures.Count > yourCreatures.Count) throw new ArgumentException("You do not have enough creatures!"); BattleResult battleResult = new BattleResult(); for (int duelIndex = 0; duelIndex < opponentsCreatures.Count; duelIndex++) { Creature opponent = new Creature(opponentsCreatures[duelIndex]); Creature you = new Creature(yourCreatures[duelIndex]); DuelResult duel = new DuelResult(); AddEnchantmentEffects(you, opponent); AddEnchantmentEffects(opponent, you); AddItemEffectsBeforeBattle(you, opponent, yourCreatures, opponentsCreatures); AddItemEffectsBeforeBattle(opponent, you, opponentsCreatures, yourCreatures); while (you.Health > 0 && opponent.Health > 0) { int opponentDamage = GetDamage(opponent, you); int yourDamage = GetDamage(you, opponent); you.Health -= opponentDamage; opponent.Health -= yourDamage; AddItemEffectsBeforeTurn(you, opponent); AddItemEffectsBeforeTurn(opponent, you); if (you.Health < 0) you.Health = 0; if (opponent.Health < 0) opponent.Health = 0; duel.Result += String.Format( "Your {0} did {1} damage -> opponent's {2} has {3} health left." + Environment.NewLine + "Opponent's {2} did {4} damage -> your {0} has {5} health left." + Environment.NewLine, you.Name, yourDamage, opponent.Name, opponent.Health, opponentDamage, you.Health); } if (you.Health == 0 && opponent.Health == 0) { string outCome = String.Format("Your {0} killed your opponent's {1} but died in the process.", you.Name, opponent.Name); duel.Result += outCome; duel.ShortResult = outCome; duel.Outcome = DuelOutcome.Dip; } else if (you.Health > 0) { string outCome = String.Format("Your {0} killed your opponent's {1}.", you.Name, opponent.Name); duel.Result += outCome; duel.ShortResult = outCome; duel.Outcome = DuelOutcome.Won; } else { string outCome = String.Format("Your {0} got killed by your opponent's {1}.", you.Name, opponent.Name); duel.Result += outCome; duel.ShortResult = outCome; duel.Outcome = DuelOutcome.Lost; } battleResult.Add(duel); } return battleResult; }
public static void RankingBattleEndend( Ruler one, Ruler two, BattleResult result ) { try { User uone = UserUtility.bd.getUser(one.ForeignId); User utwo = UserUtility.bd.getUser(two.ForeignId); Ranking.Update( uone, utwo, result ); if( result == BattleResult.NumberOneVictory ) { ++uone.Wins; ++utwo.Losses; } else { ++utwo.Wins; ++uone.Losses; } UserUtility.bd.saveUser(uone, string.Empty); UserUtility.bd.saveUser(utwo, string.Empty); if( uone.AllianceId > 0 && utwo.AllianceId > 0 && uone.AllianceId != utwo.AllianceId ) { AllianceInfo aone = AllianceUtility.Persistance.Get(uone.AllianceId); AllianceInfo atwo = AllianceUtility.Persistance.Get(utwo.AllianceId); Ranking.Update(aone, atwo, result); ++aone.RankingBattles; ++atwo.RankingBattles; AllianceUtility.Persistance.Save(aone); AllianceUtility.Persistance.Save(atwo); } } catch( Exception ex ) { ExceptionLog.log(ex); } }
public void DisplayBattleResults(BattleResult outcome) { this.outcome = outcome; this.displaying = true; }
void _beginWaitForNightBattle(int estimatedTickCount, BattleResult.Result result) { if (Properties.Settings.Default.ShowEnemyBattleStatus && estimatedTickCount > 0) { _battleResult = result; timerWaitForNightBattle.Interval = estimatedTickCount * 1000; timerWaitForNightBattle.Enabled = true; Debug.WriteLine(string.Format("夜戦入り検出を開始。{0}秒後に起動", estimatedTickCount)); } else { Debug.WriteLine("夜戦入り検出は開始してません。"); timerWaitForNightBattle.Enabled = false; } }
/// <summary> /// /kcsapi/api_req_sortie/battleresult /// /kcsapi/api_req_combined_battle/battleresult /// </summary> /// <param name="responseJson"></param> /// <param name="battleResult"></param> void BattleResult(string responseJson,BattleResult.Result battleResult) { #if DEBUG if (battleResult != null) Debug.WriteLine(battleResult.ToString()); else Debug.WriteLine("BattleResult is null"); #endif _parent.EndWaitForNightBattle(); var binfo = _logBattle.Finish(responseJson, _memberShip, _memberDeck, _masterShip, _memberBasic); _parent.AddBattleResult(binfo); _statusManager.FinishBattle(); //戦闘で受けた友軍ダメージを反映する _memberShip.ApplyBattleResult(battleResult); //推測戦闘結果 if (battleResult != null) { var st = battleResult.BattleState; var st2 = KCB2.BattleResult.Result.BattleResultStateString(st); //HP減少分をUIへ反映 _parent.UpdateShipList(_memberShip.ShipList); _parent.UpdateDeckMemberList(_memberShip, _memberDeck.DeckList); if (binfo.ShipDropped.Length > 0 && !Properties.Settings.Default.HideDroppedShip) UpdateDetailStatus("評価{0}({2})で戦闘を終了、{1}がドロップしました", binfo.Rank, binfo.ShipDropped, st2); else UpdateDetailStatus("評価{0}({1})で戦闘を終了しました", binfo.Rank, st2); if (binfo.Rank != KCB2.BattleResult.Result.BattleResultStateShortString(st)) { string fn = string.Format("./{0}.missing.battleresult", DateTime.Now.Ticks.ToString()); Debug.WriteLine("BattleResult Missing log:" + fn); using (var sw = new System.IO.StreamWriter(fn, true, Encoding.UTF8)) { sw.WriteLine("Result(Official):{0}\r\nResult(Self):{1}\r\n\r\n{2}", binfo.Rank, st2, battleResult.ToString()); } } } else { //戦闘解析データがない場合は評価しない。 _parent.UpdateShipList(_memberShip.ShipList); _parent.UpdateDeckMemberList(_memberShip, _memberDeck.DeckList); if (binfo.ShipDropped.Length > 0 && !Properties.Settings.Default.HideDroppedShip) UpdateDetailStatus("評価{0}で戦闘を終了、{1}がドロップしました", binfo.Rank, binfo.ShipDropped); else UpdateDetailStatus("評価{0}で戦闘を終了しました", binfo.Rank); } _parent.NotifyFinishBattle("戦闘"); }
IEnumerator DelayShowResultAnimations(BattleResult result) { float timeDelta = 0f; while (timeDelta < showResultGrahicDelay) { timeDelta += Time.deltaTime; yield return null; } battleResultAnimations.PlayAnimation((int)result); }
protected virtual void CreateInitiativePhase(WarPresentationModel model, List<List<WarUnit>> friendUnits, List<WarUnit> enemyUnits, MainWindow mainWindow) { Phases.InitiativePhase.Start = situation_ => { model.MapWindow.Refresh(); if (situation_.ActiveUnit.Side.IsPlayer) { // ユニットのコマンド状態を初期化する situation_.ActiveUnit.ResetCommandState(); } else { #region AI var doer = situation_.ActiveUnit; var ar = new ActionArguments(situation_, model); var actionEnumrator = new AI.AI().GetActionWithCoroutine(situation_); Action actionCoroutine = null; // AIの行動選択と実行のコルーチン actionCoroutine = () => { // 非同期実行のためのAIの行動選択デリゲートの生成 Func<bool> selectNextAction = actionEnumrator.MoveNext; var asyncResult = selectNextAction.BeginInvoke(null, null); // TaskList にAIの行動選択完了後の、戦闘行動実行を予約する // TaskList を使うことで、ウィンドウメッセージ処理のスレッドによる同期実行が行われる TaskList<int>.Task task = null; task = (taskArgs_, time_) => { // 非同期実行が完了するまでは何もしない if (!asyncResult.IsCompleted) return; // 非同期実行が完了すれば、戻り値を取得する if (selectNextAction.EndInvoke(asyncResult)) { // AIが選択したActionが存在する var battleAction = actionEnumrator.Current.Item1; battleAction.BootAI(ar, doer, Delegates.NOP); battleAction.Execute(ar, doer, actionEnumrator.Current.Item2, actionCoroutine); } else { // AIが選択したActionが存在しないので、ユニットの行動終了 situation_.PhaseManager.ExitPhase(situation_); } // タスクリストからこのデリゲートを削除する Global.MainLoop.TickEvents.Remove(task); }; Global.MainLoop.TickEvents.Add(Double.MinValue, task); }; // AIの行動選択と実行のコルーチンを実行 actionCoroutine(); #endregion } }; Phases.InitiativePhase.Exit = situation_ => { var friends = situation_.Sides.Single(side => side.IsPlayer); var enemies = situation_.Sides.Single(side => !side.IsPlayer); _result = checkBattleEnd(situation_, friends, enemies); if (_result != BattleResult.None) { situation_.PhaseManager.ExitPhase(situation_); return; } model.CancelCommandStack.Clear(); situation_.ActiveUnit.Side.UpdateForceAndBrave(situation_.Units.Alive); var unit = situation_.TurnManager.GetInitiativeUnit(situation_); if (unit != null) { situation_.ActiveUnit = unit; situation_.PhaseManager.StartPhase(situation_, Phases.InitiativePhase); } else { situation_.PhaseManager.ExitPhase(situation_); } }; }