private void DownPositions(string name, string areaCode, CityType cityType, int index, int count, string baiduCode)
        {
            Random rd      = new Random();
            int    kindex  = rd.Next(0, keys.Length);
            string tempUrl = string.Format(this.url, keys[kindex], name);
            //HttpWebResponse wp = HttpHelper.CreateGetHttpResponse(tempUrl, timeOut, "", GaodeMap.GetCookies());
            //string context = HttpHelper.GetResponseString(wp);
            string context = HttpHelper.GetRequestContent(tempUrl);
            object t       = JsonHelper.JsonDeserialize <object>(context);
            Dictionary <string, object> dicContext = t as Dictionary <string, object>;

            if (dicContext != null)
            {
                Divinsion divinsion = new Divinsion();
                divinsion.name = name;
                divinsion.code = baiduCode;
                object[] districtsObj = dicContext["districts"] as object[];
                for (int i = 0; i < districtsObj.Length; i++)
                {
                    Dictionary <string, object> dicObj = districtsObj[i] as Dictionary <string, object>;
                    if (areaCode != "" && dicObj["adcode"].ToString() != areaCode)
                    {
                        continue;
                    }
                    string polyline = dicObj["polyline"].ToString();
                    divinsion.polylines.Add(polyline);
                }
                if (this.AdminDivisionDowningEvent != null)
                {
                    this.AdminDivisionDowningEvent(divinsion, cityType, index, count);
                }
            }
        }
Ejemplo n.º 2
0
 public City(double xCoord, double yCoord, string name,string cityType)
 {
     XCoord = xCoord;
     YCoord = yCoord;
     Name = name;
     CityType=Convert(cityType);
 }
Ejemplo n.º 3
0
 protected AbstractStructure(CityType requiredCityType, decimal buildCost, int capacity, UnitType unitType)
 {
     RequiredCityType = requiredCityType;
     BuildCost = buildCost;
     Capacity = capacity;
     UnitType = unitType;
 }
Ejemplo n.º 4
0
 public City(double xCoord, double yCoord, string name, string cityType)
 {
     XCoord   = xCoord;
     YCoord   = yCoord;
     Name     = name;
     CityType = Convert(cityType);
 }
Ejemplo n.º 5
0
 public void SwitchState()
 {
     if (Alive.gameObject.activeSelf == true)                                                                                         //om cityalive är aktiv i den nuvarande scenen
     {
         Alive.gameObject.SetActive(false);                                                                                           //gör ena enabled och den andra inte
         Dead.gameObject.SetActive(true);
         transform.GetChild(2).localScale = new Vector3(0.7f, 0.7f);
         transform.GetChild(2).GetComponent <Animator>().SetBool("Dead", true);
         CityAnimator.SetBool("Upgrade1", false);
         CityAnimator.SetBool("Upgrade1", false);
         var clone = Instantiate(FloatingScore, Camera.main.WorldToScreenPoint(transform.position), Quaternion.identity, GameObject.Find("GameUI").transform);
         clone.GetComponent <floatingScore>().setParent(transform);
         clone.GetComponent <Text>().text = "+" + AddToScore.ToString();
         if (AssistantBehaviour.Tutorial == false)
         {
             SetRespawnTime();
         }
     }
     else
     {
         transform.GetChild(2).GetComponent <Animator>().SetBool("Dead", false);
         transform.GetChild(2).localScale = new Vector3(0.27f, 0.27f);
         Alive.gameObject.SetActive(true);                                                                                           //gör ena enabled och den andra inte
         Dead.gameObject.SetActive(false);
         CurrentType          = ChooseType();                                                                                        //skaffa en ny citytype nu när den spawnar
         citySoundPlayer.clip = citySoundClips[0];
         Instantiate(rippleEffect, transform);
         citySoundPlayer.Play();
         respawnSet = false;
     }
 }
Ejemplo n.º 6
0
 public ArmyStructure(CityType requiredCityType, decimal buildCost, int capacity, UnitType unitType)
 {
     this.RequiredCityType = requiredCityType;
     this.BuildCost = buildCost;
     this.Capacity = capacity;
     this.UnitType = unitType;
 }
