public void RecalculateCurrencyTrayVisibility()
        {
            UXController uXController = Service.Get <UXController>();

            if (uXController == null || !uXController.MiscElementsManager.IsLoaded())
            {
                return;
            }
            bool flag = false;

            for (int i = this.screens.Count - 1; i >= 0; i--)
            {
                ScreenBase screenBase = this.screens[i].Screen as ScreenBase;
                if (screenBase != null && screenBase.IsLoaded() && screenBase.ShowCurrencyTray)
                {
                    flag = true;
                    uXController.MiscElementsManager.DetachCurrencyTray();
                    screenBase.UpdateCurrencyTrayAttachment();
                    break;
                }
            }
            if (!flag)
            {
                uXController.MiscElementsManager.DetachCurrencyTray();
            }
        }
Beispiel #2
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            if (id <= EventId.BuildingReplaced)
            {
                if (id <= EventId.BuildingCancelled)
                {
                    if (id != EventId.BuildingViewReady)
                    {
                        if (id != EventId.BuildingCancelled)
                        {
                            return(EatResponse.NotEaten);
                        }
                    }
                    else
                    {
                        EntityViewParams entityViewParams = (EntityViewParams)cookie;
                        if (entityViewParams.Entity.Has <ScoutTowerComponent>())
                        {
                            this.CreateScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else if (id != EventId.EntityKilled)
                {
                    if (id != EventId.BuildingConstructed)
                    {
                        if (id != EventId.BuildingReplaced)
                        {
                            return(EatResponse.NotEaten);
                        }
                        Entity entity = cookie as Entity;
                        if (entity.Has <ScoutTowerComponent>())
                        {
                            this.CreateScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else
                {
                    SmartEntity smartEntity = (SmartEntity)cookie;
                    if (smartEntity.BuildingComp == null)
                    {
                        return(EatResponse.NotEaten);
                    }
                    BuildingType type = smartEntity.BuildingComp.BuildingType.Type;
                    if (!this.raidDefenseTrainerBindings.Contains(type))
                    {
                        return(EatResponse.NotEaten);
                    }
                    UXController uXController = Service.Get <UXController>();
                    Lang         lang         = Service.Get <Lang>();
                    switch (type)
                    {
                    case BuildingType.FleetCommand:
                        Service.Get <DeployerController>().SpecialAttackDeployer.ExitMode();
                        uXController.HUD.DisableSpecialAttacks();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("STARSHIP_TRAINER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    case BuildingType.HeroMobilizer:
                        Service.Get <DeployerController>().HeroDeployer.ExitMode();
                        uXController.HUD.DisableHeroDeploys();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("HERO_TRAINER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    case BuildingType.ChampionPlatform:
                    case BuildingType.Housing:
                        return(EatResponse.NotEaten);

                    case BuildingType.Squad:
                        Service.Get <DeployerController>().SquadTroopDeployer.ExitMode();
                        uXController.HUD.DisableSquadDeploy();
                        uXController.MiscElementsManager.ShowPlayerInstructions(lang.Get("SQUAD_CENTER_DESTROYED", new object[0]));
                        return(EatResponse.NotEaten);

                    default:
                        return(EatResponse.NotEaten);
                    }
                }
                ContractEventData contractEventData = (ContractEventData)cookie;
                if (contractEventData.BuildingVO.Type == BuildingType.ScoutTower)
                {
                    this.SendRaidDefenseUpdate();
                }
            }
            else
            {
                if (id <= EventId.ContractStarted)
                {
                    if (id != EventId.WorldLoadComplete)
                    {
                        if (id == EventId.WorldReset)
                        {
                            this.DestroyScoutHolo();
                            return(EatResponse.NotEaten);
                        }
                        if (id != EventId.ContractStarted)
                        {
                            return(EatResponse.NotEaten);
                        }
                    }
                    else
                    {
                        IState currentState = Service.Get <GameStateMachine>().CurrentState;
                        if (currentState is HomeState && this.RaidCompleteDidAwardCrate())
                        {
                            GameUtils.ShowCrateAwardModal(this.lastAwardedCrateUid);
                            this.lastAwardedCrateUid = null;
                            Service.Get <EventManager>().UnregisterObserver(this, EventId.WorldLoadComplete);
                            return(EatResponse.NotEaten);
                        }
                        return(EatResponse.NotEaten);
                    }
                }
                else if (id != EventId.ContractContinued)
                {
                    if (id == EventId.HeroDeployed)
                    {
                        EntityController entityController      = Service.Get <EntityController>();
                        NodeList <OffensiveTroopNode> nodeList = entityController.GetNodeList <OffensiveTroopNode>();
                        TroopAttackController         troopAttackController = Service.Get <TroopAttackController>();
                        for (OffensiveTroopNode offensiveTroopNode = nodeList.Head; offensiveTroopNode != null; offensiveTroopNode = offensiveTroopNode.Next)
                        {
                            troopAttackController.RefreshTarget((SmartEntity)offensiveTroopNode.Entity);
                        }
                        return(EatResponse.NotEaten);
                    }
                    if (id != EventId.PlanetRelocateStarted)
                    {
                        return(EatResponse.NotEaten);
                    }
                    if (this.AreRaidsAccessible())
                    {
                        this.SendRaidDefenseUpdate();
                        return(EatResponse.NotEaten);
                    }
                    return(EatResponse.NotEaten);
                }
                ContractEventData contractEventData2 = (ContractEventData)cookie;
                if (contractEventData2.BuildingVO.Type == BuildingType.ScoutTower)
                {
                    this.DestroyScoutHolo();
                }
            }
            return(EatResponse.NotEaten);
        }
Beispiel #3
0
        public void EnsureBuildingTooltip(SmartEntity building)
        {
            if (building == null || building.SupportViewComp == null || Service.PostBattleRepairController.IsEntityInRepair(building))
            {
                return;
            }
            SupportViewComponent supportViewComp = building.SupportViewComp;
            BuildingComponent    buildingComp    = building.BuildingComp;
            BuildingTypeVO       buildingType    = buildingComp.BuildingType;

            if (!supportViewComp.Enabled)
            {
                return;
            }
            IState currentState = Service.GameStateMachine.CurrentState;

            if (currentState is WarBoardState)
            {
                return;
            }
            bool                      flag                      = currentState is HomeState;
            bool                      editState                 = currentState is EditBaseState;
            bool                      baseLayoutState           = currentState is BaseLayoutToolState;
            int                       num                       = -1;
            int                       timeTotal                 = -1;
            string                    text                      = null;
            IUpgradeableVO            iconAsset                 = null;
            bool                      flag2                     = Service.BuildingController.SelectedBuilding == building;
            SupportViewComponentState supportViewComponentState = SupportViewComponentState.Dormant;
            Contract                  contract                  = Service.ISupportController.FindCurrentContract(buildingComp.BuildingTO.Key);

            if (contract != null)
            {
                if (this.ShouldShowProgress(contract, flag, editState, baseLayoutState, building))
                {
                    int remainingTimeForView = contract.GetRemainingTimeForView();
                    if (remainingTimeForView <= 0 || !Service.ISupportController.IsContractValidForStorage(contract))
                    {
                        text = Service.Lang.Get("STOPPED", new object[0]);
                        supportViewComponentState = SupportViewComponentState.Bubble;
                    }
                    else
                    {
                        num       = remainingTimeForView;
                        timeTotal = contract.TotalTime;
                        if (this.ShouldShowIcon(contract.DeliveryType, flag))
                        {
                            StaticDataController staticDataController = Service.StaticDataController;
                            DeliveryType         deliveryType         = contract.DeliveryType;
                            if (deliveryType != DeliveryType.UpgradeStarship)
                            {
                                if (deliveryType == DeliveryType.UpgradeEquipment)
                                {
                                    iconAsset = staticDataController.Get <EquipmentVO>(contract.ProductUid);
                                    goto IL_19B;
                                }
                                if (deliveryType != DeliveryType.Starship)
                                {
                                    iconAsset = staticDataController.Get <TroopTypeVO>(contract.ProductUid);
                                    goto IL_19B;
                                }
                            }
                            iconAsset = staticDataController.Get <SpecialAttackTypeVO>(contract.ProductUid);
IL_19B:
                            supportViewComponentState = SupportViewComponentState.IconProgress;
                        }
                        else
                        {
                            supportViewComponentState = SupportViewComponentState.Progress;
                        }
                    }
                }
            }
            else
            {
                text = this.GetBubbleText(building, flag, editState, flag2);
                if (text != null)
                {
                    supportViewComponentState = this.GetBubbleViewComponentStateBasedOnBuilding(building);
                }
            }
            if (flag2 && flag && supportViewComponentState == SupportViewComponentState.Dormant && buildingType.Type == BuildingType.Starport)
            {
                supportViewComponentState = SupportViewComponentState.General;
            }
            if (supportViewComponentState != SupportViewComponentState.Dormant)
            {
                bool            flag3 = supportViewComponentState == supportViewComp.State;
                BuildingTooltip buildingTooltip;
                if (flag3)
                {
                    buildingTooltip = supportViewComp.BuildingTooltip;
                }
                else
                {
                    supportViewComp.TeardownElements();
                    UXController            uXController        = Service.UXController;
                    MiscElementsManager     miscElementsManager = uXController.MiscElementsManager;
                    GameObjectViewComponent gameObjectViewComp  = building.GameObjectViewComp;
                    string     str           = gameObjectViewComp.MainGameObject.GetInstanceID().ToString();
                    string     name          = "BuildingTooltip" + str;
                    GameObject worldUIParent = Service.UXController.WorldUIParent;
                    switch (supportViewComponentState)
                    {
                    case SupportViewComponentState.Bubble:
                        if (buildingType.Type == BuildingType.ChampionPlatform)
                        {
                            buildingTooltip = miscElementsManager.CreateBubbleRepairTooltip(name, worldUIParent);
                        }
                        else
                        {
                            buildingTooltip = miscElementsManager.CreateBubbleTooltip(name, worldUIParent);
                        }
                        break;

                    case SupportViewComponentState.BubbleHQ:
                    case SupportViewComponentState.BubbleArmoryUpgrade:
                    case SupportViewComponentState.BubbleShardUpgrade:
                        buildingTooltip = miscElementsManager.CreateHQBubbleTooltip(name, worldUIParent);
                        break;

                    case SupportViewComponentState.Progress:
                        buildingTooltip = miscElementsManager.CreateProgressTooltip(name, worldUIParent);
                        break;

                    case SupportViewComponentState.IconProgress:
                        buildingTooltip = miscElementsManager.CreateIconProgressTooltip(name, worldUIParent);
                        break;

                    default:
                        buildingTooltip = miscElementsManager.CreateGeneralTooltip(name, worldUIParent);
                        break;
                    }
                }
                buildingTooltip.SetSelected(flag2);
                buildingTooltip.SetTitle(this.GetBuildingTitle(buildingType));
                buildingTooltip.SetLevel(buildingType);
                buildingTooltip.SetBubbleText(text);
                buildingTooltip.SetIconAsset(iconAsset);
                buildingTooltip.SetTime(num);
                buildingTooltip.SetProgress(num, timeTotal);
                if (!flag3)
                {
                    supportViewComp.SetupElements(buildingTooltip, supportViewComponentState);
                }
            }
        }