public void ShowPersonCreation(CityInfo selectedCity)
 {
     var screen = new PersonSelectionEdit();
     screen.SelectedCity = selectedCity;
     GameFacade.Screens.RemoveCurrent();
     GameFacade.Screens.AddScreen(screen);
 }
 /// <summary>
 /// Print information about the new city that was found
 /// </summary>
 /// <param name="city"></param>
 /// <param name="cityInfo"></param>
 public void PrintAddedCity(City city, CityInfo cityInfo)
 {
     PrintBreak();
     textBox.Dispatcher.Invoke(
         new Action(delegate()
             {
                 textBox.Text += string.Format("Add new city: {0}\n",
                     city.getName());
                 textBox.Text += string.Format("Distance from start: {0:0.##}\n",
                     cityInfo.FromStart);
                 textBox.Text += string.Format("Estimated path length: {0:0.##}\n",
                     cityInfo.PathDistance);
             }),
         DispatcherPriority.Normal, null);
 }
Example #3
0
    private static void RunSolution20160130001A() {
      string[] tokens_n = Console.ReadLine().Split(' ');
      int n = Convert.ToInt32(tokens_n[0]);
      int m = Convert.ToInt32(tokens_n[1]);
      string[] c_temp = Console.ReadLine().Split(' ');
      int[] c = Array.ConvertAll(c_temp, Int32.Parse);

      CityInfo[] ListOfCities = new CityInfo[n];
      int maxDistance = 0;
      int revisedMaxDistance = 0;
      int previousSpaceStationIndex = -1;

      for (int cityIndex = 0; cityIndex < n; cityIndex++) {
        CityInfo cityInfo = new CityInfo() { CityIndex = cityIndex };
        if (c.Contains(cityIndex)) {
          cityInfo.HasSpaceStation = true;
          previousSpaceStationIndex = cityIndex;
          for (int previousCityIndex = cityIndex - 1; previousCityIndex >= 0; previousCityIndex--) {
            if (ListOfCities[previousCityIndex].NearestDistance > (cityIndex - previousCityIndex)) {
              ListOfCities[previousCityIndex].NearestDistance = (cityIndex - previousCityIndex);
            } else {
              //maxDistance = ListOfCities[previousCityIndex].NearestDistance;
              if (maxDistance > ListOfCities[previousCityIndex].NearestDistance) {
                revisedMaxDistance = ListOfCities[previousCityIndex].NearestDistance;
              }
              break;
            }
          }
        }
        if (previousSpaceStationIndex == -1) {

        } else {
          if (!cityInfo.HasSpaceStation) {
            cityInfo.NearestDistance = cityIndex - previousSpaceStationIndex;
            if (cityInfo.NearestDistance > maxDistance) {
              maxDistance = cityInfo.NearestDistance;
            }
          }
        }

        ListOfCities[cityIndex] = cityInfo;
      }

      maxDistance = ListOfCities.Select(x => x.NearestDistance).Max();

      Console.WriteLine(maxDistance);
    }
        /// <summary>
        /// Creates a new CityTransitionScreen.
        /// </summary>
        /// <param name="SelectedCity">The city being transitioned to.</param>
        /// <param name="CharacterCreated">If transitioning from CreateASim, this should be true.
        /// A CharacterCreateCity packet will be sent to the CityServer. Otherwise, this should be false.
        /// A CityToken packet will be sent to the CityServer.</param>
        public CityTransitionScreen(CityInfo SelectedCity, bool CharacterCreated)
        {
            m_SelectedCity = SelectedCity;
            m_CharacterCreated = CharacterCreated;

            /**
             * Scale the whole screen to 1024
             */
            m_BackgroundCtnr = new UIContainer();
            m_BackgroundCtnr.ScaleX = m_BackgroundCtnr.ScaleY = ScreenWidth / 800.0f;

            /** Background image **/
            m_Background = new UIImage(GetTexture((ulong)FileIDs.UIFileIDs.setup));
            m_Background.ID = "Background";
            m_BackgroundCtnr.Add(m_Background);

            var lbl = new UILabel();
            lbl.Caption = "Version "+GlobalSettings.Default.ClientVersion;
            lbl.X = 20;
            lbl.Y = 558;
            m_BackgroundCtnr.Add(lbl);
            this.Add(m_BackgroundCtnr);

            m_LoginProgress = new UILoginProgress();
            m_LoginProgress.X = (ScreenWidth - (m_LoginProgress.Width + 20));
            m_LoginProgress.Y = (ScreenHeight - (m_LoginProgress.Height + 20));
            m_LoginProgress.Opacity = 0.9f;
            this.Add(m_LoginProgress);

            NetworkFacade.Controller.OnNetworkError += new NetworkErrorDelegate(Controller_OnNetworkError);

            LoginArgsContainer LoginArgs = new LoginArgsContainer();
            LoginArgs.Username = NetworkFacade.Client.ClientEncryptor.Username;
            LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
            LoginArgs.Enc = NetworkFacade.Client.ClientEncryptor;

            NetworkFacade.Client = new NetworkClient(SelectedCity.IP, SelectedCity.Port);
            //THIS IS IMPORTANT - THIS NEEDS TO BE COPIED AFTER IT HAS BEEN RECREATED FOR
            //THE RECONNECTION TO WORK!
            LoginArgs.Client = NetworkFacade.Client;
            NetworkFacade.Client.OnConnected += new OnConnectedDelegate(Client_OnConnected);
            NetworkFacade.Controller.Reconnect(ref NetworkFacade.Client, SelectedCity, LoginArgs);

            NetworkFacade.Controller.OnCharacterCreationStatus += new OnCharacterCreationStatusDelegate(Controller_OnCharacterCreationStatus);
            NetworkFacade.Controller.OnCityTransferProgress += new OnCityTransferProgressDelegate(Controller_OnCityTransfer);
        }
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P)
        {
            Logger.LogInfo("CityServer logged in!\r\n");

            string Name = P.ReadString();
            string Description = P.ReadString();
            string IP = P.ReadString();
            int Port = P.ReadInt32();
            CityInfoStatus Status = (CityInfoStatus)P.ReadByte();
            ulong Thumbnail = P.ReadUInt64();
            string UUID = P.ReadString();
            ulong Map = P.ReadUInt64();

            CityInfo Info = new CityInfo(true);
            Info.Name = Name;
            Info.Description = Description;
            Info.IP = IP;
            Info.Port = Port;
            Info.Status = Status;
            Info.Thumbnail = Thumbnail;
            Info.UUID = UUID;
            Info.Map = Map;
            Info.Client = Client;
            Info.Online = true;

            NetworkFacade.CServerListener.CityServers.Add(Info);
            NetworkFacade.CServerListener.PotentialLogins.TryTake(out Client);

            NetworkClient[] Clients = new NetworkClient[NetworkFacade.ClientListener.Clients.Count];
            NetworkFacade.ClientListener.Clients.CopyTo(Clients, 0);

            PacketStream ClientPacket = new PacketStream((byte)PacketType.NEW_CITY_SERVER, 0);
            ClientPacket.WriteString(Name);
            ClientPacket.WriteString(Description);
            ClientPacket.WriteString(IP);
            ClientPacket.WriteInt32(Port);
            ClientPacket.WriteByte((byte)Status);
            ClientPacket.WriteUInt64(Thumbnail);
            ClientPacket.WriteString(UUID);
            ClientPacket.WriteUInt64(Map);

            foreach(NetworkClient Receiver in Clients)
                Receiver.SendEncrypted((byte)PacketType.NEW_CITY_SERVER, ClientPacket.ToArray());
        }
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P)
        {
            CityServerClient CityClient = (CityServerClient)Client;

            Logger.LogInfo("CityServer logged in!\r\n");

            string Name = P.ReadString();
            string Description = P.ReadString();
            string IP = P.ReadString();
            int Port = P.ReadInt32();
            CityInfoStatus Status = (CityInfoStatus)P.ReadByte();
            ulong Thumbnail = P.ReadUInt64();
            string UUID = P.ReadString();
            ulong Map = P.ReadUInt64();

            CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);
            Info.Status = Status;
            CityClient.ServerInfo = Info;

            //Client instance changed, so update it...
            NetworkFacade.CServerListener.UpdateClient(CityClient);
        }
 /// <summary>
 /// Reconnects to a CityServer.
 /// </summary>
 public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs)
 {
     Client.Disconnect();
     Client.Connect(LoginArgs);
 }
Example #8
0
        public List <WeatherInfo> GetWeatherInfoList(CityInfo city)
        {
            List <WeatherInfo> result = new List <WeatherInfo>();

            using (var driver = new PhantomJSDriver())
            {
                foreach (var day in _days)
                {
                    var baseUri = new Uri(city.Url);
                    driver.Navigate().GoToUrl(new Uri(baseUri, day));

                    var culture  = driver.GetInnerElementAtributeValue("body", "class").Split(' ').Skip(2).FirstOrDefault();
                    var baseNode = driver.GetInnerElement("div", "class", "main")
                                   .GetInnerElement("div", "class", "column-wrap")
                                   .GetInnerElement("div", "class", "__frame_sm")
                                   .GetInnerElement("div", "class", "forecast_frame hw_wrap");

                    var baseDate = baseNode.GetInnerElement("div", "class", "tab  tooltip")
                                   .GetInnerElement("div", "class", "tab_wrap")
                                   .GetInnerElement("div", "class", "tab-content");

                    var date = (baseDate.GetInnerElementText("div", "class", "date ") ??
                                baseDate.GetInnerElementText("div", "class", "date weekend"))
                               ?.Split(',')
                               .LastOrDefault()
                               ?.Trim();

                    if (string.IsNullOrWhiteSpace(date))
                    {
                        continue;
                    }

                    var detailsNode = baseNode.GetInnerElement("div", "class", "widget js_widget")
                                      .GetInnerElement("div", "class", "widget__body")
                                      .GetInnerElement("div", "class", "widget__container");

                    var hours = detailsNode.GetInnerElement("div", "class", "widget__row widget__row_time")
                                .GetInnerElements("div", "class", "widget__item");

                    var icons = detailsNode.GetInnerElement("div", "class", "widget__row widget__row_table widget__row_icon")
                                .GetInnerElements("div", "class", "widget__item");

                    var temps = detailsNode.GetInnerElement("div", "class", "widget__row widget__row_table widget__row_temperature")
                                .GetInnerElement("div", "class", "templine w_temperature")
                                .GetInnerElement("div", "class", "chart chart__temperature")
                                .GetInnerElement("div", "class", "values")
                                .GetInnerElements("div", "class", "value");

                    var winds = detailsNode.GetInnerElement("div", "class", "widget__row widget__row_table widget__row_wind-or-gust")
                                .GetInnerElements("div", "class", "widget__item");

                    var precs = detailsNode.GetInnerElement("div", "class", "widget__row widget__row_table widget__row_precipitation")
                                .GetInnerElements("div", "class", "widget__item");

                    var maxlen = new[] { hours.Count, icons.Count, temps.Count, winds.Count, precs.Count }.Max();

                    var wlist = new List <HourDetails>(Enumerable.Range(0, maxlen).Select(r => new HourDetails()));

                    for (int i = 0; i < maxlen; i++)
                    {
                        var hr = hours.ByInd(i);
                        if (hr != null)
                        {
                            var h = hr.GetInnerElement("div", "class", "w_time").FindElement(By.TagName("span")).Text;
                            var m = hr.GetInnerElement("div", "class", "w_time").FindElement(By.TagName("sup")).Text;
                            if (int.TryParse(h, out var hi) && int.TryParse(m, out var mi))
                            {
                                wlist[i].Time = TimeSpan.FromMinutes(hi * 60 + mi);
                            }
                        }

                        var ic = icons.ByInd(i);
                        if (ic != null)
                        {
                            var svg = ic.GetInnerElement("div", "class", "widget__value w_icon")
                                      .GetInnerElement("span", "class", "tooltip")
                                      .GetAttribute("innerHTML");   // Сакральные знания...
                            wlist[i].IconSvg = svg;
                        }

                        var tm = temps.ByInd(i);
                        if (tm != null)
                        {
                            var t = tm.GetInnerElementText("span", "class", "unit unit_temperature_c");
                            if (double.TryParse(t, out var td))
                            {
                                wlist[i].Temperature = td;
                            }
                        }

                        var wn = winds.ByInd(i);
                        if (wn != null)
                        {
                            var w = wn.GetInnerElement("div", "class", "w_wind")
                                    .GetInnerElement("div", "class", "w_wind__warning w_wind__warning_ ")
                                    .GetInnerElementText("span", "class", "unit unit_wind_m_s");
                            wlist[i].WindText = w;
                        }

                        var pc = precs.ByInd(i);
                        if (pc != null)
                        {
                            var t = pc.GetInnerElement("div", "class", "w_prec")
                                    .GetInnerElementText("div", "class", "w_prec__value");
                            if (double.TryParse(t, out var td))
                            {
                                wlist[i].Humidity = td;
                            }
                        }
                    }

                    result.Add(new WeatherInfo()
                    {
                        CurrDate        = DateTime.ParseExact(date, new[] { "d MMM", "d MMM y", "d MMM yyyy" }, CultureInfo.GetCultureInfo(culture), DateTimeStyles.None),
                        DetailedWeather = new DetailedWeather()
                        {
                            WeatherByHours = new SortedDictionary <TimeSpan, HourDetails>(wlist.ToDictionary(x => x.Time))
                        },
                    });
                }
                driver.Quit();
                return(result);
            }
        }
Example #9
0
        /// <summary>
        /// Creates a new CityTransitionScreen.
        /// </summary>
        /// <param name="SelectedCity">The city being transitioned to.</param>
        /// <param name="CharacterCreated">If transitioning from CreateASim, this should be true.
        /// A CharacterCreateCity packet will be sent to the CityServer. Otherwise, this should be false.
        /// A CityToken packet will be sent to the CityServer.</param>
        public CityTransitionScreen(CityInfo SelectedCity, bool CharacterCreated)
        {
            m_SelectedCity     = SelectedCity;
            m_CharacterCreated = CharacterCreated;

            /**
             * Scale the whole screen to 1024
             */
            m_BackgroundCtnr        = new UIContainer();
            m_BackgroundCtnr.ScaleX = m_BackgroundCtnr.ScaleY = ScreenWidth / 800.0f;

            /** Background image **/
            m_Background    = new UIImage(GetTexture((ulong)FileIDs.UIFileIDs.setup));
            m_Background.ID = "Background";
            m_BackgroundCtnr.Add(m_Background);

            var lbl = new UILabel();

            lbl.Caption = "Version " + GlobalSettings.Default.ClientVersion;
            lbl.X       = 20;
            lbl.Y       = 558;
            m_BackgroundCtnr.Add(lbl);
            this.Add(m_BackgroundCtnr);

            m_LoginProgress         = new UILoginProgress();
            m_LoginProgress.X       = (ScreenWidth - (m_LoginProgress.Width + 20));
            m_LoginProgress.Y       = (ScreenHeight - (m_LoginProgress.Height + 20));
            m_LoginProgress.Opacity = 0.9f;
            this.Add(m_LoginProgress);

            /*lock(NetworkFacade.Controller)
             *  NetworkFacade.Controller.OnNetworkError += new NetworkErrorDelegate(Controller_OnNetworkError);*/

            lock (NetworkFacade.Client)
            {
                lock (NetworkFacade.Client.ClientEncryptor)
                {
                    LoginArgsContainer LoginArgs = new LoginArgsContainer();
                    LoginArgs.Username = NetworkFacade.Client.ClientEncryptor.Username;
                    LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
                    LoginArgs.Enc      = NetworkFacade.Client.ClientEncryptor;

                    NetworkFacade.Client = new NetworkClient(SelectedCity.IP, SelectedCity.Port,
                                                             GonzoNet.Encryption.EncryptionMode.AESCrypto, true);
                    //This might not fix decryption of cityserver's packets, but it shouldn't make things worse...
                    NetworkFacade.Client.ClientEncryptor = LoginArgs.Enc;
                    //THIS IS IMPORTANT - THIS NEEDS TO BE COPIED AFTER IT HAS BEEN RECREATED FOR
                    //THE RECONNECTION TO WORK!
                    LoginArgs.Client = NetworkFacade.Client;
                    NetworkFacade.Client.OnConnected += new OnConnectedDelegate(Client_OnConnected);
                    NetworkFacade.Controller.Reconnect(ref NetworkFacade.Client, SelectedCity, LoginArgs);
                }
            }

            lock (NetworkFacade.Controller)
            {
                NetworkFacade.Controller.OnCharacterCreationStatus += new OnCharacterCreationStatusDelegate(Controller_OnCharacterCreationStatus);
                NetworkFacade.Controller.OnCityTransferProgress    += new OnCityTransferProgressDelegate(Controller_OnCityTransfer);
                NetworkFacade.Controller.OnLoginNotifyCity         += new OnLoginNotifyCityDelegate(Controller_OnLoginNotifyCity);
                NetworkFacade.Controller.OnLoginSuccessCity        += new OnLoginSuccessCityDelegate(Controller_OnLoginSuccessCity);
                NetworkFacade.Controller.OnLoginFailureCity        += new OnLoginFailureCityDelegate(Controller_OnLoginFailureCity);
                NetworkFacade.Controller.OnNetworkError            += new NetworkErrorDelegate(Controller_OnNetworkError);
            }
        }
Example #10
0
        // POST https://your-domain/api/DatabasedNotify
        public void Post([ModelBinder(typeof(RedcapDETModelBinderProvider))] RedcapDET redcapDet)
        {
            RedcapAccess rc = new RedcapAccess();

            Log.InfoFormat("DotNetDETs triggered for project {0}, instrument {1}", redcapDet.project_id, redcapDet.instrument);

            switch (redcapDet.instrument)
            {
            case redcapSurvey:
                List <Dictionary <string, string> > recordList = new List <Dictionary <string, string> >();

                string errorMessage = string.Empty;
                string recordId     = redcapDet.record;
                // This is the field for this example that we are using to determine
                // which DAG to put the survey in AND which site coordinator to send an email notification.
                string cityField = "cityfield";

                if (redcapDet.complete_flag == "2")
                {
                    Log.InfoFormat("Using GetRedcapData to retrieve record {0}", recordId);
                    try
                    {
                        recordList = rc.GetRedcapData(token, recordId, $"subject_id,{cityField}", "", "", false, false, false, false, true, "", "");
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorFormat("GetRedcapData Exception: {0}", ex.Message);
                    }

                    CityInfo ci = GetContactForCity(recordList[0][cityField], recordId);

                    if (ci.Dag != string.Empty)
                    {
                        // Remove cityField so as not to resave the value
                        // Set data access group
                        recordList[0]["redcap_data_access_group"] = ci.Dag;
                        recordList[0][cityField] = string.Empty;     // to prevent overwriting with same value
                        Log.InfoFormat("Attempting PostRedcapData");
                        try
                        {
                            rc.PostRedcapData(token, JsonConvert.SerializeObject(recordList), false, "MDY");
                        }
                        catch (Exception ex)
                        {
                            Log.ErrorFormat("PostRedcapData Exception: {0}", ex.Message);
                        }
                    }

                    // Now email the contact
                    try
                    {
                        Messaging messaging = new Messaging();

                        StringBuilder sbMsg = new StringBuilder();
                        sbMsg.Append($"<div style='font-family: Sans-Serif;'>");
                        sbMsg.Append($"Dear {ci.ContactName},");
                        sbMsg.Append(Environment.NewLine + Environment.NewLine + "<br /><br />");
                        sbMsg.Append($"A new {projectName} response for the {ci.City} site has been received. ");
                        sbMsg.Append(Environment.NewLine + "<br />");
                        sbMsg.Append("Click on the following link to view the record (you may be required to log into REDCap first):");
                        sbMsg.Append(Environment.NewLine + Environment.NewLine + "<br /><br />");
                        sbMsg.Append($"<a href='https://redcap-address-goes-here/DataEntry/index.php?pid={redcapPid}&id={recordId}&page={redcapSurvey}'>New {ci.City} survey response</a>");
                        sbMsg.Append(Environment.NewLine + Environment.NewLine + "<br /><br />");
                        sbMsg.Append($"Alternately, login to the {projectName} project and view the response for subject with identification number of {recordId}.");
                        sbMsg.Append(Environment.NewLine + Environment.NewLine + "<br /><br />");
                        sbMsg.Append("Regards,");
                        sbMsg.Append(Environment.NewLine + "<br />");
                        sbMsg.Append("name of sender");
                        sbMsg.Append(Environment.NewLine + "<br />");
                        sbMsg.Append("organization");
                        sbMsg.Append(Environment.NewLine + "<br />");
                        sbMsg.Append("title");
                        sbMsg.Append("</div>");

                        string mailBody = sbMsg.ToString();
                        Log.DebugFormat("Body of email: {0}", mailBody);

                        messaging.SendEmail("Name<*****@*****.**>", ci.ContactEmail, projectName, mailBody, "Name<*****@*****.**>", null, recordId);
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorFormat("PostRedcapData Exception: {0}", ex.Message);
                    }
                }
                break;

            default:
                break;
            }
            return;
        }
        public static void OnCityInfoResponse(ProcessedPacket Packet)
        {
            byte NumCities = (byte)Packet.ReadByte();

            if (Packet.DecryptedLength > 1)
            {
                lock (NetworkFacade.Cities)
                {
                    for (int i = 0; i < NumCities; i++)
                    {
                        string Name = Packet.ReadString();
                        string Description = Packet.ReadString();
                        string IP = Packet.ReadString();
                        int Port = Packet.ReadInt32();
                        byte StatusByte = (byte)Packet.ReadByte();
                        CityInfoStatus Status = (CityInfoStatus)StatusByte;
                        ulong Thumbnail = Packet.ReadUInt64();
                        string UUID = Packet.ReadString();
                        ulong Map = Packet.ReadUInt64();

                        CityInfo Info = new CityInfo(false);
                        Info.Name = Name;
                        Info.Description = Description;
                        Info.Thumbnail = Thumbnail;
                        Info.UUID = UUID;
                        Info.Map = Map;
                        Info.IP = IP;
                        Info.Port = Port;
                        Info.Online = true;
                        Info.Status = Status;
                        NetworkFacade.Cities.Add(Info);
                    }
                }
            }
        }
        /* DESCRIPTION:
         * This method implements the A Algorithm.
         * Uses direct distance to the final city as a heuristic.
         * At each step finds the best next city to explore from citiesToExplore.
         * Finds the cities connected to it and examines them.
         * If the connected city is already found, then it examines is the new path to
         * it shorter than the already known one. If it is, than it renew the information
         * about the city in foundCities and citiesToExplore.
         * If the city has not been found yet, then it add it to citiesToExplore and
         * foundCities.
         * When all cities have been explored it finds the minimal path using the idea
         * that if the city B preceds the destination city A in the minimum path,
         * then the minimum path also includes the minimum path from the start city
         * to B. Thus, it goes from city to city in the reverse order and adds them
         * to the minimum path.
         */
        public List<City> FindOptimalPath()
        {
            City nextCity;                      // Next city to explore
            CityInfo nextCityInfo;              // Next city information
            List<City> nextCityConnections;     // Connections of the nextCity

            CityInfo nextConnectedCityInfo;     // Information about the currently examined city connected to nextCity
            CityInfo nextConnectedCityOldInfo;  // Old information about the currently examined city

            Coordinates tempStartPoint, tempEndPoint; // Help variables. Store points on the map.
            City tempCity, tempPrevCity;        // Help variables. Store consecutive sities in the optimal path
            CityInfo tempCityInfo;              // Help variable. Stores a city's info

            LogManager logManager = new LogManager(textBoxLog); // Log manager

            bool finalCityIsFound = false;      // Flag that we found the final city
            double distanceToFinal = -1;        // Length of the found path to the final city

            // Print log - algorithm start
            logManager.Clear();
            logManager.PrintStartAlg(StartCity, FinalCity, AlgHeuristic);

            // Start with the start city:))
            nextCity = StartCity;
            nextCityInfo = new CityInfo(StartCity, null, FinalCity,
                GetCityCoordinates(StartCity), null, GetCityCoordinates(FinalCity),
                0, AlgHeuristic);

            // Initialize
            foundCities = new Dictionary<City, CityInfo>();
            citiesToExplore = new Dictionary<City, CityInfo>();

            // Add the start city
            foundCities.Add(nextCity, nextCityInfo);
            citiesToExplore.Add(nextCity, nextCityInfo);

            // While we have cities to explore
            while (citiesToExplore.Count != 0)
            {
                // Print log
                logManager.PrintFoundExploredCities();

                // Clean the layout
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);

                // Highlighting
                graphManager.MarkAllFoundCities(new List<City>(foundCities.Keys), graphLayout);
                graphManager.MarkAllCitiesToExplore(new List<City>(citiesToExplore.Keys), graphLayout);
                graphManager.MarkStartCity(StartCity, graphLayout);
                graphManager.MarkFinalCity(FinalCity, graphLayout);

                // Wait
                Wait();

                // Find the next best city among citiesToExplore
                nextCity = FindBestCity(citiesToExplore);
                // Get its info
                citiesToExplore.TryGetValue(nextCity, out nextCityInfo);

                // Stop if all the estimates are greater than the found path length
                if (finalCityIsFound)
                {
                    if (nextCityInfo.PathDistance >= distanceToFinal)
                    {
                        break;
                    }
                }

                // Get the nextCity connections
                citiesConnecitons.connections.TryGetValue(nextCity, out nextCityConnections);

                // Print log - next city to explore
                logManager.PrintBestCity(nextCity, nextCityInfo);

                // Highlighting - next city to explore
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkBestCity(nextCity, graphLayout);

                // Print log - city connections
                logManager.PrintCityConnections(nextCityConnections);

                // Highlighting - city connections
                graphManager.MarkEdges(nextCity, nextCityConnections, graphLayout);
                graphManager.MarkAllCheckedCities(nextCityConnections, graphLayout);
                Wait();

                // Examine all the connections of the nextCity
                foreach (City nextConnectedCity in nextCityConnections)
                {
                    // Get the examined city location and the nextCity location
                    citiesLocations.locations.TryGetValue(nextCity, out tempStartPoint);
                    citiesLocations.locations.TryGetValue(nextConnectedCity, out tempEndPoint);

                    // Create information about the currently examined city
                    if (AlgHeuristic == Heuristic.Distance)
                    {
                        nextConnectedCityInfo = new CityInfo(nextConnectedCity, nextCity, FinalCity,
                            tempEndPoint, tempStartPoint, GetCityCoordinates(FinalCity),
                            FindDistance(tempStartPoint, tempEndPoint) + nextCityInfo.FromStart,
                            AlgHeuristic);
                    }
                    // If we use number of hops as a heuristic
                    else
                    {
                        nextConnectedCityInfo = new CityInfo(nextConnectedCity, nextCity, FinalCity,
                            tempEndPoint, tempStartPoint, GetCityCoordinates(FinalCity),
                            1 + nextCityInfo.FromStart, AlgHeuristic);
                    }

                    // If the examined city has already been found.
                    // If the current path is better, then update the city's info
                    if (foundCities.ContainsKey(nextConnectedCity))
                    {
                        // Get the city's old info from foundCities
                        foundCities.TryGetValue(nextConnectedCity, out nextConnectedCityOldInfo);

                        // Compare its old path distance to the new path distance
                        if (nextConnectedCityInfo.PathDistance <
                            nextConnectedCityOldInfo.PathDistance)
                        {
                            // Print log - updated city
                            logManager.PrintUpdatedCity(nextConnectedCity, nextConnectedCityInfo,
                                nextConnectedCityOldInfo);

                            // Highlighting - updated city
                            graphManager.MarkUpdatedCity(nextConnectedCity, graphLayout);

                            // Update the info if the new path is shorter
                            nextConnectedCityOldInfo.PrevCity = nextConnectedCityInfo.PrevCity;
                            nextConnectedCityOldInfo.FromStart = nextConnectedCityInfo.FromStart;

                            // If we updated the final city (found a better path)
                            if (nextConnectedCity.Equals(FinalCity))
                            {
                                distanceToFinal = nextConnectedCityInfo.FromStart;
                            }
                        }
                        else
                        {
                            // Print log - rejected city
                            logManager.PrintRejectedCity(nextConnectedCity, nextConnectedCityInfo,
                                nextConnectedCityOldInfo);

                            // Highlighting - rejected city
                            graphManager.MarkRejectedCity(nextConnectedCity, graphLayout);
                        }
                    }
                    // If we have not found this city so far.
                    // Add it to foundCities and citiesToExplore.
                    else
                    {
                        // Add the city to foundCities and citiesToExplore.
                        foundCities.Add(nextConnectedCity, nextConnectedCityInfo);
                        citiesToExplore.Add(nextConnectedCity, nextConnectedCityInfo);

                        // Print log - added city
                        logManager.PrintAddedCity(nextConnectedCity, nextConnectedCityInfo);

                        // Highlighting - added city
                        graphManager.MarkAddedCity(nextConnectedCity, graphLayout);

                        // Check wether we added the desired final city
                        if (!finalCityIsFound)
                        {
                            if (nextConnectedCity.Equals(FinalCity))
                            {
                                finalCityIsFound = true;
                                distanceToFinal = nextConnectedCityInfo.FromStart;
                            }
                        }
                    }
                }

                // Wait
                Wait();

                // Mark nextCity as explored.
                // Remove it from citiesToExplore
                nextCityInfo.IsExplored = true;
                citiesToExplore.Remove(nextCity);
            }

            // If we were able to reach the destination,
            // then construct the optimal path.
            if (foundCities.ContainsKey(FinalCity))
            {
                // Start with the end city
                tempCity = FinalCity;
                // Get the end city info
                foundCities.TryGetValue(tempCity, out tempCityInfo);

                // Initialize
                List<City> optimalPath = new List<City>();

                // Add the end city to the optimal path
                optimalPath.Add(tempCity);

                // Set the city that preceds the end city in the optimal path
                tempPrevCity = tempCityInfo.PrevCity;

                // While we have not reached the start city
                while (tempPrevCity != null)
                {
                    // Add the city that preceds the current city in the optimal path
                    tempCity = tempPrevCity;
                    optimalPath.Add(tempCity);

                    // Move to the previous city in the path in order to
                    // add it in the next loop iteration.
                    foundCities.TryGetValue(tempCity, out tempCityInfo);
                    tempPrevCity = tempCityInfo.PrevCity;
                }

                // Reverse the list
                ReverseListOrder(ref optimalPath);

                // Print log - optimal path
                logManager.PrintPath(optimalPath,
                    Algorithm.CalculateTotalPath(optimalPath, citiesLocations));

                // Highlighting - optimal path
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkPath(optimalPath, graphLayout);

                // Print log - end of the algorithm
                logManager.PrintEndAlg(true);

                return (optimalPath);
            }
            // Output an error if the destination could not be reached.
            else
            {
                // Highlighting
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkStartCity(StartCity, graphLayout);
                graphManager.MarkFinalCity(FinalCity, graphLayout);

                // Print log - end of the algorithm
                logManager.PrintEndAlg(false);

                // Output an error that the path was not found
                MessageBox.Show("Cannot find a path between the chosen cities.",
                    "Path Finder", MessageBoxButton.OK, MessageBoxImage.Warning);
                return (null);
            }
        }
 /// <summary>
 /// Print information about the city that was updated
 /// </summary>
 /// <param name="city"></param>
 /// <param name="newCityInfo"></param>
 /// <param name="oldCityInfo"></param>
 public void PrintUpdatedCity(City city, CityInfo newCityInfo,
     CityInfo oldCityInfo)
 {
     PrintBreak();
     textBox.Dispatcher.Invoke(
         new Action(delegate()
         {
             textBox.Text += string.Format("Update city (shorter path): {0}\n",
                 city.getName());
             textBox.Text += string.Format("Old distance from start: {0:0.##}\n",
                 oldCityInfo.FromStart);
             textBox.Text += string.Format("New distance from start: {0:0.##}\n",
                 newCityInfo.FromStart);
             textBox.Text += string.Format("Estimated path length: {0:0.##}\n",
                 newCityInfo.PathDistance);
         }),
         DispatcherPriority.Normal, null);
 }
Example #14
0
    public void LoadMOD(int index)
    {
        //Informations.Reset();
        Controller.MODSelect          = index;
        Informations.Instance.kingNum = Informations.Instance.modKingNum[Controller.MODSelect];

        string      modName   = "MOD0" + (index + 1);
        XmlDocument xmlDoc    = new XmlDocument();
        TextAsset   textAsset = (TextAsset)Resources.Load(modName);

        xmlDoc.LoadXml(textAsset.text.ToString().Trim());
        XmlElement root = xmlDoc.DocumentElement;

        XmlElement  node     = (XmlElement)root.SelectSingleNode("King");
        XmlNodeList nodeList = node.ChildNodes;
        int         i        = 0;

        foreach (XmlElement kingNode in nodeList)
        {
            KingInfo kInfo = new KingInfo();
            kInfo.active     = int.Parse(kingNode.GetAttribute("Active"));
            kInfo.generalIdx = int.Parse(kingNode.GetAttribute("GeneralIdx"));

            Informations.Instance.SetKingInfo(i++, kInfo);
        }

        i        = 0;
        node     = (XmlElement)root.SelectSingleNode("City");
        nodeList = node.ChildNodes;
        foreach (XmlElement cityNode in nodeList)
        {
            CityInfo cInfo = new CityInfo();
            cInfo.king         = int.Parse(cityNode.GetAttribute("King"));
            cInfo.population   = int.Parse(cityNode.GetAttribute("Population"));
            cInfo.money        = int.Parse(cityNode.GetAttribute("Money"));
            cInfo.reservist    = int.Parse(cityNode.GetAttribute("Reservist"));
            cInfo.reservistMax = int.Parse(cityNode.GetAttribute("ReservistMax"));
            cInfo.defense      = int.Parse(cityNode.GetAttribute("Defense"));

            Informations.Instance.SetCityInfo(i++, cInfo);
        }

        KingInfo k = new KingInfo();

        k.generalIdx = 0;
        Informations.Instance.SetKingInfo(Informations.Instance.kingNum, k);

        i        = 0;
        node     = (XmlElement)root.SelectSingleNode("General");
        nodeList = node.ChildNodes;
        foreach (XmlElement generalNode in nodeList)
        {
            GeneralInfo gInfo = new GeneralInfo();
            gInfo.king       = int.Parse(generalNode.GetAttribute("King"));
            gInfo.city       = int.Parse(generalNode.GetAttribute("City"));
            gInfo.magic[0]   = int.Parse(generalNode.GetAttribute("Magic0"));
            gInfo.magic[1]   = int.Parse(generalNode.GetAttribute("Magic1"));
            gInfo.magic[2]   = int.Parse(generalNode.GetAttribute("Magic2"));
            gInfo.magic[3]   = int.Parse(generalNode.GetAttribute("Magic3"));
            gInfo.equipment  = int.Parse(generalNode.GetAttribute("Equipment"));
            gInfo.strength   = int.Parse(generalNode.GetAttribute("Strength"));
            gInfo.intellect  = int.Parse(generalNode.GetAttribute("Intellect"));
            gInfo.experience = int.Parse(generalNode.GetAttribute("Experience"));
            gInfo.level      = int.Parse(generalNode.GetAttribute("Level"));
            gInfo.healthMax  = int.Parse(generalNode.GetAttribute("HealthMax"));
            gInfo.healthCur  = int.Parse(generalNode.GetAttribute("HealthCur"));
            gInfo.manaMax    = int.Parse(generalNode.GetAttribute("ManaMax"));
            gInfo.manaCur    = int.Parse(generalNode.GetAttribute("ManaCur"));
            gInfo.soldierMax = int.Parse(generalNode.GetAttribute("SoldierMax"));
            gInfo.soldierCur = int.Parse(generalNode.GetAttribute("SoldierCur"));
            gInfo.knightMax  = int.Parse(generalNode.GetAttribute("KnightMax"));
            gInfo.knightCur  = int.Parse(generalNode.GetAttribute("KnightCur"));
            gInfo.arms       = int.Parse(generalNode.GetAttribute("Arms"));
            gInfo.formation  = int.Parse(generalNode.GetAttribute("Formation"));

            Informations.Instance.SetGeneralInfo(i++, gInfo);
        }

        Informations.Instance.InitKingInfo();
        Informations.Instance.InitCityPrefect();
        Informations.Instance.InitCityInfo();
        Informations.Instance.InitGeneralInfo();
    }
        private void HandleGotoDetails(CityInfo cityInfo)
        {
            if (MenuActive)
            {
                MenuActive = false;
                return;
            }

            if (cityInfo != null)
            {
                _navigation.Navigate(Experiences.CityDetails.ToString(), cityInfo);
                Clocks.CollectionChanged -= Clocks_CollectionChanged;
            }
        }
 public void DeleteClock(CityInfo clock)
 {
 }
 public void AddClock(CityInfo info)
 {
 }
Example #18
0
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            NetState state = args.State;

            if (state == null)
            {
                return;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Character creation failed, account full", state);
                Utility.PopColor();
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female      = args.Female;

            newChar.Race = args.Race; //Sets body

            newChar.Hue = args.Hue | 0x8000;

            newChar.Hunger = 20;

            bool young = false;

            if (newChar is PlayerMobile pm)
            {
                pm.AutoRenewInsurance = true;

                double skillcap = Config.Get("PlayerCaps.SkillCap", 1000.0d) / 10;

                if (skillcap != 100.0)
                {
                    for (int i = 0; i < Enum.GetNames(typeof(SkillName)).Length; ++i)
                    {
                        pm.Skills[i].Cap = skillcap;
                    }
                }

                pm.Profession = args.Profession;

                if (pm.IsPlayer() && pm.Account.Young && !Siege.SiegeShard)
                {
                    young = pm.Young = true;
                }
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, state, args.Profession, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = args.HairHue;
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = args.BeardHue;
            }

            int faceID = args.FaceID;

            if (faceID > 0 && race.ValidateFace(newChar.Female, faceID))
            {
                newChar.FaceItemID = faceID;
                newChar.FaceHue    = args.FaceHue;
            }
            else
            {
                newChar.FaceItemID = race.RandomFace(newChar.Female);
                newChar.FaceHue    = newChar.Hue;
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                TestCenter.FillBankbox(newChar);
            }

            if (young)
            {
                NewPlayerTicket ticket = new NewPlayerTicket
                {
                    Owner = newChar
                };

                newChar.BankBox.DropItem(ticket);
            }

            CityInfo city = args.City;
            Map      map  = Siege.SiegeShard && city.Map == Map.Trammel ? Map.Felucca : city.Map;

            newChar.MoveToWorld(city.Location, map);

            Utility.PushColor(ConsoleColor.Green);
            Console.WriteLine("Login: {0}: New character being created (account={1})", state, args.Account.Username);
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.DarkGreen);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map);
            Utility.PopColor();
        }
Example #19
0
        public string FTP_TNHamilton(string houseno, string sname, string sttype, string accno, string parcelNumber, string searchType, string orderNumber, string ownername, string directParcel, string unitno)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;

            string StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = "";

            var driverService = PhantomJSDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            using (driver = new PhantomJSDriver())
            {
                //driver = new ChromeDriver();

                try
                {
                    StartTime = DateTime.Now.ToString("HH:mm:ss");

                    if (searchType == "titleflex")
                    {
                        string address = houseno + " " + sname + " " + unitno;
                        gc.TitleFlexSearch(orderNumber, parcelNumber, "", address, "TN", "Hamilton");
                        if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes"))
                        {
                            driver.Quit();
                            return("MultiParcel");
                        }
                        else if (HttpContext.Current.Session["titleparcel"].ToString() == "")
                        {
                            HttpContext.Current.Session["Nodata_TNHamilton"] = "Yes";
                            driver.Quit();
                            return("No Data Found");
                        }
                        parcelNumber = HttpContext.Current.Session["titleparcel"].ToString();
                        searchType   = "parcel";
                    }

                    if (searchType == "address")
                    {
                        driver.Navigate().GoToUrl("http://assessor.hamiltontn.gov/search.aspx");
                        Thread.Sleep(2000);

                        driver.FindElement(By.Id("SearchStreetName")).SendKeys(sname);
                        driver.FindElement(By.Id("SearchStreetNumber")).SendKeys(houseno);

                        driver.FindElement(By.Id("cmdGo")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        gc.CreatePdf_WOP(orderNumber, "Address search", driver, "TN", "Hamilton");

                        IWebElement         MultiAddressTB = driver.FindElement(By.XPath("//*[@id='T1']/tbody"));
                        IList <IWebElement> MultiAddressTR = MultiAddressTB.FindElements(By.TagName("tr"));
                        IList <IWebElement> MultiAddressTD;

                        if (MultiAddressTR.Count == 1)
                        {
                            driver.FindElement(By.XPath("//*[@id='T1']/tbody/tr/td[1]/a")).Click();
                            Thread.Sleep(2000);
                        }

                        else
                        {
                            int AddressmaxCheck = 0;
                            foreach (IWebElement MultiAddress in MultiAddressTR)
                            {
                                if (AddressmaxCheck <= 25)
                                {
                                    MultiAddressTD = MultiAddress.FindElements(By.TagName("td"));
                                    if (MultiAddressTD.Count != 0)
                                    {
                                        Parcelno = MultiAddressTD[0].Text;
                                        Location = MultiAddressTD[1].Text;
                                        Owner    = MultiAddressTD[2].Text;

                                        MultiAddress_details = Location + "~" + Owner;
                                        gc.insert_date(orderNumber, Parcelno, 764, MultiAddress_details, 1, DateTime.Now);
                                    }
                                    AddressmaxCheck++;
                                }
                            }
                            if (MultiAddressTR.Count > 25)
                            {
                                HttpContext.Current.Session["multiParcel_TNHamilton_Multicount"] = "Maximum";
                            }
                            else
                            {
                                HttpContext.Current.Session["multiparcel_TNHamilton"] = "Yes";
                            }
                            driver.Quit();

                            return("MultiParcel");
                        }
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.XPath("//*[@id='body']/div[3]")).Text;
                            if (nodata.Contains("No results found!"))
                            {
                                HttpContext.Current.Session["Nodata_TNHamilton"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }

                    if (searchType == "parcel")
                    {
                        driver.Navigate().GoToUrl("http://assessor.hamiltontn.gov/search.aspx");
                        Thread.Sleep(2000);

                        if (parcelNumber.Contains("-") || parcelNumber.Contains(" ") || parcelNumber.Contains("."))
                        {
                            parcelNumber = parcelNumber.Replace("-", "").Replace(" ", "").Replace(".", "");
                        }

                        string CommonParcel = parcelNumber;

                        if (CommonParcel.Length == 8)
                        {
                            string a = parcelNumber.Substring(0, 4);
                            string b = parcelNumber.Substring(4, 1);
                            string c = parcelNumber.Substring(5, 3);

                            parcelNumber = a + " " + b + " " + c;
                        }

                        if (CommonParcel.Length == 6)
                        {
                            string g = parcelNumber.Substring(0, 3);
                            string h = parcelNumber.Substring(3, 3);

                            parcelNumber = g + " " + h;
                        }

                        if (CommonParcel.Length == 13)
                        {
                            string d = parcelNumber.Substring(0, 4);
                            string e = parcelNumber.Substring(5, 1);
                            string f = parcelNumber.Substring(6, 3);

                            parcelNumber = d + " " + e + " " + f;
                        }

                        driver.FindElement(By.Id("SearchParcel")).SendKeys(parcelNumber);

                        driver.FindElement(By.Id("cmdGo")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        gc.CreatePdf(orderNumber, parcelNumber, "ParcelSearch", driver, "TN", "Hamilton");

                        driver.FindElement(By.XPath("//*[@id='T1']/tbody/tr/td[1]/a")).Click();
                        Thread.Sleep(2000);
                    }

                    if (searchType == "ownername")
                    {
                        driver.Navigate().GoToUrl("http://assessor.hamiltontn.gov/search.aspx");
                        Thread.Sleep(2000);

                        driver.FindElement(By.Id("SearchOwner")).SendKeys(ownername);

                        driver.FindElement(By.Id("cmdGo")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                        gc.CreatePdf_WOP(orderNumber, "Owner search", driver, "TN", "Hamilton");

                        IWebElement         MultiOwnerTB = driver.FindElement(By.XPath("//*[@id='T1']/tbody"));
                        IList <IWebElement> MultiOwnerTR = MultiOwnerTB.FindElements(By.TagName("tr"));
                        IList <IWebElement> MultiOwnerTD;

                        if (MultiOwnerTR.Count == 1)
                        {
                            driver.FindElement(By.XPath("//*[@id='T1']/tbody/tr/td[1]/a")).Click();
                            Thread.Sleep(2000);
                        }

                        else
                        {
                            int AddressmaxCheck = 0;
                            foreach (IWebElement MultiOwner in MultiOwnerTR)
                            {
                                if (AddressmaxCheck <= 25)
                                {
                                    MultiOwnerTD = MultiOwner.FindElements(By.TagName("td"));
                                    if (MultiOwnerTD.Count != 0)
                                    {
                                        Parcelno = MultiOwnerTD[0].Text;
                                        Location = MultiOwnerTD[1].Text;
                                        Owner    = MultiOwnerTD[2].Text;

                                        MultiOwner_details = Location + "~" + Owner;
                                        gc.insert_date(orderNumber, Parcelno, 764, MultiOwner_details, 1, DateTime.Now);
                                    }
                                    AddressmaxCheck++;
                                }
                            }
                            if (MultiOwnerTR.Count > 25)
                            {
                                HttpContext.Current.Session["multiParcel_TNHamilton_Multicount"] = "Maximum";
                            }
                            else
                            {
                                HttpContext.Current.Session["multiparcel_TNHamilton"] = "Yes";
                            }
                            driver.Quit();
                            return("MultiParcel");
                        }
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.XPath("//*[@id='body']/div[3]")).Text;
                            if (nodata.Contains("No results found!"))
                            {
                                HttpContext.Current.Session["Nodata_TNHamilton"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }

                    //Property Details
                    try
                    {
                        Property_Address = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[1]/td[1]/div/div")).Text;
                        Account_No       = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[1]/td[2]/div/div")).Text;
                        Parcel_ID        = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[1]/td[3]/div/div")).Text;
                        Pro_Type         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[2]/td[1]/div/div")).Text;
                        Land_Use         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[2]/td[2]/div/div")).Text;
                        Dist             = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[1]/tbody/tr[2]/td[3]/div/div")).Text;
                        Owner1           = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[1]/td[2]/div")).Text;
                        Owner2           = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[2]/td[2]/div")).Text;
                        Owners           = Owner1 + " &" + Owner2;
                        Mailing1         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[3]/td[2]/div")).Text;
                        Mailing2         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[1]/td[4]/div")).Text;
                        Mailing3         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[2]/td[4]/div")).Text;
                        Mailing4         = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody/tr[3]/td[4]/div")).Text;
                        Mailing_Address  = Mailing1 + "," + Mailing2 + "," + Mailing3 + " " + Mailing4;
                        Year_Built       = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[4]/td/div[2]/center/table/tbody/tr[2]/td/div/table/tbody/tr/td/div")).Text;
                        Year_Built       = WebDriverTest.Between(Year_Built, "about ", " with");
                        Legal_Desp       = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[4]/td/div[2]/center/table/tbody/tr[2]/td/font[2]/div[1]/center/table[2]/tbody/tr[2]/td/div/table/tbody/tr/td/div")).Text;

                        property = Account_No + "~" + Property_Address + "~" + Pro_Type + "~" + Land_Use + "~" + Dist + "~" + Owners + "~" + Mailing_Address + "~" + Year_Built + "~" + Legal_Desp;
                        gc.CreatePdf(orderNumber, Parcel_ID, "Property Details", driver, "TN", "Hamilton");
                        gc.insert_date(orderNumber, Parcel_ID, 766, property, 1, DateTime.Now);
                    }
                    catch
                    { }

                    //Assessment Deatils
                    try
                    {
                        IWebElement         tbmulti11 = driver.FindElement(By.XPath("//*[@id='body']/form/div[2]/table[2]/tbody/tr[4]/td/div[1]/center/table/tbody/tr[2]/td/div/table/tbody/tr/td/table/tbody"));
                        IList <IWebElement> TRmulti11 = tbmulti11.FindElements(By.TagName("tr"));
                        IList <IWebElement> TDmulti11;

                        foreach (IWebElement row in TRmulti11)
                        {
                            TDmulti11 = row.FindElements(By.TagName("td"));
                            if (TDmulti11.Count != 0)
                            {
                                Build = TDmulti11[0].Text;
                                if (Build.Contains("Building Value"))
                                {
                                    Building_Value = TDmulti11[1].Text;
                                }

                                Xtra = TDmulti11[0].Text;
                                if (Xtra.Contains("Xtra Features Value"))
                                {
                                    Xtra_Fetures_Value = TDmulti11[1].Text;
                                }

                                Land = TDmulti11[0].Text;
                                if (Land.Contains("Land Value"))
                                {
                                    Land_Value = TDmulti11[1].Text;
                                }

                                tol = TDmulti11[0].Text;
                                if (tol.Contains("Total Value"))
                                {
                                    Total_Value = TDmulti11[1].Text;
                                }

                                Assed = TDmulti11[0].Text;
                                if (Assed.Contains("Assessed Value"))
                                {
                                    Assessed_Value = TDmulti11[1].Text;
                                }
                            }
                        }

                        Assessment = Building_Value + "~" + Xtra_Fetures_Value + "~" + Land_Value + "~" + Total_Value + "~" + Assessed_Value;
                        gc.insert_date(orderNumber, Parcel_ID, 767, Assessment, 1, DateTime.Now);
                    }
                    catch
                    { }


                    //Tax Details
                    driver.Navigate().GoToUrl("http://tpti.hamiltontn.gov/AppFolder/Trustee_PropertySearch.aspx");
                    Thread.Sleep(2000);

                    driver.FindElement(By.Id("ctl00_MainContent_btnMGP")).Click();
                    Thread.Sleep(2000);


                    Parcel_ID = Parcel_ID.Replace("_", "");

                    if (Parcel_ID.Contains("."))
                    {
                        Parcel_ID = GlobalClass.Before(Parcel_ID, ".").Trim();
                    }
                    string com_Parcel = Parcel_ID;
                    if (com_Parcel.Length == 7)
                    {
                        Map    = Parcel_ID.Substring(0, 4);
                        Parcel = Parcel_ID.Substring(4, 3);
                    }
                    if (com_Parcel.Length == 8)
                    {
                        Map    = Parcel_ID.Substring(0, 4);
                        Group  = Parcel_ID.Substring(4, 1);
                        Parcel = Parcel_ID.Substring(5, 3);
                    }
                    if (com_Parcel.Length == 9)
                    {
                        Map    = Parcel_ID.Substring(0, 5);
                        Group  = Parcel_ID.Substring(5, 1);
                        Parcel = Parcel_ID.Substring(6, 3);
                    }

                    driver.FindElement(By.Id("ctl00_MainContent_txtMap")).SendKeys(Map);
                    driver.FindElement(By.Id("ctl00_MainContent_txtGroup")).SendKeys(Group);
                    driver.FindElement(By.Id("ctl00_MainContent_txtParcel")).SendKeys(Parcel);

                    gc.CreatePdf(orderNumber, Parcel_ID, "Tax Parcel search", driver, "TN", "Hamilton");
                    driver.FindElement(By.Id("ctl00_MainContent_cmdMGP_Search")).SendKeys(Keys.Enter);

                    //County Tax History Details
                    try
                    {
                        IWebElement         CountyTaxPaymentTB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_dgrResults']/tbody"));
                        IList <IWebElement> CountyTaxPaymentTR = CountyTaxPaymentTB.FindElements(By.TagName("tr"));
                        IList <IWebElement> CountyTaxPaymentTD;

                        foreach (IWebElement CountyTaxPayment in CountyTaxPaymentTR)
                        {
                            CountyTaxPaymentTD = CountyTaxPayment.FindElements(By.TagName("td"));
                            if (CountyTaxPaymentTD.Count != 0 && !CountyTaxPayment.Text.Contains("Year"))
                            {
                                County_Taxyear = CountyTaxPaymentTD[1].Text;
                                Bill           = CountyTaxPaymentTD[2].Text;
                                Bill_Type      = CountyTaxPaymentTD[4].Text;
                                CPro_Type      = CountyTaxPaymentTD[5].Text;
                                Own_name       = CountyTaxPaymentTD[6].Text;
                                Tol_Due        = CountyTaxPaymentTD[7].Text;
                                Status         = CountyTaxPaymentTD[8].Text;

                                CountyPayment_details = County_Taxyear + "~" + Bill + "~" + Bill_Type + "~" + CPro_Type + "~" + Own_name + "~" + Tol_Due + "~" + Status;
                                gc.CreatePdf(orderNumber, Parcel_ID, "County Tax History Details", driver, "TN", "Hamilton");
                                gc.insert_date(orderNumber, Parcel_ID, 768, CountyPayment_details, 1, DateTime.Now);
                            }
                        }
                    }
                    catch
                    { }

                    //County Tax Info Details
                    List <string> CountyInfoSearch = new List <string>();

                    try
                    {
                        IWebElement         CityInfoTB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_dgrResults']/tbody"));
                        IList <IWebElement> CityInfoTR = CityInfoTB.FindElements(By.TagName("tr"));
                        IList <IWebElement> CityInfoTD;

                        int i = 0;
                        foreach (IWebElement CityInfo in CityInfoTR)
                        {
                            if (!CityInfo.Text.Contains("Year"))
                            {
                                if (i == 1 || i == 2 || i == 3)
                                {
                                    CityInfoTD = CityInfo.FindElements(By.TagName("td"));
                                    IWebElement CityInfo_link = CityInfoTD[0].FindElement(By.TagName("a"));
                                    string      CityInfourl   = CityInfo_link.GetAttribute("href");
                                    CountyInfoSearch.Add(CityInfourl);
                                }
                            }
                            i++;
                        }

                        foreach (string CityInfobill in CountyInfoSearch)
                        {
                            driver.Navigate().GoToUrl(CityInfobill);
                            Thread.Sleep(5000);

                            driver.SwitchTo().Window(driver.WindowHandles.Last());
                            Thread.Sleep(3000);

                            //Tax Info
                            Flags          = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[1]/td[4]")).Text;
                            Tax_Distrct    = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[2]/td[2]")).Text;
                            Bil_type       = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[7]/td/table/tbody/tr[1]/td[2]")).Text;
                            TaxBil_type    = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[7]/td/table/tbody/tr[1]/td[4]")).Text;
                            Bil_Status     = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[7]/td/table/tbody/tr[2]/td[2]")).Text;
                            Bill_Hash      = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[7]/td/table/tbody/tr[2]/td[4]")).Text;
                            Tax_Assessment = driver.FindElement(By.XPath("//*[@id='aspnetForm']/div[3]/table/tbody/tr[2]/td[2]/table/tbody/tr[7]/td/table/tbody/tr[5]/td[2]")).Text;

                            IWebElement         Tax3TB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_dgrTrans']/tbody"));
                            IList <IWebElement> Tax3TR = Tax3TB.FindElements(By.TagName("tr"));
                            IList <IWebElement> Tax3TD;
                            foreach (IWebElement Tax3 in Tax3TR)
                            {
                                Tax3TD = Tax3.FindElements(By.TagName("td"));
                                if (Tax3TD.Count != 0 && !Tax3.Text.Contains("Date"))
                                {
                                    Billing_Date = Tax3TD[0].Text;
                                    Trns_type    = Tax3TD[1].Text;
                                    Fee_Type     = Tax3TD[2].Text;
                                    Bill_Amount  = Tax3TD[4].Text;
                                }
                            }

                            try
                            {
                                IWebElement         Tax4TB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_dgrPayments']/tbody"));
                                IList <IWebElement> Tax4TR = Tax4TB.FindElements(By.TagName("tr"));
                                IList <IWebElement> Tax4TD;
                                foreach (IWebElement Tax4 in Tax4TR)
                                {
                                    Tax4TD = Tax4.FindElements(By.TagName("td"));
                                    if (Tax4TD.Count != 0 && !Tax4.Text.Contains("Date Paid"))
                                    {
                                        PayIfo_Date     = Tax4TD[0].Text;
                                        PayIfoTrns_type = Tax4TD[1].Text;
                                        PayIfoFee_Type  = Tax4TD[2].Text;
                                        PayIfo_Amount   = Tax4TD[3].Text;
                                    }
                                }
                            }
                            catch
                            { }

                            //Deliquent Details
                            try
                            {
                                IWebElement         IntrestTB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_lblIntAndFees']/table/tbody"));
                                IList <IWebElement> IntrestTR = IntrestTB.FindElements(By.TagName("tr"));
                                IList <IWebElement> IntrestTD;
                                foreach (IWebElement Intrest in IntrestTR)
                                {
                                    IntrestTD = Intrest.FindElements(By.TagName("td"));
                                    if (IntrestTD.Count != 0)
                                    {
                                        ints = IntrestTD[0].Text;
                                        if (ints.Contains("Interest:"))
                                        {
                                            Deliq_Interest = IntrestTD[1].Text;
                                        }

                                        Court = IntrestTD[0].Text;
                                        if (Court.Contains("Court Cost:"))
                                        {
                                            Deliq_CourtCost = IntrestTD[1].Text;
                                        }

                                        Att = IntrestTD[0].Text;
                                        if (Att.Contains("Attorney's Fee:"))
                                        {
                                            Deliq_Attornys = IntrestTD[1].Text;
                                        }

                                        Clerk = IntrestTD[0].Text;
                                        if (Clerk.Contains("Clerk Commission:"))
                                        {
                                            Deliq_Clerk = IntrestTD[1].Text;
                                        }

                                        TR = IntrestTD[0].Text;
                                        if (TR.Contains("TR Costs:"))
                                        {
                                            Deliq_TR = IntrestTD[1].Text;
                                        }
                                    }
                                }
                            }
                            catch
                            { }

                            IWebElement         Tax2TB = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_pnlTotalDue']/table[1]/tbody/tr[1]/td/table/tbody"));
                            IList <IWebElement> Tax2TR = Tax2TB.FindElements(By.TagName("tr"));
                            IList <IWebElement> Tax2TD;

                            foreach (IWebElement Tax2 in Tax2TR)
                            {
                                Tax2TD = Tax2.FindElements(By.TagName("td"));
                                if (Tax2TD.Count != 0)
                                {
                                    t_du = Tax2TD[0].Text;
                                    if (t_du.Contains(" Total Due  "))
                                    {
                                        Total_taxDue = Tax2TD[1].Text;
                                    }
                                }
                            }
                            gc.CreatePdf(orderNumber, Parcel_ID, "Tax Details" + TaxBil_type, driver, "TN", "Hamilton");

                            try
                            {
                                Tax_Authority = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_pnlOurAddr']/table/tbody/tr/td/b")).Text;
                            }
                            catch
                            { }

                            try
                            {
                                Tax_Authority = driver.FindElement(By.XPath("//*[@id='ctl00_MainContent_pnlDelQ']/table/tbody/tr/td/b")).Text;
                            }
                            catch
                            { }

                            Tax_Deatils = Tax_Distrct + "~" + TaxBil_type + "~" + Flags + "~" + Bil_type + "~" + Bil_Status + "~" + Bill_Hash + "~" + Tax_Assessment + "~" + Billing_Date + "~" + Trns_type + "~" + Fee_Type + "~" + Bill_Amount + "~" + PayIfo_Date + "~" + PayIfoTrns_type + "~" + PayIfoFee_Type + "~" + PayIfo_Amount + "~" + Deliq_Interest + "~" + Deliq_CourtCost + "~" + Deliq_Attornys + "~" + Deliq_Clerk + "~" + Deliq_TR + "~" + Total_taxDue + "~" + Tax_Authority;
                            gc.insert_date(orderNumber, Parcel_ID, 769, Tax_Deatils, 1, DateTime.Now);
                            PayIfo_Date = ""; PayIfoTrns_type = ""; PayIfoFee_Type = ""; PayIfo_Amount = ""; Deliq_Interest = ""; Deliq_CourtCost = ""; Deliq_Attornys = ""; Deliq_Clerk = ""; Deliq_TR = ""; Total_taxDue = ""; Tax_Authority = "";
                        }
                    }
                    catch { }

                    TaxTime = DateTime.Now.ToString("HH:mm:ss");

                    if (Tax_Distrct == "Chattanooga (1)")
                    {
                        driver.Navigate().GoToUrl("http://propertytax.chattanooga.gov/component/ptaxweb/searchpage?field=mgp");
                        Thread.Sleep(2000);

                        City_map = Map.Replace(" ", "");

                        driver.FindElement(By.Id("filter_search_map")).SendKeys(City_map);
                        driver.FindElement(By.Id("filter_search_group")).SendKeys(Group);
                        driver.FindElement(By.Id("filter_search_parcel")).SendKeys(Parcel);

                        gc.CreatePdf(orderNumber, Parcel_ID, "City Parcel search", driver, "TN", "Hamilton");
                        driver.FindElement(By.XPath("//*[@id='content']/div[1]/form/div/div[2]/button")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);

                        driver.FindElement(By.XPath("//*[@id=\'content']/div/div[1]/form/table/tbody/tr/td[1]/a")).Click();
                        Thread.Sleep(2000);

                        //City Tax History Details
                        try
                        {
                            IWebElement         CityTaxPaymentTB = driver.FindElement(By.XPath("//*[@id='content']/div/div[1]/form/table[2]/tbody"));
                            IList <IWebElement> CityTaxPaymentTR = CityTaxPaymentTB.FindElements(By.TagName("tr"));
                            IList <IWebElement> CityTaxPaymentTD;

                            foreach (IWebElement CityTaxPayment in CityTaxPaymentTR)
                            {
                                CityTaxPaymentTD = CityTaxPayment.FindElements(By.TagName("td"));
                                if (CityTaxPaymentTD.Count != 0 && !CityTaxPayment.Text.Contains("Year"))
                                {
                                    City_Taxyear  = CityTaxPaymentTD[1].Text;
                                    City_Bill     = CityTaxPaymentTD[2].Text;
                                    CityBill_Type = CityTaxPaymentTD[3].Text;
                                    CityPro_Type  = CityTaxPaymentTD[4].Text;
                                    CityOwn_name  = CityTaxPaymentTD[5].Text;
                                    CityTol_Due   = CityTaxPaymentTD[6].Text;
                                    CityStatus    = CityTaxPaymentTD[7].Text;

                                    CityPayment_details = City_Taxyear + "~" + City_Bill + "~" + CityBill_Type + "~" + CityPro_Type + "~" + CityOwn_name + "~" + CityTol_Due + "~" + CityStatus;
                                    gc.CreatePdf(orderNumber, Parcel_ID, "CIty Tax History Details", driver, "TN", "Hamilton");
                                    gc.insert_date(orderNumber, Parcel_ID, 770, CityPayment_details, 1, DateTime.Now);
                                }
                            }
                        }
                        catch
                        { }

                        //City Info Details
                        List <string> CityInfoSearch = new List <string>();

                        try
                        {
                            IWebElement         CityInfo1TB = driver.FindElement(By.XPath("//*[@id='content']/div/div[1]/form/table[2]/tbody"));
                            IList <IWebElement> CityInfo1TR = CityInfo1TB.FindElements(By.TagName("tr"));
                            IList <IWebElement> CityInfo1TD;

                            int i = 0;
                            foreach (IWebElement CityInfo1 in CityInfo1TR)
                            {
                                if (i == 0 || i == 1 || i == 2)
                                {
                                    CityInfo1TD = CityInfo1.FindElements(By.TagName("td"));
                                    IWebElement CityInfo1_link = CityInfo1TD[0].FindElement(By.TagName("a"));
                                    string      CityInfo1url   = CityInfo1_link.GetAttribute("href");
                                    CityInfoSearch.Add(CityInfo1url);
                                }
                                i++;
                            }

                            foreach (string CityInfobill1 in CityInfoSearch)
                            {
                                driver.Navigate().GoToUrl(CityInfobill1);
                                Thread.Sleep(5000);

                                driver.SwitchTo().Window(driver.WindowHandles.Last());
                                Thread.Sleep(3000);

                                City_Flags       = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[1]/tbody/tr[1]/td[4]")).Text;
                                City_BillHash    = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[2]/tbody/tr/td[2]")).Text;
                                City_Bil_type    = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[3]/tbody/tr[1]/td[2]")).Text;
                                City_TaxBil_Year = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[3]/tbody/tr[1]/td[4]")).Text;
                                City_Bil_Status  = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[3]/tbody/tr[2]/td[2]")).Text;
                                City_Assessment  = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[3]/tbody/tr[4]/td[4]")).Text;

                                try
                                {
                                    IWebElement         Tax211TB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[5]/tbody[2]"));
                                    IList <IWebElement> Tax211TR = Tax211TB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> Tax211TD;
                                    foreach (IWebElement Tax211 in Tax211TR)
                                    {
                                        Tax211TD = Tax211.FindElements(By.TagName("td"));
                                        if (Tax211TD.Count != 0)
                                        {
                                            t_Inst = Tax211TD[0].Text;
                                            if (t_Inst.Contains("Taxes & Interest"))
                                            {
                                                Tax_Instr = Tax211TD[1].Text;
                                            }
                                            t_Water = Tax211TD[0].Text;
                                            if (t_Water.Contains("Water Quality Fee & Interest"))
                                            {
                                                Tax_Water = Tax211TD[1].Text;
                                            }
                                        }
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    IWebElement         Tax212TB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[5]/tbody[2]"));
                                    IList <IWebElement> Tax212TR = Tax212TB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> Tax212TD;
                                    foreach (IWebElement Tax212 in Tax212TR)
                                    {
                                        Tax212TD = Tax212.FindElements(By.TagName("td"));
                                        if (Tax212TD.Count != 0)
                                        {
                                            City_PaidDate   = Tax212TD[0].Text;
                                            City_PaidAmount = Tax212TD[1].Text;
                                        }
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    IWebElement         Tax21TB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[6]/tbody[2]"));
                                    IList <IWebElement> Tax21TR = Tax21TB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> Tax21TD;
                                    foreach (IWebElement Tax21 in Tax21TR)
                                    {
                                        Tax21TD = Tax21.FindElements(By.TagName("td"));
                                        if (Tax21TD.Count != 0)
                                        {
                                            City_PaidDate   = Tax21TD[0].Text;
                                            City_PaidAmount = Tax21TD[1].Text;
                                        }
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    IWebElement         Tax311TB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[7]/tbody"));
                                    IList <IWebElement> Tax311TR = Tax311TB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> Tax311TD;
                                    foreach (IWebElement Tax311 in Tax311TR)
                                    {
                                        Tax311TD = Tax311.FindElements(By.TagName("td"));
                                        if (Tax311TD.Count != 0)
                                        {
                                            tauth_Inst1 = Tax311TD[0].Text;
                                            if (tauth_Inst.Contains("Total Due"))
                                            {
                                                City_TotalDue = Tax311TD[1].Text;
                                            }
                                        }
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    IWebElement         Tax311TB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[8]/tbody"));
                                    IList <IWebElement> Tax311TR = Tax311TB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> Tax311TD;
                                    foreach (IWebElement Tax311 in Tax311TR)
                                    {
                                        Tax311TD = Tax311.FindElements(By.TagName("td"));
                                        if (Tax311TD.Count != 0)
                                        {
                                            tauth_Inst = Tax311TD[0].Text;
                                            if (tauth_Inst.Contains("Total Due"))
                                            {
                                                City_TotalDue = Tax311TD[1].Text;
                                            }
                                        }
                                    }
                                }
                                catch
                                { }

                                try
                                {
                                    CityTax_Authority = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[6]/tbody/tr/td")).Text;
                                    CityTax_Authority = WebDriverTest.After(CityTax_Authority, "MAKE CHECKS PAYABLE AND MAIL TO:");
                                }
                                catch
                                { }

                                try
                                {
                                    CityTax_Authority1 = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[7]/tbody/tr/td")).Text;
                                    CityTax_Authority1 = WebDriverTest.After(CityTax_Authority1, "MAKE CHECKS PAYABLE AND MAIL TO:");
                                }
                                catch
                                { }

                                CityTax_Deatils = City_Flags + "~" + City_BillHash + "~" + City_Bil_type + "~" + City_TaxBil_Year + "~" + City_Bil_Status + "~" + City_Assessment + "~" + City_PaidDate + "~" + City_PaidAmount + "~" + Tax_Instr + "~" + Tax_Water + "~" + City_TotalDue + "~" + CityTax_Authority + "~" + CityTax_Authority1;
                                gc.CreatePdf(orderNumber, Parcel_ID, "City Tax Details" + City_TaxBil_Year, driver, "TN", "Hamilton");
                                gc.insert_date(orderNumber, Parcel_ID, 771, CityTax_Deatils, 1, DateTime.Now);
                                City_PaidDate = ""; City_PaidAmount = ""; Tax_Instr = ""; Tax_Water = ""; City_TotalDue = "";

                                try
                                {
                                    IWebElement         CinfoTB = driver.FindElement(By.XPath("//*[@id='ptaxweb-content']/table[4]/tbody[2]"));
                                    IList <IWebElement> CinfoTR = CinfoTB.FindElements(By.TagName("tr"));
                                    IList <IWebElement> CinfoTD;
                                    foreach (IWebElement Cinfo in CinfoTR)
                                    {
                                        CinfoTD = Cinfo.FindElements(By.TagName("td"));
                                        if (CinfoTD.Count != 0)
                                        {
                                            Cinfo_Taxyear   = CinfoTD[0].Text;
                                            Cinfo_Transtype = CinfoTD[1].Text;
                                            Cinfo_Feetype   = CinfoTD[2].Text;
                                            Cinfo_Amount    = CinfoTD[3].Text;

                                            Cinfo_details = Cinfo_Taxyear + "~" + Cinfo_Transtype + "~" + Cinfo_Feetype + "~" + Cinfo_Amount;
                                            gc.insert_date(orderNumber, Parcel_ID, 772, Cinfo_details, 1, DateTime.Now);
                                        }
                                    }
                                }
                                catch
                                { }
                            }
                        }
                        catch { }
                    }
                    CitytaxTime = DateTime.Now.ToString("HH:mm:ss");

                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "TN", "Hamilton", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);

                    driver.Quit();
                    gc.mergpdf(orderNumber, "TN", "Hamilton");
                    return("Data Inserted Successfully");
                }
                catch (Exception ex)
                {
                    driver.Quit();
                    GlobalClass.LogError(ex, orderNumber);
                    throw;
                }
            }
        }
 private void InitializeInternal(CityInfo cityInfo)
 {
     Info = cityInfo;
     _eventAggregator.GetEvent<BeforeHideClocksMessage>().Subscribe(OnBeforeHideClocks);
     _clock.Register(this);
 }
Example #21
0
        public PCreateCharacter(PlayerMobile character, CityInfo startingCity, uint clientIP, int serverIndex, uint slot, byte profession) : base(0x00)
        {
            int skillcount = 3;

            if (FileManager.ClientVersion >= ClientVersions.CV_70160)
            {
                skillcount++;
                this[0] = 0xF8;
            }

            WriteUInt(0xEDEDEDED);
            WriteUShort(0xFFFF);
            WriteUShort(0xFFFF);
            WriteByte(0x00);
            WriteASCII(character.Name, 30);
            WriteUShort(0x00);
            uint clientflag = 0;
            uint flags      = (uint)FileManager.ClientFlags;

            for (ushort i = 0; i < flags; i++)
            {
                clientflag |= (uint)(1 << i);
            }

            WriteUInt(clientflag);
            WriteUInt(0x01);
            WriteUInt(0x0);
            WriteByte(profession); // Profession
            Skip(15);
            byte val;

            if (FileManager.ClientVersion < ClientVersions.CV_4011D)
            {
                val = Convert.ToByte(character.Flags.HasFlag(Flags.Female));
            }
            else
            {
                val = (byte)character.Race;

                if (FileManager.ClientVersion < ClientVersions.CV_7000)
                {
                    val--;
                }
                val = (byte)(val * 2 + Convert.ToByte(character.Flags.HasFlag(Flags.Female)));
            }

            WriteByte(val);
            WriteByte((byte)character.Strength);
            WriteByte((byte)character.Dexterity);
            WriteByte((byte)character.Intelligence);
            var skills = character.Skills.OrderByDescending(o => o.Value).Take(skillcount).ToList();

            foreach (var skill in skills)
            {
                WriteByte((byte)skill.Index);
                WriteByte((byte)skill.ValueFixed);
            }

            WriteUShort(character.Hue);
            if (character.Equipment[(int)Layer.Hair] != null)
            {
                WriteUShort(character.Equipment[(int)Layer.Hair].Graphic);
                WriteUShort(character.Equipment[(int)Layer.Hair].Hue);
            }
            else
            {
                WriteUShort(0x00);
                WriteUShort(0x00);
            }

            if (character.Equipment[(int)Layer.Beard] != null)
            {
                WriteUShort(character.Equipment[(int)Layer.Beard].Graphic);
                WriteUShort(character.Equipment[(int)Layer.Beard].Hue);
            }
            else
            {
                WriteUShort(0x00);
                WriteUShort(0x00);
            }

            WriteByte((byte)serverIndex);

            var location = startingCity.Index; // City

            if (FileManager.ClientVersion < ClientVersions.CV_70130 && location > 0)
            {
                location--;
            }

            WriteByte((byte)location);

            WriteUInt(slot);
            WriteUInt(clientIP);
            WriteUShort(character.Equipment[(int)Layer.Shirt].Hue);

            if (character.Equipment[(int)Layer.Pants] != null)
            {
                WriteUShort(character.Equipment[(int)Layer.Pants].Hue);
            }
            else
            {
                WriteUShort(0x00);
            }
        }
        /* DESCRIPTION:
         * This method implements the A Algorithm.
         * Uses direct distance to the final city as a heuristic.
         * At each step finds the best next city to explore from citiesToExplore.
         * Finds the cities connected to it and examines them.
         * If the connected city is already found, then it examines is the new path to
         * it shorter than the already known one. If it is, than it renew the information
         * about the city in foundCities and citiesToExplore.
         * If the city has not been found yet, then it add it to citiesToExplore and
         * foundCities.
         * When all cities have been explored it finds the minimal path using the idea
         * that if the city B preceds the destination city A in the minimum path,
         * then the minimum path also includes the minimum path from the start city
         * to B. Thus, it goes from city to city in the reverse order and adds them
         * to the minimum path.
         */
        public List <City> FindOptimalPath()
        {
            City        nextCity;                               // Next city to explore
            CityInfo    nextCityInfo;                           // Next city information
            List <City> nextCityConnections;                    // Connections of the nextCity

            CityInfo nextConnectedCityInfo;                     // Information about the currently examined city connected to nextCity
            CityInfo nextConnectedCityOldInfo;                  // Old information about the currently examined city

            Coordinates tempStartPoint, tempEndPoint;           // Help variables. Store points on the map.
            City        tempCity, tempPrevCity;                 // Help variables. Store consecutive sities in the optimal path
            CityInfo    tempCityInfo;                           // Help variable. Stores a city's info

            LogManager logManager = new LogManager(textBoxLog); // Log manager

            bool   finalCityIsFound = false;                    // Flag that we found the final city
            double distanceToFinal  = -1;                       // Length of the found path to the final city

            // Print log - algorithm start
            logManager.Clear();
            logManager.PrintStartAlg(StartCity, FinalCity, AlgHeuristic);

            // Start with the start city:))
            nextCity     = StartCity;
            nextCityInfo = new CityInfo(StartCity, null, FinalCity,
                                        GetCityCoordinates(StartCity), null, GetCityCoordinates(FinalCity),
                                        0, AlgHeuristic);

            // Initialize
            foundCities     = new Dictionary <City, CityInfo>();
            citiesToExplore = new Dictionary <City, CityInfo>();

            // Add the start city
            foundCities.Add(nextCity, nextCityInfo);
            citiesToExplore.Add(nextCity, nextCityInfo);

            // While we have cities to explore
            while (citiesToExplore.Count != 0)
            {
                // Print log
                logManager.PrintFoundExploredCities();

                // Clean the layout
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);

                // Highlighting
                graphManager.MarkAllFoundCities(new List <City>(foundCities.Keys), graphLayout);
                graphManager.MarkAllCitiesToExplore(new List <City>(citiesToExplore.Keys), graphLayout);
                graphManager.MarkStartCity(StartCity, graphLayout);
                graphManager.MarkFinalCity(FinalCity, graphLayout);

                // Wait
                Wait();


                // Find the next best city among citiesToExplore
                nextCity = FindBestCity(citiesToExplore);
                // Get its info
                citiesToExplore.TryGetValue(nextCity, out nextCityInfo);

                // Stop if all the estimates are greater than the found path length
                if (finalCityIsFound)
                {
                    if (nextCityInfo.PathDistance >= distanceToFinal)
                    {
                        break;
                    }
                }

                // Get the nextCity connections
                citiesConnecitons.connections.TryGetValue(nextCity, out nextCityConnections);

                // Print log - next city to explore
                logManager.PrintBestCity(nextCity, nextCityInfo);

                // Highlighting - next city to explore
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkBestCity(nextCity, graphLayout);

                // Print log - city connections
                logManager.PrintCityConnections(nextCityConnections);

                // Highlighting - city connections
                graphManager.MarkEdges(nextCity, nextCityConnections, graphLayout);
                graphManager.MarkAllCheckedCities(nextCityConnections, graphLayout);
                Wait();

                // Examine all the connections of the nextCity
                foreach (City nextConnectedCity in nextCityConnections)
                {
                    // Get the examined city location and the nextCity location
                    citiesLocations.locations.TryGetValue(nextCity, out tempStartPoint);
                    citiesLocations.locations.TryGetValue(nextConnectedCity, out tempEndPoint);

                    // Create information about the currently examined city
                    if (AlgHeuristic == Heuristic.Distance)
                    {
                        nextConnectedCityInfo = new CityInfo(nextConnectedCity, nextCity, FinalCity,
                                                             tempEndPoint, tempStartPoint, GetCityCoordinates(FinalCity),
                                                             FindDistance(tempStartPoint, tempEndPoint) + nextCityInfo.FromStart,
                                                             AlgHeuristic);
                    }
                    // If we use number of hops as a heuristic
                    else
                    {
                        nextConnectedCityInfo = new CityInfo(nextConnectedCity, nextCity, FinalCity,
                                                             tempEndPoint, tempStartPoint, GetCityCoordinates(FinalCity),
                                                             1 + nextCityInfo.FromStart, AlgHeuristic);
                    }


                    // If the examined city has already been found.
                    // If the current path is better, then update the city's info
                    if (foundCities.ContainsKey(nextConnectedCity))
                    {
                        // Get the city's old info from foundCities
                        foundCities.TryGetValue(nextConnectedCity, out nextConnectedCityOldInfo);

                        // Compare its old path distance to the new path distance
                        if (nextConnectedCityInfo.PathDistance <
                            nextConnectedCityOldInfo.PathDistance)
                        {
                            // Print log - updated city
                            logManager.PrintUpdatedCity(nextConnectedCity, nextConnectedCityInfo,
                                                        nextConnectedCityOldInfo);

                            // Highlighting - updated city
                            graphManager.MarkUpdatedCity(nextConnectedCity, graphLayout);

                            // Update the info if the new path is shorter
                            nextConnectedCityOldInfo.PrevCity  = nextConnectedCityInfo.PrevCity;
                            nextConnectedCityOldInfo.FromStart = nextConnectedCityInfo.FromStart;

                            // If we updated the final city (found a better path)
                            if (nextConnectedCity.Equals(FinalCity))
                            {
                                distanceToFinal = nextConnectedCityInfo.FromStart;
                            }
                        }
                        else
                        {
                            // Print log - rejected city
                            logManager.PrintRejectedCity(nextConnectedCity, nextConnectedCityInfo,
                                                         nextConnectedCityOldInfo);

                            // Highlighting - rejected city
                            graphManager.MarkRejectedCity(nextConnectedCity, graphLayout);
                        }
                    }
                    // If we have not found this city so far.
                    // Add it to foundCities and citiesToExplore.
                    else
                    {
                        // Add the city to foundCities and citiesToExplore.
                        foundCities.Add(nextConnectedCity, nextConnectedCityInfo);
                        citiesToExplore.Add(nextConnectedCity, nextConnectedCityInfo);

                        // Print log - added city
                        logManager.PrintAddedCity(nextConnectedCity, nextConnectedCityInfo);

                        // Highlighting - added city
                        graphManager.MarkAddedCity(nextConnectedCity, graphLayout);

                        // Check wether we added the desired final city
                        if (!finalCityIsFound)
                        {
                            if (nextConnectedCity.Equals(FinalCity))
                            {
                                finalCityIsFound = true;
                                distanceToFinal  = nextConnectedCityInfo.FromStart;
                            }
                        }
                    }
                }

                // Wait
                Wait();

                // Mark nextCity as explored.
                // Remove it from citiesToExplore
                nextCityInfo.IsExplored = true;
                citiesToExplore.Remove(nextCity);
            }

            // If we were able to reach the destination,
            // then construct the optimal path.
            if (foundCities.ContainsKey(FinalCity))
            {
                // Start with the end city
                tempCity = FinalCity;
                // Get the end city info
                foundCities.TryGetValue(tempCity, out tempCityInfo);

                // Initialize
                List <City> optimalPath = new List <City>();

                // Add the end city to the optimal path
                optimalPath.Add(tempCity);

                // Set the city that preceds the end city in the optimal path
                tempPrevCity = tempCityInfo.PrevCity;

                // While we have not reached the start city
                while (tempPrevCity != null)
                {
                    // Add the city that preceds the current city in the optimal path
                    tempCity = tempPrevCity;
                    optimalPath.Add(tempCity);

                    // Move to the previous city in the path in order to
                    // add it in the next loop iteration.
                    foundCities.TryGetValue(tempCity, out tempCityInfo);
                    tempPrevCity = tempCityInfo.PrevCity;
                }

                // Reverse the list
                ReverseListOrder(ref optimalPath);

                // Print log - optimal path
                logManager.PrintPath(optimalPath,
                                     Algorithm.CalculateTotalPath(optimalPath, citiesLocations));

                // Highlighting - optimal path
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkPath(optimalPath, graphLayout);

                // Print log - end of the algorithm
                logManager.PrintEndAlg(true);

                return(optimalPath);
            }
            // Output an error if the destination could not be reached.
            else
            {
                // Highlighting
                graphManager.UnmarkAllCities(graphLayout);
                graphManager.UnmarkAllEdges(graphLayout);
                graphManager.MarkStartCity(StartCity, graphLayout);
                graphManager.MarkFinalCity(FinalCity, graphLayout);

                // Print log - end of the algorithm
                logManager.PrintEndAlg(false);

                // Output an error that the path was not found
                MessageBox.Show("Cannot find a path between the chosen cities.",
                                "Path Finder", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(null);
            }
        }
 /// <summary>
 /// Print information about the best city to explore next
 /// </summary>
 /// <param name="city"></param>
 /// <param name="cityInfo"></param>
 public void PrintBestCity(City city, CityInfo cityInfo)
 {
     PrintLineBreak();
     textBox.Dispatcher.Invoke(
         new Action(delegate()
             {
                 textBox.Text += string.Format("Next city to explore: {0}\n",
                     city.getName());
                 textBox.Text += string.Format("Estimated path distance: {0:0.##}\n",
                     cityInfo.PathDistance);
             }),
         DispatcherPriority.Normal, null);
 }
Example #24
0
 public void addCity(CityInfo city)
 {
     allCities.Add(city);
     //Debug.Log(allCities.Count);
 }
        private void HandleDeleteCity(CityInfo clock)
        {
            if (!Clocks.Contains(clock))
                return;

            Clocks.Remove(clock);

            //NOTE: Need a way to cleanup
        }
        public ActionResult Init(string id, string city = null)
        {
            CityInfo cityInfo = null;

            if (!string.IsNullOrEmpty(city))
            {
                cityInfo = new GoogleApi().GetCityInfo(city);
            }

            var company = Repository.GetById(id);

            if (company == null)
            {
                return(HttpNotFound());
            }

            var model = new InitSettingsModel {
                Company = company
            };

            model.CityInfo = cityInfo == null ? "" : cityInfo.Name;

            model.Settings = new Dictionary <string, Value>();

            model.Settings.Add("Direction.FlateRate", new Value(
                                   company.Application.FlagDropRate.HasValue ? company.Application.FlagDropRate.Value.ToString() : "2.25", false));

            if (company.Application.UnitOfLength == UnitOfLength.Kilometers)
            {
                model.Settings.Add("Direction.RatePerKm", new Value(
                                       company.Application.MileageRate.HasValue ? company.Application.MileageRate.Value.ToString() : "1.25", false));
            }
            else
            {
                model.Settings.Add("Direction.RatePerKm", new Value(
                                       company.Application.MileageRate.HasValue
                        ? (Convert.ToDouble(company.Application.MileageRate.Value) * 0.390625).ToString()
                        : "1.25", false)); // Convertion in the questionnaire is invalid, this fixes the issue
            }
            model.Settings.Add("DistanceFormat", new Value(
                                   company.Application.UnitOfLength == UnitOfLength.Kilometers ? "Km" : "Mile", false));

            model.Settings.Add("GeoLoc.DefaultLatitude", new Value(cityInfo != null ? cityInfo.Center.Latitude.ToString(CultureInfo.InstalledUICulture) : "", true));
            model.Settings.Add("GeoLoc.DefaultLongitude", new Value(cityInfo != null ? cityInfo.Center.Longitude.ToString(CultureInfo.InstalledUICulture) : "", true));

            if (cityInfo == null)
            {
                model.Settings.Add("GeoLoc.SearchFilter", new Value(@"{0},ottawa,on,canada&region=ca", true));
                model.Settings.Add("Client.LowerLeftLatitude", new Value("0", true));
                model.Settings.Add("Client.LowerLeftLongitude", new Value("0", true));
                model.Settings.Add("Client.UpperRightLatitude", new Value("0", true));
                model.Settings.Add("Client.UpperRightLongitude", new Value("0", true));
            }
            else
            {
                model.Settings.Add("GeoLoc.SearchFilter", new Value(@"{0}" + string.Format(",{0}&bounds={1},{2}|{3},{4}", cityInfo.Name.Replace(" ", "+"), cityInfo.SouthwestCoordinate.Latitude, cityInfo.SouthwestCoordinate.Longitude, cityInfo.NortheastCoordinate.Latitude, cityInfo.NortheastCoordinate.Longitude), true));
                model.Settings.Add("Client.LowerLeftLatitude", new Value(cityInfo.SouthwestCoordinate.Latitude.ToString(CultureInfo.InvariantCulture), true));
                model.Settings.Add("Client.LowerLeftLongitude", new Value(cityInfo.SouthwestCoordinate.Longitude.ToString(CultureInfo.InvariantCulture), true));
                model.Settings.Add("Client.UpperRightLatitude", new Value(cityInfo.NortheastCoordinate.Latitude.ToString(CultureInfo.InvariantCulture), true));
                model.Settings.Add("Client.UpperRightLongitude", new Value(cityInfo.NortheastCoordinate.Longitude.ToString(CultureInfo.InvariantCulture), true));
            }

            model.Settings.Add("DefaultPhoneNumber", new Value(
                                   string.IsNullOrEmpty(company.Application.CompanyPhoneNumber)
                    ? ""
                    : company.Application.CompanyPhoneNumber.Replace("-", ""), true));
            model.Settings.Add("DefaultPhoneNumberDisplay", new Value(company.Application.CompanyPhoneNumber, true));

            //company.CompanyKey

            model.Settings.Add("APNS.ProductionCertificatePath", new Value(
                                   string.Format("../../../Certificates/{0}.p12", company.CompanyKey), false));

            model.Settings.Add("GCM.PackageName", new Value(string.Format("com.apcurium.MK.{0}", company.CompanyKey), false));
            model.Settings.Add("Receipt.Note", new Value("Thank You!<br>" + company.Application.AppName, false));

            if (cityInfo == null)
            {
                model.Settings.Add("IBS.TimeDifference", new Value("0", true));
            }
            else
            {
                model.Settings.Add("IBS.TimeDifference", new Value((-1 * (TimeSpan.FromHours(-5).Ticks - cityInfo.TimeDifference.Ticks)).ToString(), true));
            }

            model.Settings.Add("TaxiHail.ApplicationName", new Value(company.Application.AppName, true));
            model.Settings.Add("TaxiHail.ApplicationKey", new Value(company.CompanyKey, true));
            model.Settings.Add("TaxiHail.AccentColor", new Value(String.IsNullOrEmpty(company.Style.CompanyColor) ? "#0057a3" : company.Style.CompanyColor, false));
            model.Settings.Add("TaxiHail.EmailFontColor", new Value("#000000", false));
            model.Settings.Add("TaxiHail.SiteName", new Value(company.CompanyKey, true));

            model.Settings.Add("AndroidSigningKeyAlias", new Value("MK" + company.CompanyKey, false));
            model.Settings.Add("AndroidSigningKeyPassStorePass", new Value(string.Format("mk{0}0001.", company.CompanyKey), false));

            model.Settings.Add("ApplicationName", new Value(company.Application.AppName, true));
            model.Settings.Add("AppName", new Value(company.Application.AppName, true));

            model.Settings.Add("Package", new Value("com.apcurium.MK." + company.CompanyKey, false));

            model.Settings.Add("Client.AboutUsUrl", new Value(company.Application.AboutUsLink, true));

            model.Settings.Add("SupportEmail", new Value(company.Application.SupportContactEmail, true));
            model.Settings.Add("Client.SupportEmail", new Value(company.Application.SupportContactEmail, true));

            return(View(model));
        }
        private int vedelem(CityInfo cityInfo)
        {
            int def = 0;

            for (int i = 0; i < enemyUnits.Count; i++)
            {
                if (enemyUnits.ElementAt(i).PositionX == cityInfo.PositionX && enemyUnits.ElementAt(i).PositionY == cityInfo.PositionY)
                    def++;
            }

            return def;
        }
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            NetState state = args.State;
            var      acct  = args.Account as Account;

            Mobile newChar = CreateMobile(acct);

            if (newChar == null)
            {
                Console.WriteLine("Login: {0}: Character creation failed, account full", args.State);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                var pm = (PlayerMobile)newChar;

                if (pm.AccessLevel == AccessLevel.Player && ((Account)pm.Account).Young)
                {
                    young = pm.Young = true;
                }
            }

            //CityInfo city = GetStartLocation(args, young);
            var city = new CityInfo("Britain", "Forever", 1495, 1628, 10, Map.Felucca);

            if (!VerifyProfession(args.Profession, city.Map.Expansion))
            {
                args.Profession = 0;
            }

            if (newChar is PlayerMobile)
            {
                ((PlayerMobile)newChar).Profession = args.Profession;
            }

            newChar.Female = args.Female;
            //newChar.Body = newChar.Female ? 0x191 : 0x190;

            newChar.Race = city.Map.Expansion >= args.Race.RequiredExpansion ? args.Race : Race.DefaultRace;

            //newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000;
            newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;

            newChar.Hunger = 20;
            newChar.Thirst = 20;

            //NameResultMessage result = SetName(newChar, args.Name);
            SetName(newChar, args.Name);
            AddBackpack(newChar, city.Map.Expansion);

            SetStats(newChar, state, args.Str, args.Dex, args.Int);
            SetSkills(newChar, city.Map.Expansion, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue, city.Map.Expansion);
                AddPants(newChar, args.PantsHue, city.Map.Expansion);
                AddShoes(newChar, city.Map.Expansion);
            }

            BankBox bank = newChar.BankBox;

            bool needstartpack = acct != null && String.IsNullOrEmpty(acct.GetTag("startpack"));

            if (needstartpack /*|| TestCenter.Enabled*/)
            {
                Container startpack = new StarterPack();
                bank.DropItem(startpack);

                /*
                 * Item housedeed = new SmallBrickHouseDeed();
                 * housedeed.Name = "a beta tester's small brick house deed";
                 * startpack.DropItem(housedeed);
                 * housedeed.X = 23;
                 * housedeed.Y = 53;
                 *
                 * Item startercheck = new BankCheck(10000);
                 * startpack.DropItem(startercheck);
                 * startercheck.X = 52;
                 * startercheck.Y = 36;
                 */
                acct.SetTag("startpack", "true");
            }

            if (young)
            {
                bank.DropItem(
                    new NewPlayerTicket
                {
                    Owner = newChar
                });
            }

            newChar.MoveToWorld(city.Location, city.Map);

            LogIPAccess(args.State.Address, acct, newChar);

            Console.WriteLine("Login: {0}: New character being created (account={1})", args.State, args.Account.Username);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map);

            new WelcomeTimer(newChar).Start();

            /*if (result != NameResultMessage.Allowed)
             * {
             *      newChar.SendGump(new NameChangeGump(newChar, result, args.Name));
             * }*/
        }
Example #29
0
    public void SetCityInfo(int idx, CityInfo cInfo)
    {
        if (cities == null)
        {
            cities = new CityInfo[cityNum];
        }

        cities[idx] = cInfo;
    }
Example #30
0
 /// <summary>
 /// Received token from LoginServer - proceed to CityServer!
 /// </summary>
 private void Controller_OnCityToken(CityInfo SelectedCity)
 {
     GameFacade.Controller.ShowCityTransition(SelectedCity, false);
 }
Example #31
0
 public void ShowCityTransition(CityInfo selectedCity, bool CharacterCreated)
 {
     // GameFacade.Screens.RemoveCurrent();
     // GameFacade.Screens.AddScreen(new CityTransitionScreen(selectedCity, CharacterCreated));
 }
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            NetState state = args.State;

            if (state == null)
            {
                return;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Console.WriteLine("Login: {0}: Character creation failed, account full", state);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female      = args.Female;

            if (Core.Expansion >= args.Race.RequiredExpansion)
            {
                newChar.Race = args.Race;       //Sets body
            }
            else
            {
                newChar.Race = Race.DefaultRace;
            }

            newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;

            newChar.Hunger = Food.CharacterCreationHunger;

            bool young = true;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)newChar;

                pm.Profession = args.Profession;

                Account account = pm.Account as Account;

                if (pm.AccessLevel == AccessLevel.Player && account.Young)
                {
                    young = pm.Young = true;
                }
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, state, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            AddShirt(newChar, args.ShirtHue);
            AddPants(newChar, args.PantsHue);
            AddShoes(newChar);

            /*
             * if (young)
             * {
             *  NewPlayerTicket ticket = new NewPlayerTicket();
             *  ticket.Owner = newChar;
             *  newChar.BankBox.DropItem(ticket);
             * }
             */

            CityInfo[] ci = new CityInfo[2];

            ci[0] = new CityInfo("", "", 1604, 1524, 20, Map.Felucca);
            ci[1] = new CityInfo("", "", 1605, 1524, 20, Map.Felucca);

            Random rand      = new Random();
            int    cityIndex = rand.Next(0, 1);

            CityInfo city = ci[cityIndex];

            newChar.MoveToWorld(city.Location, city.Map);

            new WelcomeTimer(newChar).Start();
        }
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                log.ErrorFormat("Login: {0}: Character creation failed, account full", args.State);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = ((Account)args.Account).AccessLevel;
            newChar.Female      = args.Female;
            newChar.Body        = newChar.Female ? 0x191 : 0x190;
            newChar.Hue         = Utility.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;
            newChar.Hunger      = 20;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)newChar;

                pm.Profession = args.Profession;

                if (pm.AccessLevel == AccessLevel.Player && ((Account)pm.Account).Young)
                {
                    young = pm.Young = true;
                }
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            AddHair(newChar, args.HairID, Utility.ClipHairHue(args.HairHue & 0x3FFF));
            AddBeard(newChar, args.BeardID, Utility.ClipHairHue(args.BeardHue & 0x3FFF));

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                FillBankbox(newChar);
            }

            if (young && newChar.BankBox != null)
            {
                NewPlayerTicket ticket = new NewPlayerTicket();
                ticket.Owner = newChar;
                newChar.BankBox.DropItem(ticket);
            }

            CityInfo city = GetStartLocation(args, young);

            //CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10, Map.Felucca );

            newChar.MoveToWorld(city.Location, city.Map);

            log.InfoFormat("Login: {0}: New character being created (account={1})",
                           args.State, ((Account)args.Account).Username);
            log.InfoFormat(" - Character: {0} (serial={1})",
                           newChar.Name, newChar.Serial);
            log.InfoFormat(" - Started: {0} {1} in {2}",
                           city.City, city.Location, city.Map.ToString());

            new WelcomeTimer(newChar).Start();
        }