Ejemplo n.º 7
0
        public ActionResult CityType(CityType cityType)
        {
            ViewBag.Edit = cityType.Id != 0;

            if (cityType.Name.IsNullOrEmpty())
            {
                ModelState.AddModelError("Name", "Поле не может быть пустым");
            }

            if (!ModelState.IsValid)
            {
                return(View(cityType));
            }


            var session = NHibernateHelper.OpenSession();


            using (var tx = session.BeginTransaction())
            {
                session.SaveOrUpdate(cityType);

                tx.Commit();
            }

            return(RedirectToAction("Index"));
        }
 protected ArmyStructure(CityType requiredCityType, decimal buildCost, int capacity, UnitType unitType)
 {
     this.RequiredCityType = requiredCityType;
     this.BuildCost        = buildCost;
     this.Capacity         = capacity;
     this.UnitType         = unitType;
 }
Ejemplo n.º 9
0
        // public static T[] GetTypes<T>(this IConfigurationSection config) where T : IHaveDefaultField, IType, new() =>
        //     config.Get<TypeConfig[]>().Select(i => new T()
        //     {
        //         Name =  i.Name,
        //         ShortName = i.ShortName,
        //         Default = i.Default
        //     }).ToArray();

        public static City GetCity(this IConfigurationSection config)
        {
            var cityConfig = config.Get <CityConfig>();

            if (cityConfig == null)
            {
                return(null);
            }
            var cityTypeConfig = cityConfig.CityType;

            if (cityTypeConfig == null)
            {
                return(null);
            }
            var cityType = new CityType {
                Name      = cityTypeConfig.Name,
                ShortName = cityTypeConfig.ShortName,
                Default   = cityTypeConfig.Default
            };

            return(new City {
                Name = cityConfig.Name,
                CityType = cityType,
                Prefix = cityConfig.Prefix,
                Default = cityConfig.Default
            });
        }
Ejemplo n.º 10
0
    private CityType ChooseType()
    {
        CityType TmpType = CityType.NORMAL;                                                                                                //sätter en temporär variabel till normal

        if (LastAttackedBy == null)
        {
            return(TmpType);                                                                                                               //om den inte har blivit attackerad går tillbaka med citytype.normal
        }
        else if (LastAttackedBy == DamageKinds[0])                                                                                         //om det va en earthquake
        {
            TmpType = CityType.EARTHQUAKE;                                                                                                 //sätt till rätta variabler till type och dmgtype
            dmgDealer.damageType = DamageKinds[4];
        }
        else if (LastAttackedBy == DamageKinds[1])                                                                                        //om det va lightning
        {
            TmpType = CityType.LIGHTNING;                                                                                                 //sätt till rätta variabler till type och dmgtype
            dmgDealer.damageType = DamageKinds[5];
        }
        else if (LastAttackedBy == DamageKinds[2])                                                                                        //om det va en tornado
        {
            TmpType = CityType.TORNADO;                                                                                                   //sätt till rätta variabler till type och dmgtype
            dmgDealer.damageType = DamageKinds[6];
        }
        else if (LastAttackedBy == DamageKinds[3])                                                                                        //om det va en våg
        {
            TmpType = CityType.WATER;                                                                                                     //sätt till rätta variabler till type och dmgtype
            dmgDealer.damageType = DamageKinds[7];
        }
        return(TmpType);                                                                                                                  //skicka tillbakla temporär variabeln
    }
Ejemplo n.º 11
0
    public void UpgradeCity(CityType t_ct)
    {
        buyButton.gameObject.SetActive(false);

        switch (t_ct)
        {
        case CityType.airport:
            GetComponentInChildren <MeshFilter>().mesh         = airportMesh;
            GetComponentInChildren <MeshCollider>().sharedMesh = airportMesh;
            GetComponentInChildren <MeshFilter>().transform.eulerAngles.Set(0, 0, Random.Range(0, 360));
            cityType = CityType.airport;
            break;

        case CityType.harbor:
            GetComponentInChildren <MeshFilter>().mesh         = harborMesh;
            GetComponentInChildren <MeshCollider>().sharedMesh = harborMesh;
            cityType = CityType.harbor;
            break;

        default:
            break;
        }

        m_gm.money -= upgradeCost;
    }
