private void ShowVictoryLose() { VicDefView.Type result = _battleResultData.isVictorious ? VicDefView.Type.Victory : VicDefView.Type.Defeat; BattleResult matchRes = (BattleResult)NewUIGroup.CreateGroup(NewUIGroup.NAME__BATTLERESULT, NewUIGroup.PrefabProviderType.Battle); matchRes.Init(result, _battleResultData, CleaningBattleAndDestroying); }
//Private Methods private void Init(BattleInfo battleInfo) { if (Application.isMobilePlatform) { Screen.sleepTimeout = SleepTimeout.NeverSleep; } DivineDebug.Log("Initing battle Logic."); _curState = BattleLogicStates.Start; _battleInfo = battleInfo; _battleScene = BattleSceneManager.instance.SelectBattleScene(_battleInfo.battleSceneType); _newBattleUI = NewUIGroup.CreateGroup(NewUIGroup.NAME__BATTLEUI, NewUIGroup.PrefabProviderType.Battle) as BattleUI; _generatedApOnDeath = AppManager.instance.config.apDeath; _generatedApDamageTaken = AppManager.instance.config.apTakenDamage; _isFirstTurn = true; _battleEndCame = false; _firstPing = true; _pingProblem = AppManager.instance.config.pingProblemNumber; _timeOutTime = _pingProblem * 5; _clientCurrentTime = Time.time; _currentselectedCharacters = new List <Character>(); MakeParties(_battleInfo.partyInfoes); StartParties(); List <Character> orderArray = new List <Character>(_battleInfo.charactersTurnOrder_id.Length); foreach (var item in _battleInfo.charactersTurnOrder_id) { var characterOrder = _parties[0].FindCharacter(item); if (characterOrder != null) { orderArray.Add(characterOrder); } else { orderArray.Add(_parties[1].FindCharacter(item)); } } _newBattleUI.Init(_parties[0].Name, _parties[1].Name, _battleInfo.turnTime, battleInfo.partyInfoes[0].availableSecrets, OnSpellSelectedByCurrentChar, OnSecretSelected, orderArray); _newBattleUI.InitScore(0, 0); BattleDataProvider.instance.SetBattleLogic(this); BattleDataProvider.instance.Event_BattleFinish += OnBattleFinishedComeFromServer; BattleDataProvider.instance.Event_BattleTurnData += OnTurnChanged; BattleDataProvider.instance.Event_ActionReceived += OnActionReceived; BattleDataProvider.instance.Event_BattlePingTick += OnPinging; //BattleDataProvider.instance.Event_Secret += OnSecretCastSuccessful; if (!TutorialManager.instance.IsInBattleTutorial()) { TimeManager.instance.Event_OneSecTick += OnSecTick; } _battleSpellDataProvider = BattleSpellDataProvider.instance; GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, _parties[0].hero.moniker.ToString()); if (_battleInfo.isBot) { _botLogic = new BotLogic(orderArray, battleInfo.botPower); } //Test FakeServer.instance.Event_ActionAnalyzed += OnActionReceived; FakeServer.instance.Event_BattleFinished += OnBattleFinishedComeFromServer; }
public static void Net_CharLevelUp(NewUIGroup relatedGroup, CharInfo charInfo, Action actionOnSuccess = null, Action actionOnFail = null) { relatedGroup.SetIsBusyInLogicForAMoment(); NetRequestPage netReqPage = NewUIGroup.CreateGroup(NewUIGroup.NAME__NETREQUESTPAGE, relatedGroup) as NetRequestPage; netReqPage.Init("upgrading"); DivineDebug.Log("Net: CharLevelUp request sent. Char: '" + charInfo.moniker.ToString() + "'."); NewNetworkManager.instance.CharLevelUp(charInfo, (data) => { DivineDebug.Log("Old MaxHP: " + charInfo.baseStats.maxHp); DivineDebug.Log("Next MaxHP: " + charInfo.nextUpgradeStats.health); DivineDebug.Log("Net: CharLevelUp was successful. Char: '" + charInfo.moniker.ToString() + "'."); netReqPage.SetSuccessHappened("done"); GameManager.instance.player.coin -= charInfo.nextUpgradeStats.card_cost; charInfo.curCardCount -= charInfo.nextUpgradeStats.card_count; GameAnalyticsSDK.GameAnalytics.NewDesignEvent("Level up character : " + charInfo.moniker.ToString()); charInfo.level++; charInfo.SetBaseStats(data.max_health, data.max_health, data.attack, data.max_shield, data.max_shield); charInfo.SetOtherStats(data.critical_ratio, data.critical_chance, data.dodge_chance); charInfo.nextUpgradeStats = CharInfoHelper.GetNextUpgradeStats(data.nextStats); if (data.chakraData != null) { HeroInfo heroInfo = (HeroInfo)charInfo; heroInfo.chakra.level++; heroInfo.chakra.SetBaseStats(data.chakraData.chakra_max_health, data.chakraData.chakra_max_health, data.chakraData.chakra_attack, data.chakraData.chakra_max_shield, data.chakraData.chakra_max_shield); heroInfo.chakra.SetOtherStats(data.chakraData.chakra_critical_ratio, data.chakraData.chakra_critical_chance, data.chakraData.chakra_dodge_chance); heroInfo.chakra.nextUpgradeStats = CharInfoHelper.GetNextUpgradeStats(data.chakraData.next_upgrade_stats); } if (actionOnSuccess != null) { actionOnSuccess(); } DivineDebug.Log("MaxHP: " + charInfo.baseStats.maxHp); DivineDebug.Log("MaxHP: " + charInfo.nextUpgradeStats.health); }, (errorMsg) => { DivineDebug.Log("Net: CharLevelUp failed. Char: '" + charInfo.moniker.ToString() + "'."); netReqPage.SetFailHappened("connectionError"); if (actionOnFail != null) { actionOnFail(); } }); }