Example #34
0
 public List <WeatherInfo> GetWeatherInfoList(CityInfo city)
 {
     throw new NotImplementedException();
 }
Example #35
0
        public CreateCharSelectionCityGump(byte profession, LoginScene scene) : base(0, 0)
        {
            CanMove = false;
            CanCloseWithRightClick = false;
            CanCloseWithEsc        = false;

            _scene = scene;
            _selectedProfession = profession;

            CityInfo city;

            if (Client.Version >= ClientVersion.CV_70130)
            {
                city = scene.GetCity(0);
            }
            else
            {
                city = scene.GetCity(3);

                if (city == null)
                {
                    city = scene.GetCity(0);
                }
            }

            if (city == null)
            {
                Log.Error("No city found. Something wrong with the received cities.");
                Dispose();
                return;
            }

            uint map = 0;

            if (city.IsNewCity)
            {
                map = city.Map;
            }

            _facetName = new Label("", true, 0x0481, font: 0, style: FontStyle.BlackBorder)
            {
                X = 240,
                Y = 440
            };


            if (Client.Version >= ClientVersion.CV_70130)
            {
                Add(new GumpPic(62, 54, (ushort)(0x15D9 + map), 0));
                Add(new GumpPic(57, 49, 0x15DF, 0));
                _facetName.Text = _cityNames[map];
            }
            else
            {
                Add(new GumpPic(57, 49, 0x1598, 0));
                _facetName.IsVisible = false;
            }

            if (Settings.GlobalSettings.ShardType == 2)
            {
                _facetName.IsVisible = false;
            }

            Add(_facetName);


            Add(new Button((int)Buttons.PreviousScreen, 0x15A1, 0x15A3, 0x15A2)
            {
                X            = 586,
                Y            = 445,
                ButtonAction = ButtonAction.Activate
            });

            Add(new Button((int)Buttons.Finish, 0x15A4, 0x15A6, 0x15A5)
            {
                X            = 610,
                Y            = 445,
                ButtonAction = ButtonAction.Activate
            });


            _htmlControl = new HtmlControl(452, 60, 175, 367, true, true, ishtml: true, text: city.Description);
            Add(_htmlControl);

            if (Settings.GlobalSettings.ShardType == 2)
            {
                _htmlControl.IsVisible = false;
            }

            for (int i = 0; i < scene.Cities.Length; i++)
            {
                CityInfo c = scene.GetCity(i);

                if (c == null)
                {
                    continue;
                }

                int x = 0;
                int y = 0;

                if (c.IsNewCity)
                {
                    uint cityFacet = c.Map;

                    if (cityFacet > 5)
                    {
                        cityFacet = 5;
                    }

                    x = 62 + Utility.MathHelper.PercetangeOf(MapLoader.Instance.MapsDefaultSize[cityFacet, 0] - 2048, c.X, 383);
                    y = 54 + Utility.MathHelper.PercetangeOf(MapLoader.Instance.MapsDefaultSize[cityFacet, 1], c.Y, 384);
                }
                else if (i < _townButtonsText.Length)
                {
                    x = _townButtonsText[i].X;
                    y = _townButtonsText[i].Y;
                }

                CityControl control = new CityControl(c, x, y, i);
                Add(control);
                _cityControls.Add(control);

                if (Settings.GlobalSettings.ShardType == 2)
                {
                    control.IsVisible = false;
                }
            }

            SetCity(city);
        }
