示例#1
0
        public static void LoadAwards(String userName)
        {
            currentPlayerAwards = MakeNewData();

            AwardsData data;
            // Get the path of the saved game
            string fullpath;
            #if WINDOWS
            fullpath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                "My Games"),
                "SHMUP"),
                "SaveGames"),
                userName + ".awd");
            #elif XBOX
            fullpath = Path.Combine(HighScoreManager.container.Path,  userName + ".awd");
            #endif
            if (!File.Exists(fullpath))
            {
                data = MakeNewData();
                MessageManager.newMessage(Strings.NewAwards);
            }
            else
            {
                // Get the path of the saved game
                // Open the file
                FileStream stream = File.Open(fullpath, FileMode.Open, FileAccess.Read);
                // Read the data from the file
                XmlSerializer serializer = new XmlSerializer(typeof(AwardsData));
                data = (AwardsData)serializer.Deserialize(stream);
                // Close the file
                stream.Close();
            }

            GamePadState gps = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
            KeyboardState kbs = Keyboard.GetState();

            if (gps.IsButtonDown(Buttons.LeftShoulder) &&
                gps.IsButtonDown(Buttons.RightShoulder) &&
                gps.Triggers.Left > 0.5f &&
                gps.Triggers.Right > 0.5f)
            {
                data = MakeNewData();
            }
            else if (kbs.IsKeyDown(Keys.F1) &&
                    kbs.IsKeyDown(Keys.F2))
            {
                data = MakeNewData();
            }
            currentPlayerAwards = data;

            lastScore = data.stats[(int)stats.totalScore];

            SaveAwards(userName);
        }
示例#2
0
        public static AwardsData MakeNewData()
        {
            AwardsData data = new AwardsData();

            data.awards = new List<bool>();
            int numFalseAwards = 0;
            for (int i = 0; i < (int)awards.ZZZLASTAWARDTHATISONLYUSEDFORLISTGENERAIONANDITERATION; i++)
            {
                data.awards.Add(false);
                numFalseAwards++;
            }
            data.stats = new List<int>();
            for (int i = 0; i < (int)stats.ZZZLASTSTATTHATISONLYUSEDFORLISTGENERAIONANDITERATION; i++)
            {
                data.stats.Add(0);
            }
            data.highestMultiplier = 0;

            return data;
        }
示例#3
0
        private void cmdCleanUp_Click(object sender, EventArgs e)
        {
            try
            {
                string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;

                string dupQuery = "SELECT Count([Pricing Rate ID]) As Duplicates, [Customer BT], [Origin City], [Origin State], [Origin Zip], " +
                                  " [Origin Zip Range], [Dest City], [Dest State], [Dest Zip], [Dest Zip Range]  From award_publication_temp " +
                                  " WHERE (GETDATE() BETWEEN ISNULL([Effective Date], GETDATE()) AND ISNULL([Expiration Date], GETDATE())) " +
                                  " GROUP BY [Customer BT], [Origin City], [Origin State], [Origin Zip], " +
                                  " [Origin Zip Range], [Dest City], [Dest State], [Dest Zip], [Dest Zip Range] " +
                                  " ORDER BY Duplicates DESC";

                SqlConnection  conn = new SqlConnection(connStr);
                SqlCommand     cmd  = new SqlCommand(dupQuery, conn);
                SqlDataAdapter da   = new SqlDataAdapter(cmd);

                DataTable dt = new DataTable();

                conn.Open();

                da.Fill(dt);

                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        int dups = int.Parse(row[0].ToString());

                        if (dups > 1)
                        {
                            AwardsData ad = new AwardsData();

                            ad.Customer       = row["Customer BT"].ToString();
                            ad.OriginCity     = row["Origin City"].ToString();
                            ad.OriginState    = row["Origin State"].ToString();
                            ad.OriginZip      = row["Origin Zip"].ToString();
                            ad.OriginZipRange = row["Origin Zip Range"].ToString();
                            ad.DestCity       = row["Dest City"].ToString();
                            ad.DestState      = row["Dest State"].ToString();
                            ad.DestZip        = row["Dest Zip"].ToString();
                            ad.DestZipRange   = row["Dest Zip Range"].ToString();

                            string query = "SELECT [Pricing Rate ID] FROM award_publication_temp WHERE [Customer BT] = @customer " +
                                           " AND [Origin City] = @originCity AND [Origin State] = @originState AND [Origin Zip] = @originZip " +
                                           " AND [Origin Zip Range] = @originZipRange AND [Dest City] = @destCity AND [Dest State] = @destState " +
                                           " AND [Dest Zip] = @destZip AND [Dest Zip Range] = @destZipRange " +
                                           " ORDER BY [Pricing Rate ID] DESC ";


                            using (SqlCommand command = new SqlCommand(query, conn))
                            {
                                using (SqlDataAdapter sda = new SqlDataAdapter(command))
                                {
                                    command.Parameters.AddWithValue("@customer", ad.Customer);
                                    command.Parameters.AddWithValue("@originCity", ad.OriginCity);
                                    command.Parameters.AddWithValue("@originState", ad.OriginState);
                                    command.Parameters.AddWithValue("@originZip", ad.OriginZip);
                                    command.Parameters.AddWithValue("@originZipRange", ad.OriginZipRange);
                                    command.Parameters.AddWithValue("@destCity", ad.DestCity);
                                    command.Parameters.AddWithValue("@destState", ad.DestState);
                                    command.Parameters.AddWithValue("@destZip", ad.DestZip);
                                    command.Parameters.AddWithValue("@destZipRange", ad.DestZipRange);

                                    DataTable dtDups = new DataTable();

                                    sda.Fill(dtDups);

                                    int nCount = 0;

                                    if (dtDups != null && dtDups.Rows.Count > 0)
                                    {
                                        foreach (DataRow dupRow in dtDups.Rows)
                                        {
                                            if (nCount > 0)
                                            {
                                                string pricingRateId = dupRow["Pricing Rate ID"].ToString();
                                                string deleteQry     = "DELETE award_publication_temp WHERE [Pricing Rate ID] = '" + pricingRateId + "'";

                                                SqlCommand deleteCmd = new SqlCommand(deleteQry, conn);

                                                deleteCmd.ExecuteNonQuery();
                                            }

                                            nCount += 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }