Example #1
0
        public static void CalculateFromLocalData()
        {
            DateTime dtnew   = DateTime.Now;
            int      nCities = BUSCity.Count();

            for (int i = 0; i < nCities; i++)
            {
                DTOCity  ct = BUSCity.GetResourceCity(i);
                TimeSpan tp = new TimeSpan(dtnew.Ticks - ct.DTResourceCity.Ticks);

                //cap nhat dan - townhall
                ct.FreePopulation += updateValue(ct.PopulationGrow, (float)tp.TotalSeconds);
                ct.Population      = updateValueHaveLimit(ct.Population, ct.PopulationLimit, ct.PopulationGrow, (float)tp.TotalSeconds);

                //cap nhat res
                ct.Wood    = updateValueHaveLimit(ct.Wood, ct.WoodLimit, ct.WoodPerHour, (float)tp.TotalSeconds);
                ct.Wine    = updateValueHaveLimit(ct.Wine, ct.WineLimit, ct.WinePerHour, (float)tp.TotalSeconds);
                ct.Marble  = updateValueHaveLimit(ct.Marble, ct.MarbleLimit, ct.MarblePerHour, (float)tp.TotalSeconds);
                ct.Crystal = updateValueHaveLimit(ct.Crystal, ct.CrystalLimit, ct.CrystalPerHour, (float)tp.TotalSeconds);
                ct.Sulphur = updateValueHaveLimit(ct.Sulphur, ct.SulphurLimit, ct.SulphurPerHour, (float)tp.TotalSeconds);

                //cap nhat cooldown cac building

                //cap nhat lai thoi gian
                ct.DTResourceCity = dtnew;
                ct.DTTownHall     = dtnew;
                Gloval.Database.Account.Cities[i] = ct;
            }
        }
Example #2
0
        public static void requestTownHall(int iIndexCity)
        {
            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                BUSCity.ChangeCityTo(iIndexCity);

                if (Gloval.Database.CurrentView != Data.SITE_VIEW.TOWN_HALL)
                {
                    if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                    {
                        BUSCity.GoToCity();
                    }

                    BUSCity.GoToTownHall();
                }

                Gloval.Database.Account.Cities[iIndexCity].DTTownHall = DateTime.Now;

                //lấy thông tin
                long  PopulationLimit;
                float PopulationGrow;
                long  GoldPerHour;
                int   ResearchPointPerHour;
                DAOCity.GetTownHallInfomation(iIndexCity,
                                              out PopulationLimit,
                                              out PopulationGrow,
                                              out GoldPerHour,
                                              out ResearchPointPerHour);

                Gloval.Database.Account.Cities[iIndexCity].PopulationLimit      = PopulationLimit;
                Gloval.Database.Account.Cities[iIndexCity].PopulationGrow       = PopulationGrow;
                Gloval.Database.Account.Cities[iIndexCity].GoldPerHour          = GoldPerHour;
                Gloval.Database.Account.Cities[iIndexCity].ResearchPointPerHour = ResearchPointPerHour;
            }
        }
Example #3
0
        public static void AutoRequestBuildings()
        {
            //force update building
            int nCities = BUSCity.Count();

            for (int i = 0; i < nCities; i++)
            {
                BUSBuilding.ForceUpdate(i);
            }

            Gloval.bBuildingsOverviewIsNewData = true;
        }
Example #4
0
 public static void requestBuilding(int iIndexCity)
 {
     if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
     {
         BUSCity.ChangeCityTo(iIndexCity);
         if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
         {
             BUSCity.GoToCity();
         }
         //cap nhat thoi gian update tu ika server
         Gloval.Database.Account.Cities[iIndexCity].DTBuilding   = DateTime.Now;
         Gloval.Database.Account.Cities[iIndexCity].ListBuilding = DAOBuilding.GetBuildingCity();
     }
 }
Example #5
0
        //town hall info
        public static void ForceUpdateTownHall(int iIndexCity)
        {
            BUSCity.ChangeCityTo(iIndexCity, true);
            if (Gloval.Database.CurrentView != Data.SITE_VIEW.TOWN_HALL)
            {
                if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                {
                    DAOCity.GoToCity();
                }

                DAOCity.GoToTownHall();
            }

            Gloval.Database.Account.Cities[iIndexCity].DTTownHall = DateTime.Now;

            //lấy thông tin
            DAOCity.GetTownHallInfomation(iIndexCity);
        }
