Example #1
0
 public ReplayMapDataLoader Initialize(BattleParticipant defender, string replayOwnerPlayerId)
 {
     this.defender            = defender;
     this.replayOwnerPlayerId = replayOwnerPlayerId;
     this.replayResponseData  = null;
     return(this);
 }
Example #2
0
 public ReplayMapDataLoader InitializeFromData(BattleEntry battleEntry, BattleRecord battleRecord)
 {
     this.replayResponseData            = new GetReplayResponse();
     this.replayResponseData.EntryData  = battleEntry;
     this.replayResponseData.ReplayData = battleRecord;
     this.defender            = battleEntry.Defender;
     this.replayOwnerPlayerId = null;
     return(this);
 }
        public void OnReplayLoaded(GetReplayResponse response, object cookie)
        {
            ProcessingScreen.Hide();
            this.replayResponseData = response;
            BattlePlaybackState.GoToBattlePlaybackState(this);
            BattleRecord replayData = response.ReplayData;
            BattleEntry  entryData  = response.EntryData;

            replayData.RecordId      = entryData.RecordID;
            entryData.SharerPlayerId = this.replayOwnerPlayerId;
            bool flag = Service.Get <CurrentPlayer>().PlayerId == entryData.AttackerID || this.replayOwnerPlayerId == entryData.AttackerID;

            entryData.Won = (flag ? (entryData.EarnedStars > 0) : (entryData.EarnedStars == 0));
            Service.Get <EventManager>().SendEvent(EventId.BattleRecordRetrieved, this.replayResponseData);
        }
Example #4
0
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.MapDataProcessingStart)
     {
         if (id == EventId.BattleRecordRetrieved)
         {
             GetReplayResponse getReplayResponse = (GetReplayResponse)cookie;
             this.battleRecord = getReplayResponse.ReplayData;
             this.battleEntry  = getReplayResponse.EntryData;
             Service.Get <BattlePlaybackController>().InitPlayback(this.battleRecord, this.battleEntry);
         }
     }
     else
     {
         this.OnMapProcessingStart();
         Service.Get <EventManager>().UnregisterObserver(this, EventId.MapDataProcessingStart);
     }
     return(EatResponse.NotEaten);
 }
Example #5
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.BattleReplaySetup:
            {
                BattleRecord battleRecord = (BattleRecord)cookie;
                ArmoryController.AddEquipmentBuffs(battleRecord.AttackerEquipment, battleRecord.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleRecordRetrieved:
            {
                GetReplayResponse getReplayResponse = (GetReplayResponse)cookie;
                BattleRecord      replayData        = getReplayResponse.ReplayData;
                ArmoryController.AddEquipmentBuffs(replayData.AttackerEquipment, replayData.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleLeftBeforeStarting:
            case EventId.BattleReplayEnded:
                goto IL_150;

            case EventId.BattleLoadedForDefend:
                break;

            default:
                switch (id)
                {
                case EventId.EquipmentUnlocked:
                    this.pendingCelebrationEquipment = (cookie as EquipmentVO);
                    this.UpdateLastEquipmentUnlocked(this.pendingCelebrationEquipment.Uid);
                    if (this.AllowUnlockCelebration)
                    {
                        if (GameUtils.IsUnlockBlockingScreenOpen())
                        {
                            Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
                        }
                        else
                        {
                            bool immediate = GameUtils.CanShardUnlockCelebrationPlayImmediately();
                            this.ShowEquipmentUnlockedCelebration(immediate);
                        }
                    }
                    return(EatResponse.NotEaten);

                case EventId.EquipmentUpgraded:
                {
                    ContractEventData    contractEventData    = cookie as ContractEventData;
                    StaticDataController staticDataController = Service.StaticDataController;
                    EquipmentVO          equipmentVO          = staticDataController.Get <EquipmentVO>(contractEventData.Contract.ProductUid);
                    this.UpdateActiveArmoryLevel(equipmentVO);
                    return(EatResponse.NotEaten);
                }

                case EventId.EquipmentActivated:
                case EventId.EquipmentDeactivated:
                    this.UpdateArmoryBuildingTooltip();
                    return(EatResponse.NotEaten);

                default:
                    switch (id)
                    {
                    case EventId.ScreenClosing:
                        if (cookie is InventoryCrateCollectionScreen)
                        {
                            GameUtils.CloseStoreOrInventoryScreen();
                            Service.EventManager.UnregisterObserver(this, EventId.ScreenClosing);
                            if (this.AllowUnlockCelebration)
                            {
                                this.ShowEquipmentUnlockedCelebration(false);
                            }
                        }
                        return(EatResponse.NotEaten);

                    case EventId.ScreenClosed:
                    case EventId.ScreenOverlayClosing:
                    {
IL_58:
                        if (id == EventId.BattleLoadStart)
                        {
                            goto IL_E3;
                        }
                        if (id == EventId.BattleEndFullyProcessed)
                        {
                            goto IL_150;
                        }
                        if (id != EventId.PlanetConfirmRelocate)
                        {
                            return(EatResponse.NotEaten);
                        }
                        CurrentPlayer        currentPlayer         = Service.CurrentPlayer;
                        StaticDataController staticDataController2 = Service.StaticDataController;
                        for (int i = currentPlayer.ActiveArmory.Equipment.Count - 1; i >= 0; i--)
                        {
                            EquipmentVO equipment = staticDataController2.Get <EquipmentVO>(currentPlayer.ActiveArmory.Equipment[i]);
                            if (!ArmoryUtils.IsEquipmentValidForPlanet(equipment, (string)cookie))
                            {
                                this.DeactivateEquipmentOnClient(currentPlayer, equipment);
                            }
                        }
                        return(EatResponse.NotEaten);
                    }

                    case EventId.ScreenLoaded:
                        if (cookie is ArmoryScreen)
                        {
                            this.UpdateLastEquipmentUnlocked("false");
                        }
                        return(EatResponse.NotEaten);
                    }
                    goto IL_58;
                }
                break;
            }
IL_E3:
            CurrentBattle currentBattle = Service.BattleController.GetCurrentBattle();

            ArmoryController.AddEquipmentBuffs(currentBattle.AttackerEquipment, currentBattle.DefenderEquipment);
            return(EatResponse.NotEaten);

IL_150:
            Service.BuffController.ClearEquipmentBuffs();
            return(EatResponse.NotEaten);
        }
Example #6
0
 public void SetReplayResponseData(GetReplayResponse replayResponseData)
 {
     this.replayResponseData = replayResponseData;
 }