Esempio n. 1
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);
        }
    }
Esempio n. 2
0
    public void UnlockTechnology(ConstructibleElement technology, Empire empire)
    {
        if (technology == null)
        {
            throw new ArgumentNullException("technology");
        }
        if (this.GetTechnologyState(technology, empire) == DepartmentOfScience.ConstructibleElement.State.Researched)
        {
            return;
        }
        ConstructionQueue constructionQueueForEmpire = this.GetConstructionQueueForEmpire(empire);

        if (constructionQueueForEmpire.Contains(technology))
        {
            constructionQueueForEmpire.Remove(technology);
        }
        this.researchedTechNames.Add(technology.Name);
        this.researchedTechs.Add(technology);
        if (this.KaijuTechnologyUnlocked != null)
        {
            this.KaijuTechnologyUnlocked(this, new ConstructibleElementEventArgs(technology));
        }
    }