Example #6
0
        public static void requestUnits(int iIndexCity)
        {
            BUSCity.ChangeCityTo(iIndexCity);
            if (Gloval.Database.CurrentView != Data.SITE_VIEW.TROOPS)
            {
                if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                {
                    BUSCity.GoToCity();
                }

                //nhảy vào trang troops
                BUSTroops.GoToTroops();
            }

            Gloval.Database.Account.Cities[iIndexCity].DTTroopUnits = DateTime.Now;
            //lấy thông tin
            Gloval.Database.Account.Cities[iIndexCity].ListTroopsUnits = DAOTroops.ParseUnits(iIndexCity);
        }
Example #7
0
        public static void AutoRequestTroops()
        {
            //force unit
            int nCities = BUSCity.Count();

            for (int i = 0; i < nCities; i++)
            {
                BUSTroops.ForceUpdateUnits(i);
            }

            //force update ships
            for (int i = 0; i < nCities; i++)
            {
                BUSTroops.ForceUpdateShips(i);
            }

            Gloval.bTroopsOverviewIsNewData = true;
        }
Example #8
0
        public static string requestTownsFromGadget()
        {
            //if (Gloval.bEmpireOverviewIsNewData)
            //{
            ////cap nhat thong tin dang luu tru phu` hop voi thoi diem hien ta
            BUSCity.CalculateFromLocalData();

            //cap nhat lai thanh du lieu cu
            //de gadget khong lay lai lan nua
            Gloval.bEmpireOverviewIsNewData = false;

            //lay du lieu moi update cho gadget
            //return JsonConvert.SerializeObject(Gloval.Database.Account.Cities);
            //return "new data";
            return(JsonConvert.SerializeObject(Gadget.CityToEmpire(Gloval.Database.Account.Cities)));
            //}

            //return "";
        }
Example #9
0
        public static void ForceUpdateUnits(int iIndexCity)
        {
            BUSCity.ChangeCityTo(iIndexCity, true);
            if (Gloval.Database.CurrentView != Data.SITE_VIEW.TROOPS)
            {
                if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                {
                    DAOCity.GoToCity();
                }

                //nhảy vào trang troops
                DAOTroops.GoToTroops();
            }

            Gloval.Database.Account.Cities[iIndexCity].DTTroopUnits = DateTime.Now;

            //lấy thông tin
            DAOTroops.GetUnits(iIndexCity);
        }
Example #10
0
        public static void AutoRequestEmpireOverview()
        {
            //get res all city
            int nCities = BUSCity.Count();

            for (int i = 0; i < nCities; i++)
            {
                BUSCity.GetResourceCity(i, true);
            }

            //get townhall inf all city
            for (int i = 0; i < nCities; i++)
            {
                BUSCity.GetTownHallInfomationInCity(i, true);
            }

            //event
            BUSEvent.ForceUpdate();

            Gloval.bEmpireOverviewIsNewData = true;
        }
Example #11
0
        public static void AutoRequestEmpireOverview(Gadget gg)
        {
            DebuggingAndTracking.Debug.Logging("AutoRequestEmpireOverview start");
            //get res all city
            int nCities = Gloval.Database.Account.Cities.Count();

            for (int i = 0; i < nCities; i++)
            {
                if (gg.bStopAutoRequest)
                {
                    return;
                }
                BUSCity.requestResourceCity(i);
                if (gg.bStopAutoRequest)
                {
                    return;
                }
                BUSCity.requestTownHall(i);
            }

            Gloval.bEmpireOverviewIsNewData = true;
            DebuggingAndTracking.Debug.Logging("AutoRequestEmpireOverview Done");
        }
        public static int Count(int iIndexCity)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                if (Gloval.Database.Account.Cities[iIndexCity].ListBuilding == null)
                {
                    BUSCity.ChangeCityTo(iIndexCity);
                    if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                    {
                        DAOCity.GoToCity();
                    }
                    DAOBuilding.GetBuildingCity(iIndexCity);
                }

                return(Gloval.Database.Account.Cities[iIndexCity].ListBuilding.Count());
            }

            return(-1);
        }