コード例 #1
0
        public override void Refresh()
        {
            foreach (var projectRecord in new List <CityProjectRecord>(InstantiatedProjectRecords))
            {
                Destroy(projectRecord.gameObject);
            }
            InstantiatedProjectRecords.Clear();

            if (ObjectToDisplay == null)
            {
                return;
            }

            var cityOwner = CityPossessionCanon.GetOwnerOfPossession(ObjectToDisplay);

            if (DisplayType == CityDisplayType.PlayMode)
            {
                AddUnitProjects(cityOwner);

                AddBuildingProjects(
                    cityOwner, TechCanon.GetResearchedBuildings(cityOwner),
                    template => ObjectToDisplay.ActiveProject = ProjectFactory.ConstructProject(template)
                    );
            }
            else if (DisplayType == CityDisplayType.MapEditor)
            {
                AddBuildingProjects(
                    cityOwner, AllBuildingTemplates,
                    template => BuildingFactory.BuildBuilding(template, ObjectToDisplay)
                    );
            }
        }
コード例 #2
0
        private void DecomposeActiveProject(SerializableCityData cityData, ICity newCity)
        {
            if (cityData.ActiveProject != null)
            {
                if (cityData.ActiveProject.BuildingToConstruct != null)
                {
                    var buildingTemplate = AvailableBuildingTemplates.Where(
                        template => template.name.Equals(cityData.ActiveProject.BuildingToConstruct)
                        ).First();

                    newCity.ActiveProject = ProjectFactory.ConstructProject(buildingTemplate);
                }
                else
                {
                    var unitTemplate = AvailableUnitTemplates.Where(
                        template => template.name.Equals(cityData.ActiveProject.UnitToConstruct)
                        ).First();

                    newCity.ActiveProject = ProjectFactory.ConstructProject(unitTemplate);
                }

                newCity.ActiveProject.Progress = cityData.ActiveProject.Progress;
            }
        }