예제 #1
0
    private void CreateWorldCity(WorldCityInfo info)
    {
        WorldCity city     = null;
        var       townInfo = info as WorldResTownInfo;

        if (townInfo != null)
        {
            // 资源城
            if (townInfo.ProduceType == ResourceType.STONE)
            {
                city = Instantiate(_resTownPrefabList[1]);
            }
            else
            {
                city = Instantiate(_resTownPrefabList[0]);
            }
        }
        else
        {
            // 主城
            city = Instantiate(_worldCityPrefabList[0]);
        }

        city.gameObject.SetActive(true);
        Vector3 pos = GetSlotPosition(info.MapPosition, info is WorldResTownInfo);

        city.transform.SetParent(_panelCity, false);
        city.transform.localPosition = pos;
        city.CreateUserPanel(_userInfoPanelPrefab);
        city.SetInfo(info);

        _cityList.Add(city);
    }
예제 #2
0
    // 刷新城池数据
    private void OnRefreshCity(int mapPos)
    {
        WorldCity city = GetCity(mapPos);

        if (city != null)
        {
            city.Refresh();
        }
    }
예제 #3
0
    // 移除一个城池
    private void OnRemoveCity(int mapPos)
    {
        WorldCity city = GetCity(mapPos);

        if (city != null)
        {
            _cityList.Remove(city);
            Destroy(city.gameObject);
        }
    }
예제 #4
0
    // 更换对手
    private void OnSwitchCity(WorldCityInfo info)
    {
        WorldCity oldCity = GetCity(info.MapPosition);

        if (oldCity != null)
        {
            _cityList.Remove(oldCity);
            Destroy(oldCity.gameObject);
        }

        CreateWorldCity(info);
    }
예제 #5
0
        public static WorldCities ProcessWorldCities(ShapefileConverter shapefile)
        {
            var cities = new WorldCities();

            foreach (ShapefileRecord record in shapefile)
            {
                var item = new WorldCity();
                if (record.Fields != null)
                {
                    if (item.Population < 0)
                    {
                        item.Population = 0;
                    }
                    // get geo-location from shape file (SHP)
                    item.Longitude = record.Points[0][0].X;
                    item.Latitude  = record.Points[0][0].Y;
                    // get data about a location from database file (DBF)
                    if (record.Fields.ContainsKey("COUNTRY_NA"))
                    {
                        item.CountryName = (string)(record.Fields["COUNTRY_NA"]);
                    }
                    if (record.Fields.ContainsKey("NAME"))
                    {
                        item.CityName = (string)(record.Fields["NAME"]);
                    }
                    if (record.Fields.ContainsKey("POPULATION"))
                    {
                        item.Population = (double)(record.Fields["POPULATION"]);
                    }
                    if (record.Fields.ContainsKey("CAPITAL"))
                    {
                        item.IsCapital = (string)(record.Fields["CAPITAL"]) == "N" ? false : true;
                    }

                    //if (item.CountryName == "US" || item.CountryName == "USA") item.CountryName = "United States";
                    //if (item.CountryName == "UK" || item.CountryName == "GB") item.CountryName = "United Kingdom";

                    item.Label = "City: " + item.CityName + ", " + item.CountryName
                                 + Environment.NewLine + "Population: " + String.Format("{0:#,##0,,.0 M}", item.Population);

                    cities.Population.Update(item.Population);

                    // add an item to data collection
                    cities.Add(item);
                }
            }
            cities.Sort((x, y) => - x.Population.CompareTo(y.Population));
            return(cities);
        }
예제 #6
0
        public int CsvH_Regular(string fileName, int fileSize, int nbFloat)
        {
            using (var reader = new StreamReader(fileName))
                using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                {
                    var records = new List <WorldCity>();
                    csv.Read();
                    csv.ReadHeader();
                    while (csv.Read())
                    {
                        var record = new WorldCity
                        {
                            //	City = csv.GetField<string>("City"),
                            Latitude  = csv.GetField <double>("Latitude"),
                            Longitude = csv.GetField <double>("Longitude")
                        };
                        records.Add(record);
                    }

                    return(records.Count);
                }
        }
예제 #7
0
 static bool CitiesIntersect(WorldCity city1, WorldCity city2, int ChunksOfPadding)
 {
     return(new Rectangle(city1.x, city1.z, city1.ChunkLength, city1.ChunkLength).IntersectsWith(
                new Rectangle(city2.x - ChunksOfPadding, city2.z - ChunksOfPadding,
                              city2.ChunkLength + (2 * ChunksOfPadding), city2.ChunkLength + (2 * ChunksOfPadding))));
 }
예제 #8
0
 public CityEventArgs(WorldCity city)
 {
     City = city;
 }
예제 #9
0
 public Worker(string name, DateTime birthDay, WorldCity favoriteCity)
 {
     Name              = name;
     BirthDay          = birthDay;
     this.favoriteCity = favoriteCity;
 }
예제 #10
0
 public Worker()
 {
     Name         = "Unknown";
     BirthDay     = DateTime.Now;
     favoriteCity = WorldCity.Beijing;
 }
예제 #11
0
 // Constructor
 public WarManager() : base()
 {
     worldCities  = new WorldCity();
     myExpedition = new ExpeditionManager();
 }