コード例 #1
0
    private void OnSelectOrbUnlockCB(GameObject obj)
    {
        if (this.empire == null)
        {
            Diagnostics.LogError("Empire is null");
            return;
        }
        DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>();

        DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition);
        ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition);

        if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available && agency.OrbUnlockQueue.Length < 2)
        {
            this.AgeTransform.Enable = false;
            if (agency.OrbUnlockQueue.Length > 0)
            {
                Construction construction = constructionQueueForTech.Peek();
                this.CancelResearch(construction);
            }
            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 construction2 = constructionQueueForTech.Get(this.TechnologyDefinition);
            this.CancelResearch(construction2);
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
    }
コード例 #2
0
    public DepartmentOfScience.ConstructibleElement.State GetTechnologyState(ConstructibleElement technology, Empire empire)
    {
        if (technology == null)
        {
            throw new ArgumentNullException("technology");
        }
        ConstructionQueue constructionQueue = null;

        if (!this.researchQueues.TryGetValue(empire.Index, out constructionQueue))
        {
            Diagnostics.LogError("The provided empire does not have a construction queue. Make sure one is created.");
            return(DepartmentOfScience.ConstructibleElement.State.NotAvailable);
        }
        if (this.researchedTechNames.Contains(technology.Name))
        {
            if (empire is MajorEmpire && !DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                return(DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable);
            }
            return(DepartmentOfScience.ConstructibleElement.State.Researched);
        }
        else
        {
            Diagnostics.Assert(constructionQueue != null);
            Construction construction = constructionQueue.Get(technology);
            if (construction != null && construction.ConstructibleElement.Name == technology.Name)
            {
                return(DepartmentOfScience.ConstructibleElement.State.InProgress);
            }
            if (constructionQueue.Contains(technology))
            {
                return(DepartmentOfScience.ConstructibleElement.State.Queued);
            }
            if (!DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                return(DepartmentOfScience.ConstructibleElement.State.NotAvailable);
            }
            return(DepartmentOfScience.ConstructibleElement.State.Available);
        }
    }
コード例 #3
0
    private void OnSelectTechnologyCB(GameObject obj)
    {
        if (this.empire == null)
        {
            Diagnostics.LogError("Empire is null");
            return;
        }
        DepartmentOfScience agency = this.empire.GetAgency <DepartmentOfScience>();

        DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(this.TechnologyDefinition);
        ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition);

        if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available)
        {
            this.AgeTransform.Enable = false;
            if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G))
            {
                this.ForceUnlockTechnology();
            }
            else
            {
                this.QueueResearch();
            }
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
            return;
        }
        if (technologyState == DepartmentOfScience.ConstructibleElement.State.InProgress || technologyState == DepartmentOfScience.ConstructibleElement.State.Queued)
        {
            this.AgeTransform.Enable = false;
            Construction construction = constructionQueueForTech.Get(this.TechnologyDefinition);
            this.CancelResearch(construction);
            if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && Input.GetKey(KeyCode.G))
            {
                this.ForceUnlockTechnology();
            }
            this.selectionClient.SendMessage("OnSelectTechnology", this.AgeTransform, SendMessageOptions.RequireReceiver);
        }
    }
コード例 #4
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);
        }
    }