Example #36
0
    public void SaveRecord(int index, RecordCallback recordCallback)
    {
        KingInfo kInfo     = Informations.Instance.GetKingInfo(Controller.kingIndex);
        string   recordStr = "Record" + (index + 1);

        PlayerPrefs.SetInt(recordStr, 1);
        PlayerPrefs.SetInt(recordStr + "SelectKing", Controller.kingIndex);
        PlayerPrefs.SetInt(recordStr + "GeneralIndex", kInfo.generalIdx);
        PlayerPrefs.SetInt(recordStr + "CitiesNum", kInfo.cities.Count);
        PlayerPrefs.SetInt(recordStr + "GeneralsNum", kInfo.generals.Count);
        PlayerPrefs.SetInt(recordStr + "HistoryTime", Controller.historyTime);
        PlayerPrefs.Save();

        string path = "";

        if (Application.isEditor)
        {
            path = Application.dataPath + "/../SAVES/";
        }
        else
        {
            path = Application.persistentDataPath + "/SAVES/";
        }
        DirectoryInfo dir = new DirectoryInfo(path);

        if (!dir.Exists)
        {
            Directory.CreateDirectory(path);
        }

        path += "SANGO0" + (index + 1) + ".SAV.xml";

        XmlDocument xmlDoc      = new XmlDocument();
        XmlElement  rootElement = xmlDoc.CreateElement("GameRecord");

        xmlDoc.AppendChild(rootElement);

        XmlElement node = xmlDoc.CreateElement("Mod");

        node.SetAttribute("Index", Controller.MODSelect.ToString());
        rootElement.AppendChild(node);

        node = xmlDoc.CreateElement("HeadInfo");
        node.SetAttribute("SelectKing", Controller.kingIndex.ToString());
        node.SetAttribute("GeneralIndex", kInfo.generalIdx.ToString());
        node.SetAttribute("CitiesNum", kInfo.cities.Count.ToString());
        node.SetAttribute("GeneralsNum", kInfo.generals.Count.ToString());
        node.SetAttribute("HistoryTime", Controller.historyTime.ToString());
        rootElement.AppendChild(node);

        node = xmlDoc.CreateElement("Misc");
        node.SetAttribute("IsFirstEnter", StrategyController.isFirstEnter.ToString());
        node.SetAttribute("StrategyCamPos", StrategyController.strategyCamPos.ToString());
        rootElement.AppendChild(node);

        for (int i = 0; i < Informations.Instance.kingNum; i++)
        {
            node  = xmlDoc.CreateElement("KingsInfo");
            kInfo = Informations.Instance.GetKingInfo(i);
            node.SetAttribute("active", kInfo.active.ToString());
            node.SetAttribute("generalIdx", kInfo.generalIdx.ToString());
            rootElement.AppendChild(node);
        }

        for (int i = 0; i < Informations.Instance.cityNum; i++)
        {
            node = xmlDoc.CreateElement("CitiesInfo");
            CityInfo cInfo = Informations.Instance.GetCityInfo(i);

            node.SetAttribute("king", cInfo.king.ToString());
            node.SetAttribute("prefect", cInfo.prefect.ToString());
            node.SetAttribute("population", cInfo.population.ToString());
            node.SetAttribute("money", cInfo.money.ToString());
            node.SetAttribute("reservist", cInfo.reservist.ToString());
            node.SetAttribute("reservistMax", cInfo.reservistMax.ToString());
            node.SetAttribute("defense", cInfo.defense.ToString());

            List <string> objectStr = new List <string>();
            if (cInfo.objects != null && cInfo.objects.Count > 0)
            {
                for (int j = 0; j < cInfo.objects.Count; j++)
                {
                    objectStr.Add(cInfo.objects[j].ToString());
                }
                node.SetAttribute("objects", string.Join(",", objectStr.ToArray()));
            }

            rootElement.AppendChild(node);
        }

        for (int i = 0; i < Informations.Instance.generalNum; i++)
        {
            node = xmlDoc.CreateElement("GeneralsInfo");
            GeneralInfo gInfo = Informations.Instance.GetGeneralInfo(i);

            node.SetAttribute("active", gInfo.active.ToString());
            node.SetAttribute("king", gInfo.king.ToString());
            node.SetAttribute("city", gInfo.city.ToString());
            node.SetAttribute("prisonerIdx", gInfo.prisonerIdx.ToString());
            node.SetAttribute("loyalty", gInfo.loyalty.ToString());
            node.SetAttribute("job", gInfo.job.ToString());
            node.SetAttribute("equipment", gInfo.equipment.ToString());
            node.SetAttribute("strength", gInfo.strength.ToString());
            node.SetAttribute("intellect", gInfo.intellect.ToString());
            node.SetAttribute("experience", gInfo.experience.ToString());
            node.SetAttribute("level", gInfo.level.ToString());
            node.SetAttribute("healthMax", gInfo.healthMax.ToString());
            node.SetAttribute("healthCur", gInfo.healthCur.ToString());
            node.SetAttribute("manaMax", gInfo.manaMax.ToString());
            node.SetAttribute("manaCur", gInfo.manaCur.ToString());
            node.SetAttribute("soldierMax", gInfo.soldierMax.ToString());
            node.SetAttribute("soldierCur", gInfo.soldierCur.ToString());
            node.SetAttribute("knightMax", gInfo.knightMax.ToString());
            node.SetAttribute("knightCur", gInfo.knightCur.ToString());
            node.SetAttribute("arms", gInfo.arms.ToString());
            node.SetAttribute("armsCur", gInfo.armsCur.ToString());
            node.SetAttribute("formation", gInfo.formation.ToString());
            node.SetAttribute("formationCur", gInfo.formationCur.ToString());
            node.SetAttribute("escape", gInfo.escape.ToString());

            List <string> magicStr = new List <string>();
            for (int m = 0; m < 4; m++)
            {
                magicStr.Add(gInfo.magic[m].ToString());
            }
            node.SetAttribute("magic", string.Join(",", magicStr.ToArray()));

            rootElement.AppendChild(node);
        }

        if (Informations.Instance.armys.Count > 0)
        {
            for (int i = 0; i < Informations.Instance.armys.Count; i++)
            {
                node = xmlDoc.CreateElement("ArmiesInfo");

                ArmyInfo armyInfo = Informations.Instance.armys[i];
                node.SetAttribute("king", armyInfo.king.ToString());
                node.SetAttribute("cityFrom", armyInfo.cityFrom.ToString());
                node.SetAttribute("cityTo", armyInfo.cityTo.ToString());
                node.SetAttribute("commander", armyInfo.commander.ToString());
                node.SetAttribute("money", armyInfo.money.ToString());
                node.SetAttribute("state", armyInfo.state.ToString());
                node.SetAttribute("direction", armyInfo.direction.ToString());
                node.SetAttribute("isFlipped", armyInfo.isFlipped.ToString());
                node.SetAttribute("pos", armyInfo.pos.ToString());
                node.SetAttribute("timeTick", armyInfo.timeTick.ToString());

                List <string> generalStr = new List <string>();
                for (int j = 0; j < armyInfo.generals.Count; j++)
                {
                    generalStr.Add(armyInfo.generals[j].ToString());
                }
                node.SetAttribute("generals", string.Join(",", generalStr.ToArray()));

                if (armyInfo.prisons.Count > 0)
                {
                    List <string> prisonStr = new List <string>();
                    for (int j = 0; j < armyInfo.prisons.Count; j++)
                    {
                        prisonStr.Add(armyInfo.prisons[j].ToString());
                    }
                    node.SetAttribute("prisons", string.Join(",", prisonStr.ToArray()));
                }

                rootElement.AppendChild(node);
            }
        }

        xmlDoc.Save(path);

        if (recordCallback != null)
        {
            recordCallback();
        }
    }