Ejemplo n.º 12
0
        private void adminDivisionDowningHandler(Divinsion divinsion, CityType type, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                switch (type)
                {
                case CityType.Country:
                    foreach (string polyline in divinsion.polylines)
                    {
                        DataRow row = this.countryDataTable.NewRow();
                        row[0] = divinsion.name;
                        row[1] = polyline;
                        this.countryDataTable.Rows.Add(row);
                    }
                    break;

                case CityType.City:
                    foreach (string polyline in divinsion.polylines)
                    {
                        DataRow row = this.cityDataTable.NewRow();
                        row[0] = divinsion.name;
                        row[1] = polyline;
                        this.cityDataTable.Rows.Add(row);
                    }
                    break;

                case CityType.District:
                    foreach (string polyline in divinsion.polylines)
                    {
                        DataRow row = this.districtDataTable.NewRow();
                        row[0] = divinsion.name;
                        row[1] = polyline;
                        this.districtDataTable.Rows.Add(row);
                    }
                    break;

                case CityType.Province:
                    foreach (string polyline in divinsion.polylines)
                    {
                        DataRow row = this.provinceDataTable.NewRow();
                        row[0] = divinsion.name;
                        row[1] = polyline;
                        this.provinceDataTable.Rows.Add(row);
                    }
                    break;
                }
                labMessage.Text        = "提示:正在下载" + divinsion.name;
                this.progressBar.Value = index * 100 / count;
            };

            if (base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Ejemplo n.º 13
0
 public CityDTO(int id, string name, int level, CityType cityType, Location location)
 {
     Id       = id;
     Name     = name;
     Level    = level;
     CityType = new CityTypeDTO(cityType);
     Location = new LocationDTO(location);
 }
Ejemplo n.º 14
0
 public City(int id, string name, int level, CityType cityType, Location location)
 {
     Id       = id;
     Name     = name;
     Level    = level;
     CityType = cityType;
     Location = location;
 }
Ejemplo n.º 15
0
 public City(long iD, double latitude, double longitude, string name, CityType type)
 {
     ID        = iD;
     Latitude  = latitude;
     Longitude = longitude;
     Name      = name;
     Type      = type;
 }
Ejemplo n.º 16
0
 public PopulationNodeStats(string name, int control, List <float> factionsSupport, int population, CityType type)
 {
     PopulationNodeName = name;
     Control            = control;
     FactionsSupport    = factionsSupport;
     Population         = population;
     Type = type;
 }
Ejemplo n.º 17
0
        public void city_citysize_should_return_valid_citysize(CityType expected, string cityName, int poulation)
        {
            City myCity = new City
            {
                Name       = cityName,
                Population = poulation
            };

            Assert.AreEqual(expected, myCity.CitySize);
        }
 protected ArmyStructureBase(
     CityType cityType,
     decimal buildCost,
     int capacity,
     UnitType unitType)
 {
     this.RequiredCityType = cityType;
     this.BuildCost = buildCost;
     this.Capacity = capacity;
     this.UnitType = unitType;
 }
Ejemplo n.º 19
0
 public Place(int id, string city, string province, Region region, string country, CityType cityType,
              string maleDemonym, string femaleDemonym) : base(id)
 {
     City               = city;
     Province           = province;
     Region             = region;
     Country            = country;
     this.cityType      = cityType;
     this.maleDemonym   = maleDemonym;
     this.femaleDemonym = femaleDemonym;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化城市
        /// </summary>
        private void LoadCities()
        {
            List <City> cityList = new List <City>(MaxCities);

            FileLocation      fl     = FileSystem.Instance.Locate("cities.xml", GameFileLocs.Config);
            GameConfiguration resCon = new GameConfiguration(fl);

            GameConfiguration.ValueCollection resVals      = resCon.Values;
            Dictionary <string, City>         resolveTable = new Dictionary <string, City>(MaxCities);

            foreach (GameConfigurationSection sect in resVals)
            {
                City   city;
                string typestr = sect.GetString("Type", string.Empty).ToLowerInvariant();

                CityType type = City.ParseType(typestr);

                switch (type)
                {
                case CityType.Neutral:
                    city = new City(this, null, type);
                    break;

                case CityType.Oil:
                case CityType.Green:
                    city = new GatherCity(this, null, type);
                    break;

                case CityType.Disease:
                case CityType.Education:
                case CityType.Health:
                case CityType.Volience:
                    city = new ProductionCity(this, null, type);
                    break;

                default:
                    city = new City(this, null, type);
                    break;
                }

                city.Parse(sect);

                resolveTable.Add(sect.Name, city);
                cityList.Add(city);
            }

            for (int i = 0; i < cityList.Count; i++)
            {
                cityList[i].ResolveCities(resolveTable);
            }

            cities = cityList.ToArray();
        }
Ejemplo n.º 21
0
 public CityTypeDTO(CityType cityType)
 {
     Id             = cityType.Id;
     Name           = cityType.Name;
     OfficialName   = cityType.OfficialName;
     FictionalName  = cityType.FictionalName;
     Region         = cityType.Region;
     SeaConnection  = cityType.SeaConnection;
     RoadConnection = cityType.RoadConnection;
     Difficulty     = cityType.Difficulty;
     Description    = cityType.Description;
 }
Ejemplo n.º 22
0
 City GetCityByTypeAndFaction(CityType cityType, Faction faction)
 {
     foreach (City city in ObjectsManager.Instance.transform.Find("Map/Cities").GetComponentsInChildren <City>())
     {
         if (city.CityType == cityType && city.CityCurrentFaction == faction)
         {
             return(city);
         }
     }
     Debug.LogError("Failed to find city with " + cityType.ToString() + " type and " + faction.ToString() + " faction.");
     return(null);
 }
Ejemplo n.º 23
0
        private IEnumerable <CityType> GetCityTypesFromDataTable(DataTable dt)
        {
            List <CityType> cityTypes = new List <CityType>();

            foreach (DataRow row in dt.Rows)
            {
                CityType type = ConvertDataRowToCityType(row, "Id");

                cityTypes.Add(type);
            }

            return(cityTypes);
        }
Ejemplo n.º 24
0
    public void ChangePathType(PathType newType)
    {
        PathTypeState state = null;

        lastSetType = newType;
        switch (newType)
        {
        case PathType.city:
            state = new CityType();
            break;

        case PathType.desert:
            state = new DesertType();
            break;

        case PathType.field:
            state = new FieldType();
            break;

        case PathType.forest:
            state = new ForestType();
            break;

        case PathType.mountain:
            state = new MountainType();
            break;

        case PathType.road:
            state = new RoadType();
            break;

        case PathType.rocks:
            state = new RocksType();
            break;

        case PathType.swamp:
            state = new SwampType();
            break;

        case PathType.water:
            state = new WaterType();
            break;
        }

        if (_pathType != null)
        {
            _pathType.OnExitState();
        }
        _pathType = state;
        _pathType.OnEnterState(this);
    }
        /// <summary>
        /// Define preset settings based on a type
        /// </summary>
        private GenerationSettings GetSettingsFromPreset(CityType cityType)
        {
            var genSettings = new GenerationSettings();

            switch (cityType)
            {
            //Small
            case CityType.Village:
            {
                genSettings.Width                = 150;
                genSettings.Length               = 150;
                genSettings.PointAlgorithm       = PointGenerationAlgorithm.Simple;
                genSettings.Amount               = 20;
                _citySettings.GenerateInnerRoads = false;
                break;
            }

            //medium
            case CityType.Town:
            {
                genSettings.Width                = 200;
                genSettings.Length               = 200;
                genSettings.PointAlgorithm       = PointGenerationAlgorithm.Simple;
                genSettings.Amount               = 50;
                _citySettings.GenerateInnerRoads = true;
                break;
            }

            //large
            case CityType.Metropolis:
            {
                genSettings.Width          = 350;
                genSettings.Length         = 350;
                genSettings.PointAlgorithm = PointGenerationAlgorithm.CityLike;
                genSettings.Amount         = 100;
                break;
            }

            default:
                break;
            }

            //still allow seed to be used with presets
            genSettings.UseSeed = _generationSettings.UseSeed;
            genSettings.Seed    = _generationSettings.Seed;

            //prefer fortune algorithm for speed
            genSettings.VoronoiAlgorithm = VoronoiAlgorithm.Fortune;

            return(genSettings);
        }
Ejemplo n.º 26
0
        public ActionResult CityType(int id = 0)
        {
            ViewBag.Edit = id != 0;

            CityType cityType = new CityType();

            if (id != 0)
            {
                using (var repository = new NHRepository <CityType>())
                {
                    cityType = repository.Get(id);
                }
            }

            return(View(cityType));
        }
Ejemplo n.º 27
0
        private CityType ConvertDataRowToCityType(DataRow row, string idColumnName)
        {
            CityType type = new CityType(
                Convert.ToInt32(row[idColumnName].ToString()),
                row["Name"].ToString(),
                row["OfficialName"].ToString(),
                row["FictionalName"].ToString(),
                row["Region"].ToString(),
                Convert.ToBoolean(row["SeaConnection"].ToString()),
                Convert.ToBoolean(row["RoadConnection"].ToString()),
                row["Difficulty"].ToString(),
                row["Description"].ToString()
                );

            return(type);
        }
Ejemplo n.º 28
0
    public ForeignCity(ColonyLocation colony_data)
    {
        Id = current_id;
        current_id++;
        Name    = colony_data.Name;
        Opinion = 1.0f;
        Opinion_Resting_Point = -1.0f;
        Update_Opinion_Resting_Point();
        City_Type        = CityType.Colony;
        Trade_Route_Type = colony_data.Trade_Route_Type;

        Preferred_Imports  = colony_data.Preferred_Imports;
        Disliked_Imports   = colony_data.Disliked_Imports;
        Unaccepted_Imports = colony_data.Unaccepted_Imports;
        Exports            = colony_data.Exports;
        Cheap_Exports      = colony_data.Cheap_Exports;
        Expensive_Exports  = colony_data.Expensive_Exports;
    }
Ejemplo n.º 29
0
        static float ResetGenerateRBallCD(CityType ctype)
        {
            switch (ctype)
            {
            case CityType.Health:
                return(RulesTable.HealthBallGenInterval);

            case CityType.Volience:
                return(RulesTable.VolienceBallGenInterval);

            case CityType.Disease:
                return(RulesTable.DiseaseBallGenInterval);

            case CityType.Education:
                return(RulesTable.EducationBallGenInterval);
            }
            throw new InvalidOperationException();
        }
Ejemplo n.º 30
0
    // BuyCity and UpgradeCity could probably be merged in just one function
    private void BuyCity()
    {
        owned = true;
        buyButton.GetComponentInChildren <TextMeshProUGUI>().text = "Upgrade!";

        GetComponentInChildren <Renderer>().material = ownedMaterial;

        GetComponentInChildren <MeshFilter>().mesh         = warehouseMesh;
        GetComponentInChildren <MeshCollider>().sharedMesh = warehouseMesh;

        if (!onCoast)
        {
            GetComponentInChildren <MeshFilter>().transform.Rotate(new Vector3(0, 0, Random.Range(0, 360)));
        }

        cityType = CityType.warehouse;

        m_gm.money -= buyingCost;
    }
Ejemplo n.º 31
0
        //创建某个城市
        public static CityManager CreateCity(CityTalkRecord tbCity, CityType type, string name, bool isDad = true)
        {
            var cityId = tbCity.Id;
            var cm     = new CityManager();

            cm.mCityId  = cityId;
            cm.mType    = type;
            cm.CityName = name;
            if (isDad)
            {
                CityDads.Add(cm);
            }
            Citys[cityId] = cm;
            if (type == CityType.Son)
            {
                for (var i = 1; i <= tbCity.Param; i++)
                {
                    var cc = CreateChannel(cityId, ChannelType.System, string.Format("{0}{1}", name, i));
                    cm.cChannels.Add(cc.mGuid, cc);
                }
            }
            else
            {
                var tbSkillup = Table.GetSkillUpgrading(tbCity.Param);
                if (tbSkillup != null)
                {
                    foreach (var i in tbSkillup.Values)
                    {
                        var tbCT = Table.GetCityTalk(i);
                        if (tbCT == null)
                        {
                            continue;
                        }
                        cm.Citys.Add(CreateCity(tbCT, (CityType)tbCT.IsParent, tbCT.Name));
                    }
                }
                //var newCity = CreateCity(cityId * 100 + 1, CityType.Son, "测试1");
                //cm.Citys.Add(newCity);
                //newCity = CreateCity(cityId * 100 + 2, CityType.Son, "测试2");
                //cm.Citys.Add(newCity);
            }
            return(cm);
        }
Ejemplo n.º 32
0
 public ForeignCity(ForeignCitySaveData data)
 {
     Id = data.Id;
     if (Id >= current_id)
     {
         current_id = Id + 1;
     }
     Name    = data.Name;
     Opinion = data.Opinion;
     Opinion_Resting_Point = data.Opinion_Resting_Point;
     City_Type             = (CityType)data.City_Type;
     Trade_Route_Type      = (TradeRouteType)data.Trade_Route_Type;
     Preferred_Imports     = Make_Resource_List(data.Preferred_Imports);
     Disliked_Imports      = Make_Resource_List(data.Disliked_Imports);
     Unaccepted_Imports    = Make_Resource_List(data.Unaccepted_Imports);
     Exports           = Make_Resource_List(data.Exports);
     Cheap_Exports     = Make_Resource_List(data.Cheap_Exports);
     Expensive_Exports = Make_Resource_List(data.Expensive_Exports);
 }
Ejemplo n.º 33
0
    void UpdateCity(string city)
    {
        CityType   type     = CityType.Seashore;
        GameObject model    = null;
        GameObject oldModel = GameObject.FindGameObjectWithTag(Tags.cityModel);

        if (oldModel != null)
        {
            Destroy(oldModel);
        }

        foreach (Province pro in China.china)
        {
            if (pro.capital == city)
            {
                type = pro.type;
            }
            foreach (string c in pro.cities)
            {
                if (c == city)                 //非省会城市
                {
                    type = pro.type;
                }
            }
        }

        switch (type)
        {
        case CityType.Commercial:
            model = Instantiate(Resources.Load("CommercialCity")) as GameObject; break;

        case CityType.Seashore:
            model = Instantiate(Resources.Load("Seashore")) as GameObject; break;

        case CityType.Travel:
            model = Instantiate(Resources.Load("TravelCity")) as GameObject; break;

        default:
            model = Instantiate(Resources.Load("Seashore")) as GameObject; break;
        }
        //UnityEngine.SceneManagement.SceneManager.LoadScene(city);
    }
Ejemplo n.º 34
0
        public GatherCity(BattleField btfld, Player owner, CityType type)
            : base(btfld, owner, type)
        {
            harvester           = new Harvester(this, btfld.Map);
            harvester.GotHome  += Harv_Home;
            harvester.GotThere += Harv_Dest;

            Harvester.Props hprop = getHarvProps();
            harvester.SetProps(hprop);


            if (this.Type == CityType.Oil)
            {
                gatherDistance = RulesTable.OilGatherDistance;
            }
            else if (this.Type == CityType.Green)
            {
                gatherDistance = RulesTable.GreenGatherDistance;
            }
        }
Ejemplo n.º 35
0
        public GatherCity(BattleField btfld, Player owner, CityType type)
            : base(btfld, owner, type)
        {
            harvester = new Harvester(this, btfld.Map);
            harvester.GotHome += Harv_Home;
            harvester.GotThere += Harv_Dest;

            Harvester.Props hprop = getHarvProps();
            harvester.SetProps(hprop);

            
            if (this.Type == CityType.Oil)
            {
                gatherDistance = RulesTable.OilGatherDistance;
            }
            else if (this.Type == CityType.Green)
            {
                gatherDistance = RulesTable.GreenGatherDistance;
            }
           
        }
Ejemplo n.º 36
0
 public City(
     string name,
     IHouse controllingHouse,
     int defense,
     decimal upgradeCost,
     double initialFoodStorage,
     double foodProduction,
     decimal taxBase,
     CityType cityType = DefaultCityType)
 {
     this.Name = name;
     this.ControllingHouse = controllingHouse;
     this.Defense = defense;
     this.UpgradeCost = upgradeCost;
     this.FoodStorage = initialFoodStorage;
     this.FoodProduction = foodProduction;
     this.TaxBase = taxBase;
     this.availableMilitaryUnits = new List<IMilitaryUnit>();
     this.armyStructures = new List<IArmyStructure>();
     this.CityType = cityType;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strFolder"></param>
        /// <param name="blnIsIncremental"></param>
        /// <returns></returns>
        public string[] GetFilesList(CityType intCityType, FeedType intFeedType)
        {
            string strFolder = intCityType == CityType.Aiken ? Constant.AIKEN_DOWNLOAD_FOLDER : Constant.AUGUSTA_DOWNLOAD_FOLDER;
            string[] arrFilePaths = Directory.GetFiles(strFolder, "*.csv");
            List<string> listFilePaths = new List<string>();

            for(int intIndex = 0; intIndex < arrFilePaths.Length; intIndex++)
            {
                if(arrFilePaths[intIndex].Contains("Inc.csv") && this.blnIsIncremental)
                {
                    if ((intFeedType == FeedType.Residential && arrFilePaths[intIndex].Contains("_RES"))
                     || (intFeedType == FeedType.Land && arrFilePaths[intIndex].Contains("_LAND")))
                    {
                        listFilePaths.Add(arrFilePaths[intIndex]);
                    }
                }
                else if (!arrFilePaths[intIndex].Contains("Inc.csv") && !this.blnIsIncremental)
                {
                    if ((intFeedType == FeedType.Residential && arrFilePaths[intIndex].Contains("_RES"))
                     || (intFeedType == FeedType.Land && arrFilePaths[intIndex].Contains("_LAND")))
                    {
                        listFilePaths.Add(arrFilePaths[intIndex]);
                    }
                    else if (intFeedType == FeedType.Agent && arrFilePaths[intIndex].Contains("_Agents"))
                    {
                        listFilePaths.Add(arrFilePaths[intIndex]);
                    }
                    else if (intFeedType == FeedType.Office && arrFilePaths[intIndex].Contains("_Offices"))
                    {
                        listFilePaths.Add(arrFilePaths[intIndex]);
                    }
                }
            }

            if (!this.blnIsIncremental)
            {
                if (Constant.FILE_COUNT.ContainsKey(intCityType + "_" + intFeedType)) {
                    if (Constant.FILE_COUNT[intCityType + "_" + intFeedType] != listFilePaths.Count)
                    {
                        bFatalError = true;
                        this.WriteToLog("<br /><b><i style=\"color:red;\">Missing file for " + Enum.GetName(typeof(CityType), intCityType) + " " + Enum.GetName(typeof(FeedType), intFeedType) + "</i></b>");
                        this.bBlockPropertyPurge = true;
                    }
                }
            }

            return listFilePaths.ToArray();
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Define preset settings based on a type
        /// </summary>
        private GenerationSettings GetSettingsFromPreset(CityType cityType)
        {
            var genSettings = new GenerationSettings();

            switch (cityType)
            {
                //Small
                case CityType.Village:
                    {
                        genSettings.Width = 150;
                        genSettings.Length = 150;
                        genSettings.PointAlgorithm = PointGenerationAlgorithm.Simple;
                        genSettings.Amount = 20;
                        _citySettings.GenerateInnerRoads = false;
                        break;
                    }

                //medium
                case CityType.Town:
                    {
                        genSettings.Width = 200;
                        genSettings.Length = 200;
                        genSettings.PointAlgorithm = PointGenerationAlgorithm.Simple;
                        genSettings.Amount = 50;
                        _citySettings.GenerateInnerRoads = true;
                        break;
                    }

                //large
                case CityType.Metropolis:
                    {
                        genSettings.Width = 350;
                        genSettings.Length = 350;
                        genSettings.PointAlgorithm = PointGenerationAlgorithm.CityLike;
                        genSettings.Amount = 100;
                        break;
                    }
                default:
                    break;
            }

            //still allow seed to be used with presets
            genSettings.UseSeed = _generationSettings.UseSeed;
            genSettings.Seed = _generationSettings.Seed;

            //prefer fortune algorithm for speed
            genSettings.VoronoiAlgorithm = VoronoiAlgorithm.Fortune;

            return genSettings;
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Adjust settings that generate the voronoi diagram
        /// </summary>
        private void GenerationSettings()
        {
            //foldout settings
            _foldoutSettings = EditorGUILayout.Foldout(_foldoutSettings, "Generation Settings", _foldoutStyle);
            if (!_foldoutSettings)
            {
                return;
            }

            EditorGUI.indentLevel++;

            //SEED
            _generationSettings.UseSeed = EditorGUILayout.Toggle("Use Seed", _generationSettings.UseSeed);
            if (_generationSettings.UseSeed)
            {
                _generationSettings.Seed = EditorGUILayout.IntField("Seed", _generationSettings.Seed);
            }

            //PARENT
            //_townGenerator.Parent = (GameObject)EditorGUILayout.ObjectField("Parent", _townGenerator.Parent, typeof(GameObject), true);

            //PRESETS
            _cityType = (CityType)EditorGUILayout.EnumPopup("Preset", _cityType);

            //ADVANCED SETTINGS
            _showAdvancedSettings = EditorGUILayout.Toggle("Advanced Settings", _showAdvancedSettings);
            if (_showAdvancedSettings)
            {
                //Width and Height
                _generationSettings.Width = EditorGUILayout.IntField("Size", (int)_generationSettings.Width);
                _generationSettings.Length = _generationSettings.Width;
                _generationSettings.Amount = EditorGUILayout.IntField("Amount of Points",
                    (int)_generationSettings.Amount);
            }
            EditorGUI.indentLevel--;
        }
Ejemplo n.º 40
0
        public City(BattleField btfld, Player owner, CityType type)
            : base(owner, btfld)
        {
            this.battleField = btfld;
            this.Type = type;


            BoundingSphere.Radius = CityRadius;
        }
Ejemplo n.º 41
0
 public DataTable GetCityData(CityType type, string parent)
 {
     DataTable data = new DataTable();
     try
     {
         string sqlString = string.Empty;
         SQLiteParameter[] parameters = null;
         City city = new City();
         switch (type)
         {
             case CityType.Sheng:
                 sqlString = "select Name  from t_city where ShengParent IS NULL and ShiParent IS NULL and Code IS NULL";
                 break;
             case CityType.Shi:
                 sqlString = "select Name  from t_city where ShengParent=@ShengParent and ShiParent IS NULL and Code IS NULL";
                 parameters = new SQLiteParameter[]{
                                  new SQLiteParameter("@ShengParent",parent)
                                  };
                 break;
             case CityType.Xian:
                 sqlString = "select Name,Code  from t_city where ShiParent=@ShiParent";
                 parameters = new SQLiteParameter[]{
                                  new SQLiteParameter("@ShiParent",parent)
                                  };
                 break;
         }
         SqlAction action = new SqlAction();
         data = action.DataTableQuery(sqlString, parameters);
     }
     catch (Exception ex)
     {
         log.WriteLog(ex.ToString());
     }
     return data;
 }
Ejemplo n.º 42
0
 static float ResetGenerateRBallCD(CityType ctype)
 {
     switch (ctype)
     {
         case CityType.Health:
             return RulesTable.HealthBallGenInterval;
         case CityType.Volience:
             return RulesTable.VolienceBallGenInterval;
         case CityType.Disease:
             return RulesTable.DiseaseBallGenInterval;
         case CityType.Education:
             return RulesTable.EducationBallGenInterval;
     }
     throw new InvalidOperationException();
 }
Ejemplo n.º 43
0
 public ProductionCity(BattleField btfld, Player owner, CityType type)
     : base(btfld, owner, type)
 {
     generateRBallTime = ResetGenerateRBallCD(Type);
     generateRBallCD = generateRBallTime;
 }