Example #1
0
    private void OnOrderResponse(object sender, TicketRaisedEventArgs args)
    {
        this.AgeTransform.Enable = true;
        DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>();

        DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition);
        if (this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock))
        {
            IGameService service = Services.GetService <IGameService>();
            if (service == null || service.Game == null)
            {
                Diagnostics.LogError("GameService or GameService.Game is null");
                return;
            }
            IKaijuTechsService service2 = service.Game.Services.GetService <IKaijuTechsService>();
            technologyState = service2.GetTechnologyState(this.TechnologyDefinition, this.empire);
        }
        this.Refresh(this.empire, technologyState);
    }
Example #2
0
    private void OnSelectKaijuUnlockCB(GameObject obj)
    {
        if (this.empire == null)
        {
            Diagnostics.LogError("Empire is null");
            return;
        }
        IGameService service = Services.GetService <IGameService>();

        if (service == null || service.Game == null)
        {
            Diagnostics.LogError("GameService or GameService.Game is null");
            return;
        }
        IKaijuTechsService service2 = service.Game.Services.GetService <IKaijuTechsService>();

        DepartmentOfScience.ConstructibleElement.State technologyState = service2.GetTechnologyState(this.TechnologyDefinition, this.empire);
        ConstructionQueue constructionQueueForEmpire = service2.GetConstructionQueueForEmpire(this.empire);

        if (constructionQueueForEmpire == null)
        {
            return;
        }
        if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available)
        {
            this.AgeTransform.Enable = false;
            this.QueueResearch();
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
        else if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued)
        {
            this.AgeTransform.Enable = false;
            Construction construction = constructionQueueForEmpire.Get(this.TechnologyDefinition);
            this.CancelResearch(construction);
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
    }
Example #3
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        this.CostValue.Text = string.Empty;
        this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
        ICostFeatureProvider provider = this.context as ICostFeatureProvider;

        if (provider != null && provider.Constructible != null && provider.Empire != null)
        {
            DepartmentOfTheTreasury departmentOfTheTreasury = provider.Empire.GetAgency <DepartmentOfTheTreasury>();
            SimulationObjectWrapper context = (provider.Context == null) ? provider.Empire : provider.Context;
            string costString;
            int    turn;
            PanelFeatureCost.ComputeCostAndTurn(base.GuiService, provider.Constructible, departmentOfTheTreasury, context, out costString, out turn);
            this.CostValue.AgeTransform.PixelMarginRight = 0f;
            if (this.DisplayTurnCost)
            {
                this.CostValue.AgeTransform.PixelMarginRight = base.AgeTransform.Width - this.TurnValue.AgeTransform.X - 20f * AgeUtils.CurrentUpscaleFactor();
            }
            this.CostValue.AgeTransform.ComputeExtents(Rect.MinMaxRect(0f, 0f, 0f, 0f));
            this.CostValue.Text = costString;
            this.CostTitle.Text = "%FeatureCostTitle";
            if (provider.Constructible is KaijuTechnologyDefinition)
            {
                KaijuTechnologyDefinition kaijuTechnologyDefinition = provider.Constructible as KaijuTechnologyDefinition;
                IGameService       gameService       = Services.GetService <IGameService>();
                IKaijuTechsService kaijuTechsService = gameService.Game.Services.GetService <IKaijuTechsService>();
                if (kaijuTechsService.GetTechnologyState(kaijuTechnologyDefinition, provider.Empire) == DepartmentOfScience.ConstructibleElement.State.Researched)
                {
                    this.CostTitle.Text = "%FeatureAlreadyUnlockedTitle";
                    costString          = " ";
                }
            }
            this.CostValue.Text = costString;
            if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
            {
                float pixelMargin = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
                this.CostValue.AgeTransform.PixelMarginLeft = pixelMargin;
            }
            if (provider.Context == null)
            {
                this.TurnValue.Text = string.Empty;
                this.TurnIcon.AgeTransform.Visible = false;
            }
            else
            {
                this.TurnIcon.AgeTransform.Visible = true;
                if (turn == 2147483647)
                {
                    this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
                }
                else
                {
                    turn = Mathf.Max(1, turn);
                    this.TurnValue.Text = turn.ToString();
                }
            }
        }
        yield return(base.OnShow(parameters));

        this.CostValue.AgeTransform.Height = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count;
        base.AgeTransform.Height           = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count + this.CostValue.AgeTransform.PixelMarginTop + this.CostValue.AgeTransform.PixelMarginBottom;
        base.AgeTransform.Visible          = !string.IsNullOrEmpty(this.CostValue.Text);
        if (!this.DisplayTurnCost)
        {
            this.TurnIcon.AgeTransform.Visible  = false;
            this.TurnValue.AgeTransform.Visible = false;
        }
        yield break;
    }