Example #37
0
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            var state = args.State;

            if (state == null)
            {
                return;
            }

            var newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Character creation failed, account full", state);
                Utility.PopColor();
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female      = args.Female;
            //newChar.Body = newChar.Female ? 0x191 : 0x190;

            if (Core.Expansion >= args.Race.RequiredExpansion)
            {
                newChar.Race = args.Race;                 //Sets body
            }
            else
            {
                newChar.Race = Race.DefaultRace;
            }

            newChar.Hue = args.Hue | 0x8000;

            newChar.Hunger = 20;

            var young = false;

            if (newChar is PlayerMobile)
            {
                var pm = (PlayerMobile)newChar;

                pm.AutoRenewInsurance = true;

                var skillcap = Config.Get("PlayerCaps.SkillCap", 1000.0d) / 10;

                if (skillcap != 100.0)
                {
                    for (var i = 0; i < Enum.GetNames(typeof(SkillName)).Length; ++i)
                    {
                        pm.Skills[i].Cap = skillcap;
                    }
                }

                pm.Profession = args.Profession;

                //if (pm.IsPlayer() && pm.Account.Young && !Siege.SiegeShard)
                //young = pm.Young = true;
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, state, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            var race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = args.HairHue;
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = args.BeardHue;
            }

            var faceID = args.FaceID;

            if (faceID > 0 && race.ValidateFace(newChar.Female, faceID))
            {
                newChar.FaceItemID = faceID;
                newChar.FaceHue    = args.FaceHue;
            }
            else
            {
                newChar.FaceItemID = race.RandomFace(newChar.Female);
                newChar.FaceHue    = newChar.Hue;
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                TestCenter.FillBankbox(newChar);
            }

            if (young)
            {
                var ticket = new NewPlayerTicket
                {
                    Owner = newChar
                };

                newChar.BankBox.DropItem(ticket);
            }

            var city = args.City;

            city = new CityInfo("The Void", "A strange place, floating in the void.", 1150168, 5267, 2768, 2, Map.Felucca);
            var map = Map.Felucca;             // Siege.SiegeShard && city.Map == Map.Trammel ? Map.Felucca : city.Map;

            newChar.MoveToWorld(city.Location, map);

            Utility.PushColor(ConsoleColor.Green);
            Console.WriteLine("Login: {0}: New character being created (account={1})", state, args.Account.Username);
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.DarkGreen);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map);
            Utility.PopColor();

            new WelcomeTimer(newChar).Start();
        }
Example #38
0
    public void LoadRecord(int index, RecordCallback recordCallback)
    {
        string path = "";

        if (Application.isEditor)
        {
            path = Application.dataPath + "/../SAVES/";
        }
        else
        {
            path = Application.persistentDataPath + "/SAVES/";
        }
        DirectoryInfo dir = new DirectoryInfo(path);

        if (!dir.Exists)
        {
            return;
        }

        int    idx      = index;
        string filePath = path + "SANGO0" + (idx + 1) + ".SAV.xml";

        if (!File.Exists(filePath))
        {
            return;
        }

        Informations.Reset();

        XmlDocument  xmlDoc = new XmlDocument();
        StreamReader sr     = File.OpenText(filePath);

        xmlDoc.LoadXml(sr.ReadToEnd().Trim());
        XmlElement root = xmlDoc.DocumentElement;
        XmlElement node;

        node = (XmlElement)root.SelectSingleNode("Mod");
        if (node != null)
        {
            Controller.MODSelect = int.Parse(node.GetAttribute("Index"));
        }
        else
        {
            Controller.MODSelect = 1;
        }
        Informations.Instance.kingNum = Informations.Instance.modKingNum[Controller.MODSelect];

        node = (XmlElement)root.SelectSingleNode("HeadInfo");
        Controller.kingIndex   = int.Parse(node.GetAttribute("SelectKing"));
        Controller.historyTime = int.Parse(node.GetAttribute("HistoryTime"));

        node = (XmlElement)root.SelectSingleNode("Misc");
        StrategyController.isFirstEnter   = bool.Parse(node.GetAttribute("IsFirstEnter"));
        StrategyController.strategyCamPos = StringToVector3(node.GetAttribute("StrategyCamPos"));

        XmlNodeList nodeList = root.SelectNodes("KingsInfo");
        int         i        = 0;

        foreach (XmlElement kingNode in nodeList)
        {
            KingInfo kInfo = new KingInfo();
            kInfo.active     = int.Parse(kingNode.GetAttribute("active"));
            kInfo.generalIdx = int.Parse(kingNode.GetAttribute("generalIdx"));
            Informations.Instance.SetKingInfo(i++, kInfo);
        }
        KingInfo k = new KingInfo();

        k.generalIdx = 0;
        Informations.Instance.SetKingInfo(Informations.Instance.kingNum, k);

        i        = 0;
        nodeList = root.SelectNodes("CitiesInfo");
        foreach (XmlElement cityNode in nodeList)
        {
            CityInfo cInfo = new CityInfo();
            cInfo.king         = int.Parse(cityNode.GetAttribute("king"));
            cInfo.prefect      = int.Parse(cityNode.GetAttribute("prefect"));
            cInfo.population   = int.Parse(cityNode.GetAttribute("population"));
            cInfo.money        = int.Parse(cityNode.GetAttribute("money"));
            cInfo.reservist    = int.Parse(cityNode.GetAttribute("reservist"));
            cInfo.reservistMax = int.Parse(cityNode.GetAttribute("reservistMax"));
            cInfo.defense      = int.Parse(cityNode.GetAttribute("defense"));

            if (cityNode.HasAttribute("objects"))
            {
                string   str        = cityNode.GetAttribute("objects");
                string[] objectsStr = str.Split(',');
                cInfo.objects = new List <int>();
                for (int j = 0; j < objectsStr.Length; j++)
                {
                    cInfo.objects.Add(int.Parse(objectsStr[j]));
                }
            }

            Informations.Instance.SetCityInfo(i++, cInfo);
        }

        i        = 0;
        nodeList = root.SelectNodes("GeneralsInfo");
        foreach (XmlElement generalNode in nodeList)
        {
            GeneralInfo gInfo = new GeneralInfo();
            gInfo.active       = int.Parse(generalNode.GetAttribute("active"));
            gInfo.king         = int.Parse(generalNode.GetAttribute("king"));
            gInfo.city         = int.Parse(generalNode.GetAttribute("city"));
            gInfo.prisonerIdx  = int.Parse(generalNode.GetAttribute("prisonerIdx"));
            gInfo.loyalty      = int.Parse(generalNode.GetAttribute("loyalty"));
            gInfo.job          = int.Parse(generalNode.GetAttribute("job"));
            gInfo.equipment    = int.Parse(generalNode.GetAttribute("equipment"));
            gInfo.strength     = int.Parse(generalNode.GetAttribute("strength"));
            gInfo.intellect    = int.Parse(generalNode.GetAttribute("intellect"));
            gInfo.experience   = int.Parse(generalNode.GetAttribute("experience"));
            gInfo.level        = int.Parse(generalNode.GetAttribute("level"));
            gInfo.healthMax    = int.Parse(generalNode.GetAttribute("healthMax"));
            gInfo.healthCur    = int.Parse(generalNode.GetAttribute("healthCur"));
            gInfo.manaMax      = int.Parse(generalNode.GetAttribute("manaMax"));
            gInfo.manaCur      = int.Parse(generalNode.GetAttribute("manaCur"));
            gInfo.soldierMax   = int.Parse(generalNode.GetAttribute("soldierMax"));
            gInfo.soldierCur   = int.Parse(generalNode.GetAttribute("soldierCur"));
            gInfo.knightMax    = int.Parse(generalNode.GetAttribute("knightMax"));
            gInfo.knightCur    = int.Parse(generalNode.GetAttribute("knightCur"));
            gInfo.arms         = int.Parse(generalNode.GetAttribute("arms"));
            gInfo.armsCur      = int.Parse(generalNode.GetAttribute("armsCur"));
            gInfo.formation    = int.Parse(generalNode.GetAttribute("formation"));
            gInfo.formationCur = int.Parse(generalNode.GetAttribute("formationCur"));
            gInfo.escape       = int.Parse(generalNode.GetAttribute("escape"));

            string[] magics = generalNode.GetAttribute("magic").Split(',');

            for (int m = 0; m < 4; m++)
            {
                gInfo.magic[m] = int.Parse(magics[m]);
            }

            Informations.Instance.SetGeneralInfo(i++, gInfo);

            //check
            gInfo.soldierCur = Mathf.Clamp(gInfo.soldierCur, 0, gInfo.soldierMax);
            gInfo.knightCur  = Mathf.Clamp(gInfo.knightCur, 0, gInfo.knightMax);
        }

        nodeList = root.SelectNodes("ArmiesInfo");
        if (nodeList != null && nodeList.Count > 0)
        {
            i = 0;
            foreach (XmlElement armyNode in nodeList)
            {
                ArmyInfo armyInfo = new ArmyInfo();
                armyInfo.king      = int.Parse(armyNode.GetAttribute("king"));
                armyInfo.cityFrom  = int.Parse(armyNode.GetAttribute("cityFrom"));
                armyInfo.cityTo    = int.Parse(armyNode.GetAttribute("cityTo"));
                armyInfo.commander = int.Parse(armyNode.GetAttribute("commander"));
                armyInfo.money     = int.Parse(armyNode.GetAttribute("money"));
                armyInfo.state     = int.Parse(armyNode.GetAttribute("state"));
                armyInfo.direction = int.Parse(armyNode.GetAttribute("direction"));
                armyInfo.isFlipped = bool.Parse(armyNode.GetAttribute("isFlipped"));
                armyInfo.pos       = StringToVector3(armyNode.GetAttribute("pos"));
                armyInfo.timeTick  = float.Parse(armyNode.GetAttribute("timeTick"));

                if (armyNode.HasAttribute("generals"))
                {
                    string[] generals = armyNode.GetAttribute("generals").Split(',');
                    for (int j = 0; j < generals.Length; j++)
                    {
                        int temp = int.Parse(generals[j]);
                        armyInfo.generals.Add(temp);
                        //check
                        GeneralInfo gInfo = Informations.Instance.GetGeneralInfo(temp);
                        gInfo.city        = -1;
                        gInfo.king        = armyInfo.king;
                        gInfo.prisonerIdx = -1;
                    }
                }

                if (armyInfo.generals.Count == 0)
                {
                    continue;
                }

                if (armyNode.HasAttribute("prisons"))
                {
                    string[] prisons = armyNode.GetAttribute("prisons").Split(',');
                    for (int j = 0; j < prisons.Length; j++)
                    {
                        int temp = int.Parse(prisons[j]);
                        armyInfo.prisons.Add(temp);
                        //check
                        GeneralInfo gInfo = Informations.Instance.GetGeneralInfo(temp);
                        gInfo.city        = -1;
                        gInfo.prisonerIdx = armyInfo.king;
                    }
                }

                Informations.Instance.armys.Add(armyInfo);
            }
        }

        Informations.Instance.InitKingInfo();
        Informations.Instance.InitCityInfo();

        if (recordCallback != null)
        {
            recordCallback();
        }
    }
 /// <summary>
 /// Print information about the city that was rejected
 /// </summary>
 /// <param name="city"></param>
 /// <param name="newCityInfo"></param>
 /// <param name="oldCityInfo"></param>
 public void PrintRejectedCity(City city, CityInfo newCityInfo,
     CityInfo oldCityInfo)
 {
     PrintBreak();
     textBox.Dispatcher.Invoke(
         new Action(delegate()
         {
             textBox.Text += string.Format("Reject city (already visited): {0}\n",
                 city.getName());
             textBox.Text += string.Format("Old distance from start: {0:0.##}\n",
                 oldCityInfo.FromStart);
             textBox.Text += string.Format("New distance from start: {0:0.##}\n",
                 newCityInfo.FromStart);
         }),
         DispatcherPriority.Normal, null);
 }
Example #40
0
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            NetState state = args.State;

            if (state == null)
            {
                return;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Login: {0}: Character creation failed, account full", state);
                Utility.PopColor();
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female      = args.Female;
            //newChar.Body = newChar.Female ? 0x191 : 0x190;

            if (Core.Expansion >= args.Race.RequiredExpansion)
            {
                newChar.Race = args.Race;       //Sets body
            }
            else
            {
                newChar.Race = Race.DefaultRace;
            }

            //newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000;
            newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;

            newChar.Hunger = 20;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm       = (PlayerMobile)newChar;
                double       skillcap = Config.Get("PlayerCaps.SkillCap", 1000.0d) / 10;
                if (skillcap != 100.0)
                {
                    for (int i = 0; i < Enum.GetNames(typeof(SkillName)).Length; ++i)
                    {
                        pm.Skills[i].Cap = skillcap;
                    }
                }
                pm.Profession = args.Profession;

                if (pm.IsPlayer() && ((Account)pm.Account).Young)
                {
                    young = pm.Young = true;
                }
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, state, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                TestCenter.FillBankbox(newChar);
            }

            if (young)
            {
                NewPlayerTicket ticket = new NewPlayerTicket();
                ticket.Owner = newChar;
                newChar.BankBox.DropItem(ticket);
            }

            CityInfo city = GetStartLocation(args, young);

            newChar.MoveToWorld(city.Location, city.Map);

            Utility.PushColor(ConsoleColor.Green);
            Console.WriteLine("Login: {0}: New character being created (account={1})", state, args.Account.Username);
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.DarkGreen);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map.ToString());
            Utility.PopColor();

            new WelcomeTimer(newChar).Start();
        }
    public void OnSceneGUI()
    {
        if (city == null)
        {
            city = (target as CityGenerator).City;
        }

        if (city != null && city.Nodes != null && city.Nodes.Count > 0)
        {
            DrawCityGraph();
        }

        // Get event info
        Event e = Event.current;

        switch (e.type)
        {
        case EventType.KeyDown:
            if (e.keyCode == KeyCode.LeftControl)
            {
                modifierKey = true;
            }
            else if (e.keyCode == KeyCode.M && modifierKey)
            {
                // Ctrl + M for merge
                MergeIntersectionByDistance(selectedNode);
            }
            break;

        case EventType.KeyUp:
            if (e.keyCode == KeyCode.LeftControl)
            {
                modifierKey = false;
            }
            break;

        case EventType.MouseDown:
            // Ctrl + Click causes an intersection to be created from the selected node
            if (modifierKey && selectedNode != null)
            {
                Vector3 mousePosition = Event.current.mousePosition;
                Ray     ray           = HandleUtility.GUIPointToWorldRay(mousePosition);

                float distance = 0.0f;
                if (horizontalPlane.Raycast(ray, out distance))
                {
                    selectedNode = selectedNode.CreateNewIntersection(ray.GetPoint(distance), city);
                }
                else
                {
                    Debug.LogWarning("Could not create new intersection since point was attempting to be made in the sky.");
                }
            }
            break;

        default:
            break;
        }

        Selection.activeGameObject = (target as CityGenerator).gameObject;
    }
Example #42
0
        public LohanaPackageTariffSearchViewModel()
        {
            FriendlyMessage = new List <FriendlyMessage>();

            LohanaPackageTariffSearch = new LohanaPackageTariffSearchInfo();

            LohanaPackageTariffSearchList = new List <LohanaPackageTariffSearchInfo>();

            LohanaPackageTariffRoot = new LohanaPackageTariffRootInfo();

            LohanaPackageTariffRootList = new List <LohanaPackageTariffRootInfo>();

            LohanaPackageTariff = new LohanaPackageTariffInfo();

            LohanaPackageTariffList = new List <LohanaPackageTariffInfo>();

            HotelTariff = new HotelTariffInfo();

            HotelTariffs = new List <HotelTariffInfo>();

            PackageType = new PackageTypeInfo();

            PackageTypes = new List <PackageTypeInfo>();

            Hotel = new HotelInfo();

            Hotels = new List <HotelInfo>();

            RoomType = new RoomTypeInfo();

            Cities = new List <CityInfo>();

            City = new CityInfo();

            Pager = new PaginationInfo();

            HotelTariffDate = new HotelTariffDateDetailsInfo();

            HotelTariffDates = new List <HotelTariffDateDetailsInfo>();

            HotelTariffDuration = new HotelTariffDurationDetailsInfo();

            HotelTariffDurations = new List <HotelTariffDurationDetailsInfo>();

            HotelTariffPrice = new HotelTariffPriceDetailsInfo();

            HotelTariffPrices = new List <HotelTariffPriceDetailsInfo>();

            HotelTariffRoom = new HotelTariffRoomDetailsInfo();

            HotelTariffRooms = new List <HotelTariffRoomDetailsInfo>();


            LohanaPackageTariffSearchRoomList = new List <LohanaPackageTariffSearchInfo>();

            LohanaPackageTariffSearchExtraChildList = new List <LohanaPackageTariffSearchInfo>();

            LohanaPackageTariffSearchExtraList = new List <LohanaPackageTariffSearchInfo>();

            LohanaPackageTariffSearchFilter = new LohanaPackageTariffSearchInfo();

            LohanaPackageTariffSearchFilterList = new List <LohanaPackageTariffSearchInfo>();


            LohanaPackageItienaryList = new List <LohanaPackageTariffSearchInfo>();


            Enquiry = new EnquiryInfo();
        }
 private void ExecuteGoToDetails(CityInfo item)
 {
     ((IMainPageViewModel)DataContext).GoToDetails.Execute(item);
 }
