Ejemplo n.º 1
0
        public override void Refresh()
        {
            if (TechRecords == null)
            {
                SetUpTechTable();
                SetUpTechTree();
            }

            foreach (var techRecord in TechRecords)
            {
                var recordedTech = techRecord.TechToDisplay;

                techRecord.CurrentProgress = TechCanon.GetProgressOnTechByCiv(recordedTech, ObjectToDisplay);

                if (TechCanon.IsTechDiscoveredByCiv(techRecord.TechToDisplay, ObjectToDisplay))
                {
                    techRecord.Status = TechnologyRecord.TechStatus.Discovered;
                }
                else if (ObjectToDisplay.TechQueue.Contains(techRecord.TechToDisplay))
                {
                    if (ObjectToDisplay.TechQueue.Peek() == techRecord.TechToDisplay)
                    {
                        techRecord.Status = TechnologyRecord.TechStatus.BeingResearched;
                    }
                    else
                    {
                        techRecord.Status = TechnologyRecord.TechStatus.InQueue;
                    }
                }
                else if (
                    SelectionMode != TechSelectionMode.ResearchFreeTech ||
                    TechCanon.IsTechAvailableToCiv(recordedTech, ObjectToDisplay)
                    )
                {
                    techRecord.Status = TechnologyRecord.TechStatus.Available;
                }
                else
                {
                    techRecord.Status = TechnologyRecord.TechStatus.Unavailable;
                }

                techRecord.CanBeClicked = SelectionMode != TechSelectionMode.SetTechQueue ||
                                          !TechCanon.IsTechDiscoveredByCiv(recordedTech, ObjectToDisplay);

                float sciencePerTurn = YieldLogic.GetYieldOfCivilization(ObjectToDisplay)[Simulation.YieldType.Science];

                if (sciencePerTurn > 0)
                {
                    techRecord.TurnsToResearch = (int)Math.Ceiling(
                        (techRecord.TechToDisplay.Cost - techRecord.CurrentProgress) / sciencePerTurn
                        );
                }
                else
                {
                    techRecord.TurnsToResearch = -1;
                }

                techRecord.Refresh();
            }
        }