Example #44
0
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            NetState state = args.State;

            if (state == null)
            {
                return;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Console.WriteLine("Login: {0}: Character creation failed, account full", state);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = args.Account.AccessLevel;
            newChar.Female      = args.Female;
            //newChar.Body = newChar.Female ? 0x191 : 0x190;

            newChar.Race = Race.DefaultRace;

            //newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000;
            newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;

            newChar.Hunger = 20;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)newChar;

                pm.Profession = args.Profession;

                if (pm.AccessLevel == AccessLevel.Player && ((Account)pm.Account).Young)
                {
                    young = pm.Young = true;
                }
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, state, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                FillBankbox(newChar);
            }

            if (young)
            {
                NewPlayerTicket ticket = new NewPlayerTicket();
                ticket.Owner = newChar;
                newChar.BankBox.DropItem(ticket);
            }

            CityInfo city = GetStartLocation(args, young);

            newChar.MoveToWorld(city.Location, city.Map);

            Console.WriteLine("Login: {0}: New character being created (account={1})", state, args.Account.Username);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map);

            new WelcomeTimer(newChar).Start();
        }
 private void HandleAddCity(CityInfo info)
 {
     if (!Clocks.Contains(info))
         Clocks.Add(info);
 }
        private void ApplySelectionInternal(SelectionChangedEventArgs obj)
        {
            if (obj.AddedItems.Count > 0)
            {
                var cityInfo = obj.AddedItems.First() as CityInfo;
                if (cityInfo != null)
                    _info = cityInfo;

                Date = _clock.ConvertTime(_info.TimeZoneId, DateTime.Now);
                OnPropertyChanged(() => UTCOffset);
            }
        }
    private static RankingMember scoreCity(RankingMember rankingMember, CityInfo city, string formula, DatabaseContext db)
    {
        FormulaScore.FormulaScore scorer = new FormulaScore.FormulaScore();
        scorer.ScoringFormula = formula;

        // Load scoring values into scorer.
        List<string> scoringIdentifiers = FormulaScore.FormulaScore.FetchScoringIDs(formula);
        double value;
        foreach (string scoringId in scoringIdentifiers)
        {
            if (GetCityValue.IsValueIdentifier(scoringId, db))
            {
                value = GetCityValue.GetValue(scoringId, city, db);
                scorer.AddScoringValue(scoringId, value);
            }
        }

        rankingMember.Score = Math.Round(scorer.CalculateScore(), 0);
        rankingMember.DetailedScoring = scorer.GetFormulaWithValues();

        return rankingMember;
    }
        /* DESCRIPTION:
         * This method implements the A Algorithm.
         * Uses direct distance to the final city as a heuristic.
         * At each step finds the best next city to explore from citiesToExplore.
         * Finds the cities connected to it and examines them.
         * If the connected city is already found, then it examines is the new path to
         * it shorter than the already known one. If it is, than it renew the information
         * about the city in foundCities and citiesToExplore.
         * If the city has not been found yet, then it add it to citiesToExplore and
         * foundCities.
         * When all cities have been explored it finds the minimal path using the idea
         * that if the city B preceds the destination city A in the minimum path,
         * then the minimum path also includes the minimum path from the start city
         * to B. Thus, it goes from city to city in the reverse order and adds them
         * to the minimum path.
         */
        public List<City> FindOptimalPath(City startCity, City endCity)
        {
            City nextCity;                      // Next city to explore
            CityInfo nextCityInfo;              // Next city information
            CityInfo nextConnectedCityInfo;     // Information about the currently examined city connected to nextCity
            CityInfo nextConnectedCityOldInfo;  // Old information about the currently examined city
            List<City> nextCityConnections;     // Connections of the nextCity
            Coordinates tempStartPoint, tempEndPoint; // Help variables. Store points on the map.
            City tempCity, tempPrevCity;        // Help variables. Store consecutive sities in the optimal path
            CityInfo tempCityInfo;              // Help variable. Stores a city's info
            HighlightManager highlightManager;

            // Start with the start city:))
            nextCity = startCity;
            nextCityInfo = new CityInfo(this, startCity, null, endCity, 0);

            // Initialize
            foundCities = new Dictionary<City, CityInfo>();
            citiesToExplore = new Dictionary<City, CityInfo>();
            highlightManager = new HighlightManager(graphLayout);

            // Add the start city
            foundCities.Add(nextCity, nextCityInfo);
            citiesToExplore.Add(nextCity, nextCityInfo);

            // While we have cities to explore
            while (citiesToExplore.Count != 0)
            {
                // Find the next best city among citiesToExplore
                nextCity = FindBest();

                highlightManager.MarkNode(nextCity, Graph_Colors.BestNode);
                Thread.Sleep(SLEEP_TIME);

                // Get its info and connections
                citiesToExplore.TryGetValue(nextCity, out nextCityInfo);
                citiesConnecitons.connections.TryGetValue(nextCity, out nextCityConnections);

                // Examine all the connections of the nextCity
                foreach (City nextConnectedCity in nextCityConnections)
                {
                    highlightManager.MarkNode(nextConnectedCity, Graph_Colors.CheckedNode);
                    highlightManager.MarkEdge(nextCity, nextConnectedCity, Graph_Colors.CheckedEdge);
                    Thread.Sleep(SLEEP_TIME);

                    // Get the examined city location and the nextCity location
                    citiesLocations.locations.TryGetValue(nextCity, out tempStartPoint);
                    citiesLocations.locations.TryGetValue(nextConnectedCity, out tempEndPoint);
                    // Create information about the currently examined city
                    nextConnectedCityInfo = new CityInfo(this, nextConnectedCity, nextCity, endCity,
                                                         FindDistance(tempStartPoint, tempEndPoint) +
                                                         nextCityInfo.getFromStart());

                    // If the examined city has already been found.
                    // If the current path is better, then update the city's info
                    if (foundCities.ContainsKey(nextConnectedCity))
                    {
                        // Get the city's old info from foundCities
                        foundCities.TryGetValue(nextConnectedCity, out nextConnectedCityOldInfo);

                        // Compare its old path distance to the new path distance
                        if (nextConnectedCityInfo.getPathDistance() <
                            nextConnectedCityOldInfo.getPathDistance())
                        {
                            // Update the info if the new path is shorter
                            nextConnectedCityOldInfo.prevCity = nextConnectedCityInfo.prevCity;
                            nextConnectedCityOldInfo.setFromStart(nextConnectedCityInfo.getFromStart());

                            highlightManager.MarkNode(nextConnectedCity, Graph_Colors.UpdatedNode);
                            Thread.Sleep(SLEEP_TIME);
                        }
                        else
                        {
                            highlightManager.MarkNode(nextConnectedCity, Graph_Colors.RejectedNode);
                            Thread.Sleep(SLEEP_TIME);
                        }
                    }
                    // If we have not found this city so far.
                    // Add it to foundCities and citiesToExplore.
                    else
                    {
                        // Add the city to foundCities and citiesToExplore.
                        foundCities.Add(nextConnectedCity, nextConnectedCityInfo);
                        citiesToExplore.Add(nextConnectedCity, nextConnectedCityInfo);

                        highlightManager.MarkNode(nextConnectedCity, Graph_Colors.AddedNode);
                        Thread.Sleep(SLEEP_TIME);
                    }
                }

                // Mark nextCity as explored.
                // Remove it from citiesToExplore
                nextCityInfo.IsExplored = true;
                citiesToExplore.Remove(nextCity);

                highlightManager.UnmarkAllNodes();
                highlightManager.UnmarkAllEdges();

                foreach (City city in foundCities.Keys)
                {
                    foundCities.TryGetValue(city, out tempCityInfo);
                    if (tempCityInfo.IsExplored)
                    {
                        highlightManager.MarkNode(city, Graph_Colors.ExploredNode);
                    }
                }
                Thread.Sleep(SLEEP_TIME);
            }

            // If we were able to reach the destination,
            // then construct the optimal path.
            if (foundCities.ContainsKey(endCity))
            {
                // Start with the end city
                tempCity = endCity;
                // Get the end city info
                foundCities.TryGetValue(tempCity, out tempCityInfo);

                // Initialize
                List<City> optimalPath = new List<City>();

                // Add the end city to the optimal path
                optimalPath.Add(tempCity);

                // Set the city that preceds the end city in the optimal path
                tempPrevCity = tempCityInfo.prevCity;

                // While we have not reached the start city
                while (tempPrevCity != null)
                {
                    // Add the city that preceds the current city in the optimal path
                    tempCity = tempPrevCity;
                    optimalPath.Add(tempCity);

                    // Move to the previous city in the path in order to
                    // add it in the next loop iteration.
                    foundCities.TryGetValue(tempCity, out tempCityInfo);
                    tempPrevCity = tempCityInfo.prevCity;
                }

                return (optimalPath);
            }
            // Output an error if the destination could not be reached.
            else
            {
                Console.WriteLine("ERROR! Cannot find any path.");
                return (null);
            }
        }
 /// <summary>
 /// New city server came online!
 /// </summary>
 public static void OnNewCityServer(NetworkClient Client, ProcessedPacket Packet)
 {
     lock (NetworkFacade.Cities)
     {
         CityInfo Info = new CityInfo(false);
         Info.Name = Packet.ReadString();
         Info.Description = Packet.ReadString();
         Info.IP = Packet.ReadString();
         Info.Port = Packet.ReadInt32();
         Info.Status = (CityInfoStatus)Packet.ReadByte();
         Info.Thumbnail = Packet.ReadUInt64();
         Info.UUID = Packet.ReadString();
         Info.Map = Packet.ReadUInt64();
         NetworkFacade.Cities.Add(Info);
     }
 }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        city = (target as CityGenerator).City;

        if (city != null)
        {
            if (city != previousCity)
            {
                Init();
            }

            currentTab = GUILayout.Toolbar(currentTab, tabs);

            switch (currentTab)
            {
            // General
            case 0:
                // Button to generate the city
                if (GUILayout.Button("Generate City"))
                {
                    GenerateCity();
                }
                break;

            // Intersection
            case 1:
                if (selectedNode != null)
                {
                    GUILayout.Label($"Selected Intersection Tools:");
                    StartIndent(10.0f);
                    {
                        selectedNode.Position = EditorGUILayout.Vector3Field("Position", selectedNode.Position);
                        if (GUILayout.Button("Merge Nearby"))
                        {
                            MergeIntersectionByDistance(selectedNode);
                        }

                        if (GUILayout.Button("Delete Intersection"))
                        {
                            if (city.Nodes.Count > 1)
                            {
                                DeleteIntersection(selectedNode);
                            }
                            else
                            {
                                Debug.Log("Cannot delete the final intersection of this city");
                            }
                        }
                    }
                    EndIndent();
                }
                else
                {
                    EditorGUILayout.LabelField("There is no selected intersection");
                }
                break;

            // Road
            case 2:
                if (selectedNode != null)
                {
                    // Inspector for Roads
                    GUILayout.Label("Road Tools");
                    StartIndent(10.0f);
                    {
                        for (int i = 0; i < selectedNode.Roads.Count; i++)
                        {
                            GUILayout.Label($"Road {i}:");
                            StartIndent(30.0f);
                            {
                                selectedNode.Roads[i].RoadWidth = EditorGUILayout.FloatField("Width:", selectedNode.Roads[i].RoadWidth);
                                selectedNode.Roads[i].SetRoadOffset(EditorGUILayout.FloatField("Offset:", selectedNode.Roads[i].GetRoadOffset(selectedNode)), selectedNode);
                                GUILayout.BeginHorizontal();
                                {
                                    if (GUILayout.Button("Split"))
                                    {
                                        selectedNode.SplitRoad(selectedNode.Roads[i], city);
                                    }

                                    if (GUILayout.Button("Delete"))
                                    {
                                        selectedNode.RemoveConnection(selectedNode.Roads[i]);
                                    }
                                }
                                GUILayout.EndHorizontal();
                            }
                            EndIndent();
                        }
                    }
                    EndIndent();
                }
                break;

            // Buildings
            case 3:
                // Create our building list
                SerializedObject   cityObject   = new SerializedObject(city);
                SerializedProperty buildingList = cityObject.FindProperty("buildings");
                EditorGUILayout.PropertyField(buildingList);
                cityObject.ApplyModifiedProperties();
                break;

            // Materials
            case 4:
                // Get all material fields
                city.RoadMaterial       = EditorGUILayout.ObjectField("Road Material", city.RoadMaterial, typeof(Material), false) as Material;
                city.SidewalkMaterial   = EditorGUILayout.ObjectField("General Sidewalk Material", city.SidewalkMaterial, typeof(Material), false) as Material;
                city.InnerBlockMaterial = EditorGUILayout.ObjectField("Sidewalk Fill Material", city.InnerBlockMaterial, typeof(Material), false) as Material;
                break;

            // Preview
            case 5:
                baseColor     = SetEditorColorField(BASE_COLOR_NAME, ref baseColor);
                selectedColor = SetEditorColorField(SELECTED_COLOR_NAME, ref selectedColor);
                break;

            default:
                break;
            }
        }

        previousCity = city;
    }
        /// <summary>
        /// Reconnects to a CityServer.
        /// </summary>
        public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs)
        {
            Client.Disconnect();

            if (LoginArgs.Enc == null)
            {
                Debug.WriteLine("LoginArgs.Enc was null!");
                LoginArgs.Enc = new GonzoNet.Encryption.AESEncryptor(Convert.ToBase64String(PlayerAccount.Hash));
            }
            else if (LoginArgs.Username == null || LoginArgs.Password == null)
            {
                Debug.WriteLine("LoginArgs.Username or LoginArgs.Password was null!");
                LoginArgs.Username = PlayerAccount.Username;
                LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
            }

            Client.Connect(LoginArgs);
        }
Example #52
0
        private static void EventSink_CreateCharRequest(CreateCharRequestEventArgs args)
        {
            string name = args.Name.Trim();

            if (!VerifyName(name))
            {
                Console.WriteLine("Login: {0}: Character creation failed, invalid name '{1}'", args.State, args.Name);

                args.State.BlockAllPackets = false;
                args.State.Send(new PopupMessage(PMMessage.InvalidName));
                return;
            }

            if (!VerifyProfession(args.Profession))
            {
                args.Profession = 0;
            }

            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Console.WriteLine("Login: {0}: Character creation failed, account full", args.State);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = ((Account)args.Account).AccessLevel;
            newChar.Female      = args.Female;
            newChar.Race        = args.Race;
            newChar.Hue         = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;
            newChar.Hunger      = 20;

            bool young = false;

            if (newChar is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)newChar;

                pm.Profession = args.Profession;

                if (pm.AccessLevel == AccessLevel.Player && ((Account)pm.Account).Young && (pm.Profession != 0) && !(pm.Profession == 6 || pm.Profession == 7))
                {
                    young = pm.Young = true;
                }

                if (pm.Race == Race.Gargoyle)
                {
                    pm.LoyaltyInfo.SetValue(Engines.Loyalty.LoyaltyGroup.GargoyleQueen, 2000);
                }
            }

            newChar.Name = name;

            AddBackpack(newChar);

            SetStats(newChar, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            Race race = newChar.Race;

            if (race.ValidateHair(newChar, args.HairID))
            {
                newChar.HairItemID = args.HairID;
                newChar.HairHue    = race.ClipHairHue(args.HairHue & 0x3FFF);
            }

            if (race.ValidateFacialHair(newChar, args.BeardID))
            {
                newChar.FacialHairItemID = args.BeardID;
                newChar.FacialHairHue    = race.ClipHairHue(args.BeardHue & 0x3FFF);
            }

            if (args.Profession <= 3)
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            CityInfo city = GetStartLocation(args, young);

            newChar.MoveToWorld(city.Location, city.Map);

            Console.WriteLine("Login: {0}: New character being created (account={1})", args.State, ((Account)args.Account).Username);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map.ToString());
        }
        public static void OnCityInfoResponse(ProcessedPacket Packet)
        {
            byte NumCities = (byte)Packet.ReadByte();

            if (Packet.DecryptedLength > 1)
            {
                for (int i = 0; i < NumCities; i++)
                {
                    string Name = Packet.ReadString();
                    string Description = Packet.ReadString();
                    string IP = Packet.ReadString();
                    int Port = Packet.ReadInt32();
                    byte StatusByte = (byte)Packet.ReadByte();
                    CityInfoStatus Status = (CityInfoStatus)StatusByte;
                    ulong Thumbnail = Packet.ReadUInt64();
                    string UUID = Packet.ReadString();
                    ulong Map = Packet.ReadUInt64();

                    CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);
                    Info.Online = true;
                    Info.Status = Status;
                    NetworkFacade.Cities.Add(Info);
                }
            }
        }
 /// <summary>
 /// Received token from LoginServer - proceed to CityServer!
 /// </summary>
 private void Controller_OnCityToken(CityInfo SelectedCity)
 {
     GameFacade.Controller.ShowCityTransition(SelectedCity, false);
 }
 public void ShowCityTransition(CityInfo selectedCity, bool CharacterCreated)
 {
     GameFacade.Screens.RemoveCurrent();
     GameFacade.Screens.AddScreen(new CityTransitionScreen(selectedCity, CharacterCreated));
 }
Example #56
0
    void AttackCity(int cIdx)
    {
        CityInfo cInfo = Informations.Instance.GetCityInfo(cIdx);

        int result   = 0;
        int selfIdx  = 0;
        int enemyIdx = 0;

        if (cInfo.king != -1)
        {
            if (cInfo.king == Controller.kingIndex)
            {
                strCtrl.SetWarDialogue(cIdx, armyInfo);
                return;
            }
            else if (armyInfo.king == Controller.kingIndex)
            {
                strCtrl.SetWarDialogue(armyInfo, cIdx);
                return;
            }
        }
        else
        {
            result = 1;
        }

        while (result == 0)
        {
            GeneralInfo selfGeneral  = Informations.Instance.GetGeneralInfo(armyInfo.generals[selfIdx]);
            GeneralInfo enemyGeneral = Informations.Instance.GetGeneralInfo(cInfo.generals[enemyIdx]);

            int power1 = selfGeneral.level * 5 + selfGeneral.knightCur * 6 + selfGeneral.soldierCur * 3 + selfGeneral.strength * 2 + selfGeneral.healthCur + selfGeneral.manaCur / 2 + Random.Range(0, 20);
            int power2 = enemyGeneral.level * 5 + enemyGeneral.knightCur * 6 + enemyGeneral.soldierCur * 3 + enemyGeneral.strength * 2 + enemyGeneral.healthCur + enemyGeneral.manaCur / 2 + cInfo.defense / 10 + Random.Range(0, 20);

            if (power1 > power2)
            {
                WarResult(selfGeneral, enemyGeneral, power2);
                enemyIdx++;
            }
            else
            {
                WarResult(enemyGeneral, selfGeneral, power1);
                selfIdx++;
            }

            if (selfIdx >= armyInfo.generals.Count)
            {
                result = 2;
            }
            else if (enemyIdx >= cInfo.generals.Count)
            {
                result = 1;
            }
        }

        if (result == 1)
        {
            for (int i = 0; i < armyInfo.generals.Count; i++)
            {
                Informations.Instance.GetGeneralInfo(armyInfo.generals[i]).prisonerIdx = -1;
                Informations.Instance.GetGeneralInfo(armyInfo.generals[i]).city        = cIdx;
                Informations.Instance.GetGeneralInfo(armyInfo.generals[i]).escape      = 0;
                CheckIsLevelUp(Informations.Instance.GetGeneralInfo(armyInfo.generals[i]));
            }

            int count = cInfo.generals.Count;
            for (int i = count - 1; i >= 0; i--)
            {
                if (Informations.Instance.GetGeneralInfo(cInfo.generals[i]).prisonerIdx == armyInfo.king)
                {
                    cInfo.prisons.Add(cInfo.generals[i]);
                    Informations.Instance.GetKingInfo(cInfo.king).generals.Remove(cInfo.generals[i]);

                    if (cInfo.generals[i] == Informations.Instance.GetKingInfo(cInfo.king).generalIdx)
                    {
                        SetKingOver(cInfo.king);
                    }

                    cInfo.generals.RemoveAt(i);
                }
            }

            count = cInfo.generals.Count;
            if (count > 0)
            {
                SetEscapeFromCity(cIdx);
            }

            //cInfo.generals.Clear();
            cInfo.generals.AddRange(armyInfo.generals);
            cInfo.prefect = armyInfo.commander;

            for (int i = 0; i < cInfo.prisons.Count; i++)
            {
                Informations.Instance.GetGeneralInfo(cInfo.prisons[i]).prisonerIdx = armyInfo.king;
            }

            for (int i = 0; i < armyInfo.prisons.Count; i++)
            {
                Informations.Instance.GetGeneralInfo(armyInfo.prisons[i]).city = cIdx;
            }

            cInfo.prisons.AddRange(armyInfo.prisons);
            cInfo.money += armyInfo.money;

            Informations.Instance.armys.Remove(armyInfo);
            Destroy(armyInfo.armyCtrl.gameObject);

            if (cInfo.king != -1)
            {
                KingInfo kInfo = Informations.Instance.GetKingInfo(cInfo.king);
                kInfo.cities.Remove(cIdx);
            }

            cInfo.king = armyInfo.king;
            cityFlagsCtrl.SetFlag(cIdx);
            Informations.Instance.GetKingInfo(armyInfo.king).cities.Add(cIdx);
        }
        else if (result == 2)
        {
            for (int i = 0; i < cInfo.generals.Count; i++)
            {
                Informations.Instance.GetGeneralInfo(cInfo.generals[i]).prisonerIdx = -1;
                CheckIsLevelUp(Informations.Instance.GetGeneralInfo(cInfo.generals[i]));
            }

            int count = armyInfo.generals.Count;
            for (int i = count - 1; i >= 0; i--)
            {
                int gIdx = armyInfo.generals[i];
                if (Informations.Instance.GetGeneralInfo(gIdx).prisonerIdx == cInfo.king)
                {
                    if (gIdx == Informations.Instance.GetKingInfo(armyInfo.king).generalIdx)
                    {
                        SetKingOver(armyInfo.king);
                    }

                    cInfo.prisons.Add(gIdx);
                    Informations.Instance.GetGeneralInfo(gIdx).city = cIdx;

                    Informations.Instance.GetKingInfo(armyInfo.king).generals.Remove(gIdx);
                    armyInfo.generals.RemoveAt(i);
                }
            }

            if (armyInfo.generals.Count == 0)
            {
                for (int i = 0; i < armyInfo.prisons.Count; i++)
                {
                    Informations.Instance.GetGeneralInfo(armyInfo.prisons[i]).prisonerIdx = cInfo.king;
                    Informations.Instance.GetGeneralInfo(armyInfo.prisons[i]).city        = cIdx;
                }

                cInfo.prisons.AddRange(armyInfo.prisons);
                armyInfo.prisons.Clear();

                cInfo.money += armyInfo.money;

                state = ArmyState.Escape;
                Destroy(armyInfo.armyCtrl.gameObject);
                Informations.Instance.armys.Remove(armyInfo);
            }
            else
            {
                FindArmyCommander();

                int tmp = armyInfo.cityTo;
                armyInfo.cityTo   = armyInfo.cityFrom;
                armyInfo.cityFrom = tmp;

                if (pathfinding == null)
                {
                    pathfinding = GameObject.FindWithTag("Pathfinding").GetComponent <MyPathfinding>();
                }

                SetRoute(pathfinding.GetRoute(transform.position, armyInfo.cityTo));

                armyInfo.armyCtrl.SetArmyEscape();
            }
        }
    }
Example #57
0
    void SetEscapeFromCity(int cIdx)
    {
        CityInfo cInfo = Informations.Instance.GetCityInfo(cIdx);

        do
        {
            GameObject     go = (GameObject)Instantiate(armyPrefab, pathfinding.GetCityPos(cIdx), transform.rotation);
            ArmyController ac = go.GetComponent <ArmyController>();
            ArmyInfo       ai = new ArmyInfo();
            ai.king     = cInfo.king;
            ai.money    = 0;
            ai.armyCtrl = ac;

            ac.armyInfo = ai;
            ac.SetArmyKingFlag();

            Informations.Instance.armys.Add(ai);
            ai.armyCtrl.SetArmyKingFlag();

            go.transform.parent = GameObject.Find("ArmiesRoot").transform;

            int count = cInfo.generals.Count;
            int min   = count - 5;
            min = Mathf.Clamp(min, 0, count);
            for (int i = count - 1; i >= min; i--)
            {
                int g = cInfo.generals[i];
                ai.generals.Add(g);
                cInfo.generals.RemoveAt(i);

                Informations.Instance.GetGeneralInfo(g).city = -1;
            }

            ai.commander = -1;
            ai.armyCtrl.FindArmyCommander();

            int        cityEscTo = -1;
            List <int> clist     = MyPathfinding.GetCityNearbyIdx(cIdx);
            List <int> canGoList = new List <int>();

            if (clist.Count == 1)
            {
                cityEscTo = clist[0];
            }
            else
            {
                for (int i = 0; i < clist.Count; i++)
                {
                    if (Informations.Instance.GetCityInfo(clist[i]).king == ai.king)
                    {
                        canGoList.Add(clist[i]);
                    }
                }

                if (canGoList.Count > 0)
                {
                    cityEscTo = canGoList[Random.Range(0, canGoList.Count)];
                }

                if (cityEscTo == -1)
                {
                    for (int i = 0; i < clist.Count; i++)
                    {
                        if (Informations.Instance.GetCityInfo(clist[i]).king == -1)
                        {
                            canGoList.Add(clist[i]);
                        }
                    }

                    if (canGoList.Count > 0)
                    {
                        cityEscTo = canGoList[Random.Range(0, canGoList.Count)];
                    }
                }

                if (cityEscTo == -1)
                {
                    cityEscTo = clist[Random.Range(0, clist.Count)];
                }
            }

            ai.cityFrom = cIdx;
            ai.cityTo   = cityEscTo;

            if (pathfinding == null)
            {
                pathfinding = GameObject.FindWithTag("Pathfinding").GetComponent <MyPathfinding>();
            }

            ai.armyCtrl.SetRoute(pathfinding.GetRoute(ai.armyCtrl.transform.position, ai.cityTo));
            ai.armyCtrl.SetArmyEscape();
        } while (cInfo.generals.Count > 0);
    }
Example #58
0
    public string GetDeliveryWayDistricts()
    {
        int Delivery_Way_ID = tools.CheckInt(Request.QueryString["Delivery_Way_ID"]);
        IList <DeliveryWayDistrictInfo> entitys = MyBLL.GetDeliveryWayDistrictsByDWID(Delivery_Way_ID, Public.GetUserPrivilege());

        if (entitys != null)
        {
            DeliveryWayInfo wayinfo = MyBLL.GetDeliveryWayByID(Delivery_Way_ID, Public.GetUserPrivilege());

            StateInfo  stateEntity  = null;
            CityInfo   cityEntity   = null;
            CountyInfo countyEntity = null;

            StringBuilder jsonBuilder = new StringBuilder();
            jsonBuilder.Append("{\"page\":1,\"total\":1,\"records\":" + entitys.Count + ",\"rows\"");
            jsonBuilder.Append(":[");
            foreach (DeliveryWayDistrictInfo entity in entitys)
            {
                stateEntity  = addrBLL.GetStateInfoByCode(entity.District_State);
                cityEntity   = addrBLL.GetCityInfoByCode(entity.District_City);
                countyEntity = addrBLL.GetCountyInfoByCode(entity.District_County);

                jsonBuilder.Append("{\"DeliveryWayDistrictInfo.District_ID\":" + entity.District_ID + ",\"cell\":[");
                //各字段
                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.District_ID);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                if (wayinfo == null)
                {
                    jsonBuilder.Append(Delivery_Way_ID);
                }
                else
                {
                    jsonBuilder.Append(wayinfo.Delivery_Way_Name);
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");

                if (entity.District_State == "0" || entity.District_State.Length == 0)
                {
                    jsonBuilder.Append("全部");
                }
                else
                {
                    if (stateEntity == null)
                    {
                        jsonBuilder.Append(entity.District_State);
                    }
                    else
                    {
                        jsonBuilder.Append(stateEntity.State_CN);
                    }
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                if (entity.District_City == "0" || entity.District_City.Length == 0)
                {
                    jsonBuilder.Append("全部");
                }
                else
                {
                    if (cityEntity == null)
                    {
                        jsonBuilder.Append(entity.District_City);
                    }
                    else
                    {
                        jsonBuilder.Append(cityEntity.City_CN);
                    }
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                if (entity.District_County == "0" || entity.District_County.Length == 0)
                {
                    jsonBuilder.Append("全部");
                }
                else
                {
                    if (countyEntity == null)
                    {
                        jsonBuilder.Append(entity.District_County);
                    }
                    else
                    {
                        jsonBuilder.Append(countyEntity.County_CN);
                    }
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append("<img src=\\\"/images/icon_edit.gif\\\" alt=\\\"修改\\\"> <a href=\\\"district_list.aspx?action=renew&delivery_way_id=" + Delivery_Way_ID + "&district_id=" + entity.District_ID + "\\\" title=\\\"修改\\\">修改</a> <img src=\\\"/images/icon_del.gif\\\"  alt=\\\"删除\\\"> <a href=\\\"javascript:void(0);\\\" onclick=\\\"confirmdelete('district_do.aspx?action=move&delivery_way_id=" + Delivery_Way_ID + "&district_id=" + entity.District_ID + "')\\\" title=\\\"删除\\\">删除</a>");
                jsonBuilder.Append("\",");

                jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                jsonBuilder.Append("]},");
            }
            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            jsonBuilder.Append("]");
            jsonBuilder.Append("}");
            return(jsonBuilder.ToString());
        }
        else
        {
            return(null);
        }
    }
Example #59
0
    private void InitDefaultCitiesInfo()
    {
        if (cities == null)
        {
            cities = new CityInfo[cityNum];
            for (int i = 0; i < cityNum; i++)
            {
                cities[i] = new CityInfo();
            }
        }

        cities[0X00].king = -1;
        cities[0X00].population = 77000;
        cities[0X00].money = 2827;
        cities[0X00].reservistMax = 140;
        cities[0X00].reservist = 0;
        cities[0X00].defense = 369;

        cities[0X01].king = 6;
        cities[0X01].population = 90000;
        cities[0X01].money = 2925;
        cities[0X01].reservistMax = 146;
        cities[0X01].reservist = 0;
        cities[0X01].defense = 252;

        cities[0X02].king = 4;
        cities[0X02].population = 172739;
        cities[0X02].money = 3472;
        cities[0X02].reservistMax = 179;
        cities[0X02].reservist = 0;
        cities[0X02].defense = 321;

        cities[0X03].king = -1;
        cities[0X03].population = 88000;
        cities[0X03].money = 2910;
        cities[0X03].reservistMax = 145;
        cities[0X03].reservist = 0;
        cities[0X03].defense = 300;

        cities[0X04].king = 4;
        cities[0X04].population = 355340;
        cities[0X04].money = 4822;
        cities[0X04].reservistMax = 252;
        cities[0X04].reservist = 0;
        cities[0X04].defense = 439;

        cities[0X05].king = 1;
        cities[0X05].population = 330000;
        cities[0X05].money = 4725;
        cities[0X05].reservistMax = 242;
        cities[0X05].reservist = 0;
        cities[0X05].defense = 365;

        cities[0X06].king = 7;
        cities[0X06].population = 214229;
        cities[0X06].money = 3795;
        cities[0X06].reservistMax = 195;
        cities[0X06].reservist = 0;
        cities[0X06].defense = 312;

        cities[0X07].king = 8;
        cities[0X07].population = 129646;
        cities[0X07].money = 3135;
        cities[0X07].reservistMax = 161;
        cities[0X07].reservist = 0;
        cities[0X07].defense = 320;

        cities[0X08].king = 9;
        cities[0X08].population = 167000;
        cities[0X08].money = 3502;
        cities[0X08].reservistMax = 176;
        cities[0X08].reservist = 0;
        cities[0X08].defense = 227;

        cities[0X09].king = 0;
        cities[0X09].population = 221000;
        cities[0X09].money = 3907;
        cities[0X09].reservistMax = 198;
        cities[0X09].reservist = 0;
        cities[0X09].defense = 206;

        cities[0X0A].king = 3;
        cities[0X0A].population = 425000;
        cities[0X0A].money = 5437;
        cities[0X0A].reservistMax = 280;
        cities[0X0A].reservist = 0;
        cities[0X0A].defense = 500;

        cities[0X0B].king = 3;
        cities[0X0B].population = 142000;
        cities[0X0B].money = 3315;
        cities[0X0B].reservistMax = 166;
        cities[0X0B].reservist = 0;
        cities[0X0B].defense = 232;

        cities[0X0C].king = 3;
        cities[0X0C].population = 308093;
        cities[0X0C].money = 4492;
        cities[0X0C].reservistMax = 233;
        cities[0X0C].reservist = 0;
        cities[0X0C].defense = 513;

        cities[0X0D].king = -1;
        cities[0X0D].population = 89000;
        cities[0X0D].money = 2917;
        cities[0X0D].reservistMax = 145;
        cities[0X0D].reservist = 0;
        cities[0X0D].defense = 245;

        cities[0X0E].king = -1;
        cities[0X0E].population = 121000;
        cities[0X0E].money = 3157;
        cities[0X0E].reservistMax = 158;
        cities[0X0E].reservist = 0;
        cities[0X0E].defense = 373;

        cities[0X0F].king = 10;
        cities[0X0F].population = 160000;
        cities[0X0F].money = 3450;
        cities[0X0F].reservistMax = 174;
        cities[0X0F].reservist = 0;
        cities[0X0F].defense = 515;

        cities[0X10].king = 11;
        cities[0X10].population = 167000;
        cities[0X10].money = 3502;
        cities[0X10].reservistMax = 176;
        cities[0X10].reservist = 0;
        cities[0X10].defense = 140;

        cities[0X11].king = 11;
        cities[0X11].population = 188000;
        cities[0X11].money = 3660;
        cities[0X11].reservistMax = 185;
        cities[0X11].reservist = 0;
        cities[0X11].defense = 106;

        cities[0X12].king = -1;
        cities[0X12].population = 321000;
        cities[0X12].money = 4657;
        cities[0X12].reservistMax = 238;
        cities[0X12].reservist = 0;
        cities[0X12].defense = 429;

        cities[0X13].king = 12;
        cities[0X13].population = 233000;
        cities[0X13].money = 3997;
        cities[0X13].reservistMax = 206;
        cities[0X13].reservist = 0;
        cities[0X13].defense = 305;

        cities[0X14].king = -1;
        cities[0X14].population = 251000;
        cities[0X14].money = 4132;
        cities[0X14].reservistMax = 210;
        cities[0X14].reservist = 0;
        cities[0X14].defense = 137;

        cities[0X15].king = 5;
        cities[0X15].population = 325000;
        cities[0X15].money = 4687;
        cities[0X15].reservistMax = 240;
        cities[0X15].reservist = 0;
        cities[0X15].defense = 317;

        cities[0X16].king = -1;
        cities[0X16].population = 213000;
        cities[0X16].money = 3847;
        cities[0X16].reservistMax = 195;
        cities[0X16].reservist = 0;
        cities[0X16].defense = 207;

        cities[0X17].king = 13;
        cities[0X17].population = 370566;
        cities[0X17].money = 4950;
        cities[0X17].reservistMax = 258;
        cities[0X17].reservist = 0;
        cities[0X17].defense = 345;

        cities[0X18].king = -1;
        cities[0X18].population = 254000;
        cities[0X18].money = 4155;
        cities[0X18].reservistMax = 211;
        cities[0X18].reservist = 0;
        cities[0X18].defense = 214;

        cities[0X19].king = 13;
        cities[0X19].population = 132000;
        cities[0X19].money = 3240;
        cities[0X19].reservistMax = 162;
        cities[0X19].reservist = 0;
        cities[0X19].defense = 236;

        cities[0X1A].king = 13;
        cities[0X1A].population = 233000;
        cities[0X1A].money = 3997;
        cities[0X1A].reservistMax = 203;
        cities[0X1A].reservist = 0;
        cities[0X1A].defense = 294;

        cities[0X1B].king = -1;
        cities[0X1B].population = 109000;
        cities[0X1B].money = 3067;
        cities[0X1B].reservistMax = 153;
        cities[0X1B].reservist = 0;
        cities[0X1B].defense = 175;

        cities[0X1C].king = 2;
        cities[0X1C].population = 224000;
        cities[0X1C].money = 3930;
        cities[0X1C].reservistMax = 199;
        cities[0X1C].reservist = 0;
        cities[0X1C].defense = 473;

        cities[0X1D].king = -1;
        cities[0X1D].population = 174000;
        cities[0X1D].money = 3555;
        cities[0X1D].reservistMax = 179;
        cities[0X1D].reservist = 0;
        cities[0X1D].defense = 121;

        cities[0X1E].king = -1;
        cities[0X1E].population = 225000;
        cities[0X1E].money = 3937;
        cities[0X1E].reservistMax = 200;
        cities[0X1E].reservist = 0;
        cities[0X1E].defense = 132;

        cities[0X1F].king = 14;
        cities[0X1F].population = 154000;
        cities[0X1F].money = 3405;
        cities[0X1F].reservistMax = 171;
        cities[0X1F].reservist = 0;
        cities[0X1F].defense = 182;

        cities[0X20].king = 14;
        cities[0X20].population = 290000;
        cities[0X20].money = 4425;
        cities[0X20].reservistMax = 226;
        cities[0X20].reservist = 0;
        cities[0X20].defense = 420;

        cities[0X21].king = 15;
        cities[0X21].population = 232000;
        cities[0X21].money = 3990;
        cities[0X21].reservistMax = 202;
        cities[0X21].reservist = 0;
        cities[0X21].defense = 336;

        cities[0X22].king = 16;
        cities[0X22].population = 139000;
        cities[0X22].money = 3292;
        cities[0X22].reservistMax = 165;
        cities[0X22].reservist = 0;
        cities[0X22].defense = 160;

        cities[0X23].king = -1;
        cities[0X23].population = 170000;
        cities[0X23].money = 3525;
        cities[0X23].reservistMax = 178;
        cities[0X23].reservist = 0;
        cities[0X23].defense = 203;

        cities[0X24].king = -1;
        cities[0X24].population = 213000;
        cities[0X24].money = 3847;
        cities[0X24].reservistMax = 195;
        cities[0X24].reservist = 0;
        cities[0X24].defense = 233;

        cities[0X25].king = -1;
        cities[0X25].population = 181000;
        cities[0X25].money = 3607;
        cities[0X25].reservistMax = 182;
        cities[0X25].reservist = 0;
        cities[0X25].defense = 502;

        cities[0X26].king = -1;
        cities[0X26].population = 115000;
        cities[0X26].money = 3112;
        cities[0X26].reservistMax = 156;
        cities[0X26].reservist = 0;
        cities[0X26].defense = 211;

        cities[0X27].king = 17;
        cities[0X27].population = 235000;
        cities[0X27].money = 4012;
        cities[0X27].reservistMax = 204;
        cities[0X27].reservist = 0;
        cities[0X27].defense = 306;

        cities[0X28].king = 17;
        cities[0X28].population = 308000;
        cities[0X28].money = 4560;
        cities[0X28].reservistMax = 233;
        cities[0X28].reservist = 0;
        cities[0X28].defense = 284;

        cities[0X29].king = -1;
        cities[0X29].population = 236000;
        cities[0X29].money = 4020;
        cities[0X29].reservistMax = 204;
        cities[0X29].reservist = 0;
        cities[0X29].defense = 268;

        cities[0X2A].king = 17;
        cities[0X2A].population = 211000;
        cities[0X2A].money = 3832;
        cities[0X2A].reservistMax = 194;
        cities[0X2A].reservist = 0;
        cities[0X2A].defense = 162;

        cities[0X2B].king = -1;
        cities[0X2B].population = 176000;
        cities[0X2B].money = 3570;
        cities[0X2B].reservistMax = 180;
        cities[0X2B].reservist = 0;
        cities[0X2B].defense = 193;

        cities[0X2C].king = -1;
        cities[0X2C].population = 303000;
        cities[0X2C].money = 4522;
        cities[0X2C].reservistMax = 231;
        cities[0X2C].reservist = 0;
        cities[0X2C].defense = 375;

        cities[0X2D].king = -1;
        cities[0X2D].population = 149000;
        cities[0X2D].money = 3367;
        cities[0X2D].reservistMax = 169;
        cities[0X2D].reservist = 0;
        cities[0X2D].defense = 112;

        cities[0X2E].king = -1;
        cities[0X2E].population = 166000;
        cities[0X2E].money = 3495;
        cities[0X2E].reservistMax = 176;
        cities[0X2E].reservist = 0;
        cities[0X2E].defense = 244;

        cities[0X2F].king = -1;
        cities[0X2F].population = 62000;
        cities[0X2F].money = 2715;
        cities[0X2F].reservistMax = 134;
        cities[0X2F].reservist = 0;
        cities[0X2F].defense = 108;
    }
Example #60
0
 public void SetCity(CityInfo city)
 {
     _startingCity = city;
 }