/* Determine which medal was earned from score achieved in current game session */ private void MedalEarned() { medal = Medal.NONE; if (CurrentScore >= medalBreakpoints[0]) { medal = Medal.BRONZE; PlayerPrefs.SetInt("BronzeMedal", 1); } if (CurrentScore >= medalBreakpoints[1]) { medal = Medal.SILVER; PlayerPrefs.SetInt("SilverMedal", 1); } if (CurrentScore >= medalBreakpoints[2]) { medal = Medal.GOLD; PlayerPrefs.SetInt("GoldMedal", 1); } if (CurrentScore >= medalBreakpoints[3]) { medal = Medal.PLATINUM; PlayerPrefs.SetInt("PlatinumMedal", 1); } if (CurrentScore >= medalBreakpoints[4]) { medal = Medal.DIAMOND; PlayerPrefs.SetInt("DiamondMedal", 1); } }
public MedalManager() { try { using (MySqlConnection mySqlConnection = SQLjec.getInstance().conn()) { MySqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlConnection.Open(); mySqlCommand.CommandText = "SELECT * FROM player_medal"; mySqlCommand.CommandType = CommandType.Text; MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader(); while (mySqlDataReader.Read()) { Medal item = new Medal { player_id = mySqlDataReader.GetInt32("Player_Id"), brooch = mySqlDataReader.GetInt32("Brooch"), insignia = mySqlDataReader.GetInt32("Insignia"), medal = mySqlDataReader.GetInt32("Medal"), blue_order = mySqlDataReader.GetInt32("Blue_order") }; this._accounts.Add(item); this.id++; } CLogger.getInstance().extra_info("[Medal] Loaded: " + this._accounts.Count + " info(s)."); } } catch (Exception ex) { this.dbstatus = -100; CLogger.getInstance().error("[Medal] database not found"); CLogger.getInstance().error("[Medal] " + ex.ToString()); } }
public IEnumerable <Medal> GetAllMedals() { using (SqlConnection connection = new SqlConnection(_connectionString)) { using (SqlCommand command = new SqlCommand("dbo.getAllMedals", connection)) { command.CommandType = CommandType.StoredProcedure; List <Medal> medals = new List <Medal>(); command.Connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { Medal medal = new Medal { Id = int.Parse(reader[0].ToString()), Material = new Material { Id = int.Parse(reader[1].ToString()), Name = reader[2].ToString() } }; medals.Add(medal); } } return(medals); } } }
public IEnumerator RequestGetMedal(int id) { string res; string request = url + "/medals/" + id; UnityWebRequest www = UnityWebRequest.Get(request); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else if ((res = www.downloadHandler.text) != "") { JSONNode result = JSON.Parse(res); medal = new Medal(); idMedal = int.Parse(result[0]); string nameMedal = result [1]; string descriptionMedal = result [2]; int obtentionMedal = int.Parse(result [3]); int rewardMedal = int.Parse(result [4]); medal.AddValues(idMedal, nameMedal, descriptionMedal, obtentionMedal, rewardMedal); Debug.Log("Get"); } else { Debug.Log("Can't get"); } }
public Color MedalColor(Medal currMedal) { Color medalColor = new Color(); switch (currMedal) { case Medal.None: medalColor = Color.white; break; case Medal.Bronze: medalColor = StaticMethodsAndProperties.hexToColor("#CD7F32"); break; case Medal.Silver: medalColor = StaticMethodsAndProperties.hexToColor("#C0C0C0"); break; case Medal.Gold: medalColor = StaticMethodsAndProperties.hexToColor("#ffd700"); break; case Medal.Platinium: default: medalColor = StaticMethodsAndProperties.hexToColor("#e5e4e2"); break; } return(medalColor); }
public IHttpActionResult PutMedal(int id, Medal medal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != medal.Medal_ID) { return(BadRequest()); } db.Entry(medal).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MedalExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public AutoApprovalArguments( int customerID, long?cashRequestID, long?nlCashRequestID, decimal systemCalculatedAmount, Medal medal, MedalType medalType, TurnoverType?turnoverType, AutoDecisionFlowTypes flowType, bool errorInLGData, string tag, DateTime now, AConnection db, ASafeLog log ) { CustomerID = customerID; CashRequestID = cashRequestID; NLCashRequestID = nlCashRequestID; SystemCalculatedAmount = systemCalculatedAmount; Medal = medal; MedalType = medalType; TurnoverType = turnoverType; FlowType = flowType; ErrorInLGData = errorInLGData; Tag = tag; Now = now; DB = db; Log = log.Safe(); TrailUniqueID = Guid.NewGuid(); } // constructor
public void BindData() { this.DataGrid1.AllowCustomPaging = false; this.DataGrid1.TableHeaderName = "论坛勋章列表"; //this.DataGrid1.BindData(Medals.GetMedal()); this.DataGrid1.BindData(Medal.FindAllWithCache().ToDataTable(false)); }
public void Update(Medal medal) { QueryFactory.Query(TableName).Where("uid", medal.Uid).Update(new { is_equipped = medal.IsEquipped }); }
public override void OnInspectorGUI() { Parkour parkour = (Parkour)target; base.OnInspectorGUI(); for (int j = 0; j < 4; j++) { if (j < parkour.medals.Length) { if (parkour.medals[j].type != (Medal.MedalType)j) { EditorGUILayout.HelpBox("Medal at index " + j + " should be of type " + Medal.MedalTypeToString((Medal.MedalType)j), MessageType.Error); } } else { EditorGUILayout.HelpBox(Medal.MedalTypeToString((Medal.MedalType)j) + " Medal is missing", MessageType.Error); } } int min = parkour.startingScore; int i = 0; while (i < parkour.medals.Length) { if (parkour.medals[i].score > min) { EditorGUILayout.HelpBox(Medal.MedalTypeToString(parkour.medals[i].type) + " Medal score should not be higher than previous medal", MessageType.Error); break; } min = parkour.medals[i].score; i++; } }
public static void LoadExtraPostInfo(Post postInfo, int adCount) { var ug = postInfo.PostUser.Group; Random random = new Random((int)DateTime.Now.Ticks); if (postInfo.Medals != string.Empty) { postInfo.Medals = Medal.GetMedalsList(postInfo.Medals); } if (ug != null) { postInfo.Stars = ug.Stars; if (String.IsNullOrEmpty(ug.Color)) { postInfo.Status = ug.GroupTitle; } else { postInfo.Status = string.Format("<span style=\"color:{0}\">{1}</span>", ug.Color, ug.GroupTitle); } } string[] array = Utils.SplitString(GeneralConfigInfo.Current.Postnocustom, "\n"); if (array.Length >= postInfo.Id) { postInfo.Postnocustom = array[postInfo.Id - 1]; } postInfo.Adindex = random.Next(0, adCount); }
public void BubbleShow(Medal medal) { bubble.transform.position = medal.transform.position; bubbleGetText.text = medal.achievement.getText; if (medal.achievement.current() > 0) { if (medal.achievement is Achievements.League) { bubbleGetText.text += " (" + Localization.Get("league" + user.league.name) + ")"; } else { bubbleGetText.text += " (" + medal.achievement.current().SpaceFormat() + ")"; } } bubbleBonusText.text = medal.achievement.bonusText; if (leftSide.IndexOf(medals.IndexOf(medal) + 1) < 0) { bubble.transform.rotation = Quaternion.Euler(Vector3.zero); bubbleTexts.transform.localRotation = Quaternion.Euler(Vector3.zero); } else { bubble.transform.rotation = Quaternion.Euler(0, 180, 0); bubbleTexts.transform.localRotation = Quaternion.Euler(0, 180, 0); } bubble.SetActive(true); }
public async Task <IActionResult> PutMedal([FromRoute] long id, [FromForm] Medal medal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != medal.Id) { return(BadRequest()); } _context.Entry(medal).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void ImportMedal_Click(object sender, EventArgs e) { AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "导入勋章", ""); //Medals.InsertMedalList(this.GetMedalFileList()); Medal.Import(GetMedalFileList()); base.RegisterStartupScript("PAGE", "window.location.href='global_medalgrid.aspx';"); }
public IEnumerable <Medal> GetAll() { string ProcName = "ReadMedal"; List <Medal> medals = new List <Medal>(); try { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(ProcName, connection); command.CommandType = System.Data.CommandType.StoredProcedure; var reader = command.ExecuteReader(); if (reader.HasRows) { DataTable table = new DataTable(); table.Load(reader); foreach (DataRow row in table.Rows) { Medal p = new Medal(); p.id = (int)row["id"]; p.Name = row["Name"].ToString(); p.Material = row["Material"].ToString(); medals.Add(p); } } } } catch (Exception ex) { } return(medals); }
private void UpdateChecks() { PIDEC.Verify(this); Nickname.Verify(this); Language.Verify(this); Trainer.Verify(this); IndividualValues.Verify(this); EffortValues.Verify(this); Level.Verify(this); Ribbon.Verify(this); Ability.Verify(this); Ball.Verify(this); Form.Verify(this); Misc.Verify(this); Gender.Verify(this); Item.Verify(this); if (pkm.Format <= 6 && pkm.Format >= 4) { EncounterType.Verify(this); // Gen 6->7 transfer deletes encounter type data } if (pkm.Format < 6) { return; } Memory.Verify(this); Medal.Verify(this); ConsoleRegion.Verify(this); if (pkm.Format >= 7) { HyperTraining.Verify(this); Misc.VerifyVersionEvolution(this); } }
//GetMedal: devuelve el indice del sprite de la medalla a mostrar dependiendo de la puntuacion del jugador, // evaluando dicha puntuacion en intervalos, utiliza el enum Medal para mayor entendimiento. // REFACTORIZAR EVALUACION POR INTERVALOS. private int GetMedal(int score) { Medal medalByScore = Medal.Zero; if (10 <= score && score < 20) // 10 20 { medalByScore = Medal.One; } else if (20 <= score && score < 30) // 20 30 { medalByScore = Medal.Two; } else if (30 <= score && score < 40) // 30 40 { medalByScore = Medal.Three; } else if (40 <= score && score < 50) // 40 50 { medalByScore = Medal.Four; } else if (50 <= score) // 50 > { medalByScore = Medal.Five; } return((int)medalByScore); }
protected override void Seed(SellTables.Models.ApplicationDbContext context) { var userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(context)); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); var adminRole = new IdentityRole { Name = "admin" }; var userRole = new IdentityRole { Name = "user" }; roleManager.Create(adminRole); roleManager.Create(userRole); var admin = new ApplicationUser { Email = "*****@*****.**", UserName = "******" }; if (context.Medals.FirstOrDefault(m => m.Id == 6) != null) { Medal medal = context.Medals.FirstOrDefault(m => m.Id == 6); admin.Medals.Add(medal); } string password = "******"; var result = userManager.Create(admin, password); if (result.Succeeded) { userManager.AddToRole(admin.Id, userRole.Name); userManager.AddToRole(admin.Id, adminRole.Name); } base.Seed(context); }
protected UserMedal GetUserMedal(User user) { UserMedal userMedal = null; foreach (UserMedal medal in user.UserMedals) { if (medal.MedalID == Medal.ID) { userMedal = medal; } } if (userMedal == null) { MedalLevel level = Medal.GetMedalLevel(user, true); if (level != null) { userMedal = new UserMedal(); userMedal.MedalID = Medal.ID; userMedal.MedalLeveID = level.ID; userMedal.Url = level.IconSrc; userMedal.UserID = user.UserID; } } return(userMedal); }
private void ShowMedal() { if (currentScore < silverScoreMin) { currentMedal = Medal.BRONZE; // show bronze medal } else if (currentScore == numCollectables) { currentMedal = Medal.GOLD; // show gold medal } else { currentMedal = Medal.SILVER; // show silver medal } // check if player got new highest medal if (currentMedal > highestMedal) { highestMedal = currentMedal; } // set UI images currentMedalImage.sprite = medalSprites[(int)currentMedal]; bestMedalImage.sprite = medalSprites[(int)highestMedal]; }
/// <summary> /// On mouse move, we show the tooltip. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lbMedals_MouseMove(object sender, MouseEventArgs e) { for (int i = 0; i < lbMedals.Items.Count; i++) { // Skip until we found the mouse location Rectangle rect = lbMedals.GetItemRectangle(i); if (!rect.Contains(e.Location)) { continue; } Medal item = lbMedals.Items[i] as Medal; // Updates the tooltip if (item == null) { continue; } DisplayTooltip(item); return; } // If we went so far, we're not over anything m_lastTooltipItem = null; ttToolTip.Active = false; }
private static void HandleEquipMedal(GameSession session, PacketReader packet) { MedalSlot slot = (MedalSlot)packet.ReadByte(); int effectId = packet.ReadInt(); if (effectId == 0) { session.Player.Account.UnequipMedal(slot); return; } Medal newMedal = session.Player.Account.Medals.FirstOrDefault(x => x.EffectId == effectId); if (newMedal is null) { return; } // unequip medal if present session.Player.Account.UnequipMedal(slot); // equip new medal session.Player.Account.EquippedMedals[slot] = newMedal; newMedal.IsEquipped = true; DatabaseManager.MushkingRoyaleMedals.Update(newMedal); session.Send(MushkingRoyaleSystemPacket.LoadMedals(session.Player.Account)); }
public static void UpdateMedals(int uid, string medals, int adminUid, string adminUserName, string ip, string reason) { if (uid <= 0) { return; } //BBX.Data.Users.UpdateMedals(uid, medals); var user = User.FindByID(uid); var uf = user as IUser; uf.Medals = medals; user.Save(); //string username = Users.GetUserInfo(uid).Name; string[] array = medals.Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i]; if (text != "") { Medal.Award(uid, text.ToInt(), adminUid, ip, reason); //if (!BBX.Data.Medals.IsExistMedalAwardRecord(int.Parse(text), uid)) //{ // BBX.Data.Medals.CreateMedalslog(adminUid, adminUserName, ip, username, uid, "授予", int.Parse(text), reason); //} //else //{ // BBX.Data.Medals.UpdateMedalslog("授予", DateTime.Now, reason, "收回", int.Parse(text), uid); //} } } }
public int Add(Medal medal) { using (var connection = new SqlConnection(_connectionString)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "CreateMedal"; //Имя хранимой процедуры var title = new SqlParameter("@Title", SqlDbType.NVarChar) { Value = medal.Title }; command.Parameters.Add(title); var material = new SqlParameter("@Material", SqlDbType.NVarChar) { Value = medal.Material }; command.Parameters.Add(material); connection.Open(); //command.ExecuteNonQuery(); return((int)(decimal)command.ExecuteScalar()); } }
public bool Update(int id, string title, string material) { if (_medalDao.ShowById(id) != null) { if (!String.IsNullOrEmpty(title)) { if (!String.IsNullOrEmpty(material)) { var medal = new Medal { Id = id, Title = title, Material = material }; _medalDao.Update(medal); return(true); } else { throw new ArgumentNullException("You can't add medal to null material"); } } else { throw new ArgumentNullException("You can't update medal to null title"); } } else { throw new Exception($"Medal with id = {id} not available"); } }
public void Update(Medal medal) { using (var connection = new SqlConnection(_connectionString)) { SqlCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "UpdateMedal"; //Имя хранимой процедуры var identificator = new SqlParameter("@id", SqlDbType.Int) { Value = medal.Id }; command.Parameters.Add(identificator); var title = new SqlParameter("@Title", SqlDbType.NVarChar) { Value = medal.Title }; command.Parameters.Add(title); var material = new SqlParameter("@Material", SqlDbType.NVarChar) { Value = medal.Material }; command.Parameters.Add(material); connection.Open(); command.ExecuteNonQuery(); } }
// получение всех элементов списка public IEnumerable <Medal> GetAll() { // текст запроса-обращение к представлению string query = "select * from MedalView"; SqlConnection connection = new SqlConnection(); connection.ConnectionString = connectionString; connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = query; SqlDataReader reader = command.ExecuteReader(); DataTable table = new DataTable(); table.Load(reader); List <Medal> medals = new List <Medal>(); foreach (DataRow row in table.Rows) { Medal p = new Medal(); p.Id = int.Parse(row["MedalId"].ToString()); p.Name = row["MedalName"].ToString(); p.Material = row["MaterialName"].ToString(); medals.Add(p); } return(medals); }
public Medal Add(Medal medal) { string ProcName = "AddMedal"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(ProcName, connection); command.CommandType = System.Data.CommandType.StoredProcedure; // параметр для ввода имени SqlParameter medalMameParam = new SqlParameter { ParameterName = "@Name", Value = medal.Name }; // добавляем параметр command.Parameters.Add(medalMameParam); SqlParameter materialNameParam = new SqlParameter { ParameterName = "@Material", Value = medal.Material }; command.Parameters.Add(materialNameParam); var medalId = command.ExecuteScalar(); medal.id = Convert.ToInt32(medalId); return(medal); } }
private void SaveMedal_Click(object send, EventArgs e) { int num = 0; bool flag = false; foreach (object current in this.DataGrid1.GetKeyIDArray()) { int medalid = int.Parse(current.ToString()); string name = this.DataGrid1.GetControlValue(num, "name").Trim(); string image = this.DataGrid1.GetControlValue(num, "image").Trim(); if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(image)) { flag = true; } else { //Medals.UpdateMedal(medalid, name, image); var entity = Medal.FindByID(medalid); entity.Name = name; entity.Image = image; entity.Update(); num++; } } AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "批量更新勋章信息", ""); //XCache.Remove(CacheKeys.FORUM_UI_MEDALS_LIST); if (flag) { base.RegisterStartupScript("PAGE", "alert('某些信息不完整,未能更新!');window.location.href='global_medalgrid.aspx';"); return; } base.RegisterStartupScript("PAGE", "window.location.href='global_medalgrid.aspx';"); }
/// <summary> /// Get all medals on the game /// </summary> public IEnumerable <Medal> GetMedals(Platform platform) { Log.DebugFormat("Fetching medals on platform {0}...", platform); string server; switch (platform) { case Platform.XBOX: server = "api-xbox-console.worldoftanks.com"; break; case Platform.PS: server = "api-ps4-console.worldoftanks.com"; break; default: throw new ArgumentOutOfRangeException(nameof(platform), platform, null); } var url = $"https://{server}/wotx/encyclopedia/achievements/?application_id={ApplicationId}"; var json = GetContentSync($"Achievements.{platform}.json", url, WebCacheAge, false, Encoding.UTF8).Content; var o = JObject.Parse(json); var status = (string)o["status"]; if (status != "ok") { var error = o["error"]; Log.Error($"Error: {(string)error["code"]} - {(string)error["message"]}"); throw new ApplicationException($"Error calling WG API: {(string)error["code"]} - {(string)error["message"]}"); } var medals = new List <Medal>(); var data = o["data"]; foreach (var t in data.Cast <JProperty>()) { var ti = t.Value; var medal = new Medal { Platform = platform, Code = t.Name, Category = CategoryExtensions.Parse((string)ti["category"]), Name = (string)ti["name"], Section = SectionExtensions.Parse((string)ti["section"]), Type = TypeExtensions.Parse((string)ti["type"]), Description = (string)ti["description"], HeroInformation = (string)ti["hero_info"], Condition = (string)ti["condition"] }; medals.Add(medal); } return(medals); }
public MissionPassedScreen(string title, int completionRate, Medal medal) { Title = title; _completionRate = completionRate; _medal = medal; Visible = false; }
public void GetMedal(string fStr) { medals = new List<Medal>(); string[] lMedal = fStr.Split('|'); Service1 ser = new Service1(); foreach(string str in lMedal) { string rs = ser.GetMedal(int.Parse(str)); Medal tMedal = new Medal(); tMedal.SetData(rs); medals.Add(tMedal); } }
public void WinLevel(Medal winLevel) { switch(winLevel) { case Medal.Gold: totalScore = FishSpawnInfinite.instance.GoldGoal(); break; case Medal.Silver: totalScore = FishSpawnInfinite.instance.SilverGoal(); break; case Medal.Bronze: totalScore = FishSpawnInfinite.instance.BronzeGoal(); break; } FishSpawnInfinite.instance.RemoveAll(); FishSpawnInfinite.instance.NextLevel(); }
public bool AlreadyContainsMedal(Medal.Categ type) { foreach (Medal medal in Medals) if (medal.categ.Equals(type)) return true; return false; }
public override void Initialize() { base.Initialize(); _time = 0; _started = true; _paused = false; _elapsedTime = ""; CurrentMedal = Medal.Gold; LayerDepth = 0.3f; Collidable = false; }
void FinishGame(Medal medal) { SetMedal(medal); SetGameState(GameState.Over); }
public void setBestMedal() { if (_bestMedal == Medal.None) { _bestMedal = CurrentMedal; } if (_bestMedal != Medal.None) { if (CurrentMedal == Medal.Gold && _bestMedal != Medal.Gold) { _bestMedal = CurrentMedal; } if (CurrentMedal == Medal.Silver && _bestMedal == Medal.Bronze) { _bestMedal = CurrentMedal; } } }
public MedalSettings() { Medals = new MedalCollection(); MaxMedalID = 3; Medal medal = new Medal(); medal.ID = 1; medal.IsCustom = false; medal.IsHidden = false; medal.Enable = true; medal.Condition = "point_1"; medal.Name = "大富翁"; medal.MaxLevelID = 5; MedalLevel level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/gold1.gif"; level.ID = 1; level.Name = "万元户"; level.Value = 10000; medal.Levels.Add(level); level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/gold2.gif"; level.ID = 2; level.Name = "暴发户"; level.Value = 100000; medal.Levels.Add(level); level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/gold3.gif"; level.ID = 3; level.Name = "百万富翁"; level.Value = 1000000; medal.Levels.Add(level); level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/gold4.gif"; level.ID = 4; level.Name = "千万富翁"; level.Value = 10000000; medal.Levels.Add(level); level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/gold5.gif"; level.ID = 5; level.Name = "亿万富翁"; level.Value = 100000000; medal.Levels.Add(level); Medals.Add(medal); medal = new Medal(); medal.ID = 2; medal.IsCustom = true; medal.IsHidden = false; medal.Enable = true; medal.Condition = ""; medal.Name = "忠实用户"; medal.MaxLevelID = 1; level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/medal15.gif"; level.ID = 1; level.Name = "一级"; level.Condition = "参与“领取每日积分大礼包”任务可获得此图标"; medal.Levels.Add(level); Medals.Add(medal); medal = new Medal(); medal.ID = 3; medal.IsCustom = true; medal.IsHidden = true; medal.Enable = true; medal.Condition = ""; medal.Name = "开国元老"; medal.MaxLevelID = 1; level = new MedalLevel(); level.IconSrc = "~/max-assets/icon-medal/medal11.gif"; level.ID = 1; level.Name = "一级"; level.Condition = "需要管理员点亮"; medal.Levels.Add(level); Medals.Add(medal); }
protected Medal GetMedal(int medalID) { Medal medal = AllSettings.Current.MedalSettings.Medals.GetValue(medalID); if (medal == null) { medal = new Medal(); medal.ID = medalID; medal.Levels = new MedalLevelCollection(); medal.Name = "该图标不存在或者已被删除"; } return medal; }
public void NewMedal(string player, Medal.Categ type, bool updateMode) { networkView.RPC("NewMedalAck", RPCMode.Others, "Success", player, type.ToString(), updateMode); }
public void SetMedal(Medal m) { GameManager.medal = m; }
public Player(string json) { JObject data = JObject.Parse(json); this.PlayerName = data["list"][Configs.GetPlayer()]["name"].ToString(); this.Rank = data["list"][Configs.GetPlayer()]["stats"]["rank"]["nr"].ToString(); this.Score = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["scores"]["score"].ToString()); this.Objective = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["scores"]["objective"].ToString()); this.TimeRaw = data["list"][Configs.GetPlayer()]["stats"]["global"]["time"].ToString(); this.Kills = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["kills"].ToString()); this.Deaths = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["deaths"].ToString()); this.Skill = Convert.ToSingle(data["list"][Configs.GetPlayer()]["stats"]["global"]["elo"].ToString()); this.Wins = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["wins"].ToString()); this.Losses = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["losses"].ToString()); this.Hits = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["hits"].ToString()); this.Shots = Convert.ToInt32(data["list"][Configs.GetPlayer()]["stats"]["global"]["shots"].ToString()); this.RankPic = data["list"][Configs.GetPlayer()]["stats"]["rank"]["img_small"].ToString(); JObject kits = (JObject)data["list"][Configs.GetPlayer()]["stats"]["kits"]; this.Assault.Score = Convert.ToInt32(kits["assault"]["score"].ToString()); this.Assault.TimeRaw = kits["assault"]["time"].ToString(); this.Assault.KitPic = kits["assault"]["img"].ToString(); this.Engineer.Score = Convert.ToInt32(kits["engineer"]["score"].ToString()); this.Engineer.TimeRaw = kits["engineer"]["time"].ToString(); this.Engineer.KitPic = kits["engineer"]["img"].ToString(); this.Recon.Score = Convert.ToInt32(kits["recon"]["score"].ToString()); this.Recon.TimeRaw = kits["recon"]["time"].ToString(); this.Recon.KitPic = kits["recon"]["img"].ToString(); this.Support.Score = Convert.ToInt32(kits["support"]["score"].ToString()); this.Support.TimeRaw = kits["support"]["time"].ToString(); this.Support.KitPic = kits["support"]["img"].ToString(); JObject weapons = (JObject)data["list"][Configs.GetPlayer()]["stats"]["weapons"]; var wenum = weapons.GetEnumerator(); while (wenum.MoveNext()) { Weapon weapon = new Weapon(); JObject w = JObject.Parse(wenum.Current.Value.ToString()); weapon.Time = w["time"].ToString(); weapon.Kills = w["kills"].ToString(); weapon.Headshots = w["headshots"].ToString(); weapon.Hits = w["hits"].ToString(); weapon.Shots = w["shots"].ToString(); weapon.Stars = w["star"]["count"].ToString(); weapon.WeaponName = w["name"].ToString(); weapon.WeaponPic = w["img"].ToString(); weapon.Current = Convert.ToInt32(w["star"]["curr"].ToString()); weapon.Needed = Convert.ToInt32(w["star"]["needed"].ToString()); weapon.Description = w["desc"].ToString(); weapon.NextStarNeeded = Convert.ToInt32(w["star"]["needed"].ToString()); weapon.NextStarCurrent = Convert.ToInt32(w["star"]["curr"].ToString()); weapon.InKit = w["kit"].ToString(); weapon.Range = w["range"].ToString(); weapon.FireModeBurst = Convert.ToBoolean(w["fireModeBurst"].ToString()); weapon.FireModeAuto = Convert.ToBoolean(w["fireModeAuto"].ToString()); weapon.FireModeSingle = Convert.ToBoolean(w["fireModeSingle"].ToString()); weapon.ROF = w["rateOfFire"].ToString(); weapon.Ammo = w["ammo"].ToString(); JArray unlocks = (JArray)w["unlocks"]; List<WeaponUnlock> unlocklist = new List<WeaponUnlock>(); int i = 0; while (i <= unlocks.Count-1) { JObject u = JObject.Parse(unlocks[i].ToString()); if(u["curr"].ToString() != "") { WeaponUnlock wu = new WeaponUnlock(); wu.Current = Convert.ToInt32(u["curr"].ToString()); wu.Needed = Convert.ToInt32(u["needed"].ToString()); wu.UnlockName = u["name"].ToString(); wu.UnlockPic = u["img"].ToString(); unlocklist.Add(wu); } i++; } weapon.Unlocks = unlocklist; Weapons.Add(weapon); } Weapons.Sort(); JObject vehicles = (JObject)data["list"][Configs.GetPlayer()]["stats"]["vehicles"]; var venum = vehicles.GetEnumerator(); while (venum.MoveNext()) { Vehicle vehicle = new Vehicle(); JObject v = JObject.Parse(venum.Current.Value.ToString()); vehicle.Time = v["time"].ToString(); vehicle.Kills = v["kills"].ToString(); vehicle.Destroys = v["destroys"].ToString(); vehicle.VehicleName = v["name"].ToString(); vehicle.VehiclePic = v["img"].ToString(); vehicle.Description = v["desc"].ToString(); vehicle.TypeKey = v["type"].ToString(); Vehicles.Add(vehicle); } Vehicles.Sort(); JObject ribbons = (JObject)data["list"][Configs.GetPlayer()]["stats"]["ribbons"]; var renum = ribbons.GetEnumerator(); while (renum.MoveNext()) { Ribbon ribbon = new Ribbon(); JObject r = JObject.Parse(renum.Current.Value.ToString()); ribbon.RibbonName = r["name"].ToString(); ribbon.RibbonPic = r["img_small"].ToString(); ribbon.TimesTaken = Convert.ToInt32(r["count"].ToString()); ribbon.Description = r["desc"].ToString(); Ribbons.Add(ribbon); } Ribbons.Sort(); JObject medals = (JObject)data["list"][Configs.GetPlayer()]["stats"]["medals"]; var menum = medals.GetEnumerator(); while (menum.MoveNext()) { Medal medal = new Medal(); JObject m = JObject.Parse(menum.Current.Value.ToString()); medal.MedalName = m["name"].ToString(); medal.MedalPic = m["img_small"].ToString(); medal.TimesTaken = Convert.ToInt32(m["count"].ToString()); medal.Description = m["desc"].ToString(); Medals.Add(medal); } Medals.Sort(); JObject specs = (JObject)data["list"][Configs.GetPlayer()]["stats"]["specializations"]; var senum = specs.GetEnumerator(); while (senum.MoveNext()) { Specialization spec = new Specialization(); JObject s = JObject.Parse(senum.Current.Value.ToString()); spec.SpecName = s["name"].ToString(); spec.Description = s["desc"].ToString(); spec.Current = Convert.ToInt32(s["curr"].ToString()); spec.Needed = Convert.ToInt32(s["needed"].ToString()); spec.SpecPic = s["img"].ToString(); Specs.Add(spec); } JObject vunlocks = (JObject)data["list"][Configs.GetPlayer()]["stats"]["vehcats"]; var vuenum = vunlocks.GetEnumerator(); while (vuenum.MoveNext()) { VehicleType vt = new VehicleType(); JObject v = JObject.Parse(vuenum.Current.Value.ToString()); vt.TypeName = v["name"].ToString(); if (vt.TypeName != "Air Jet Attack") { vt.TypePic = v["img"].ToString(); vt.Kills = Convert.ToInt32(v["kills"].ToString()); vt.TimeRaw = v["time"].ToString(); vt.Score = Convert.ToInt32(v["score"].ToString()); vt.ServiceStars = Convert.ToInt32(v["star"]["count"].ToString()); vt.SSCurrent = Convert.ToInt32(v["star"]["curr"].ToString()); vt.SSNeeded = Convert.ToInt32(v["star"]["needed"].ToString()); JArray unlocks = (JArray)v["unlocks"]; List<VehicleUnlock> unlocklist = new List<VehicleUnlock>(); int i = 0; while (i <= unlocks.Count - 1) { JObject u = JObject.Parse(unlocks[i].ToString()); if (u["curr"].ToString() != "") { VehicleUnlock vu = new VehicleUnlock(); vu.Current = Convert.ToInt32(u["curr"].ToString()); vu.Needed = Convert.ToInt32(u["needed"].ToString()); vu.UnlockName = u["name"].ToString(); vu.UnlockPic = u["img"].ToString(); vu.Description = u["desc"].ToString(); unlocklist.Add(vu); } i++; } vt.Unlocks = unlocklist; VehicleTypes.Add(vt); } } VehicleTypes.Sort(); Equipment sb = new Equipment(); sb.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqRad"]["name"].ToString(); sb.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqRad"]["desc"].ToString(); sb.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqRad"]["img"].ToString(); sb.KitPic = "misc/Mp_Recon_Sc_Recon.png"; sb.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqRad"]["spawns"].ToString() + " spawns"; Equipments.Add(sb); Equipment g = new Equipment(); g.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["name"].ToString(); g.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["desc"].ToString(); g.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["img"].ToString(); g.KitPic = "misc/Mp_General_Sc_General.png"; g.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["kills"].ToString() + " kills, " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["hits"].ToString() + " hits in " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeM67"]["shots"].ToString() + " throws"; Equipments.Add(g); Equipment rt = new Equipment(); rt.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasRT"]["name"].ToString(); rt.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasRT"]["desc"].ToString(); rt.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasRT"]["img"].ToString(); rt.KitPic = "misc/Mp_Engineer_Sc_Engineer.png"; rt.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasRT"]["kills"].ToString() + " kills and " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasRT"]["repairs"].ToString() + " repairs"; Equipments.Add(rt); Equipment c4 = new Equipment(); c4.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeC4"]["name"].ToString(); c4.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeC4"]["desc"].ToString(); c4.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeC4"]["img"].ToString(); c4.KitPic = "misc/Mp_Support_Sc_Support.png"; c4.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeC4"]["kills"].ToString() + " kills"; Equipments.Add(c4); Equipment d = new Equipment(); d.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasDef"]["name"].ToString(); d.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasDef"]["desc"].ToString(); d.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasDef"]["img"].ToString(); d.KitPic = "misc/Mp_Assault_Sc_Assault.png"; d.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["wasDef"]["revives"].ToString() + " revives"; Equipments.Add(d); Equipment tugg = new Equipment(); tugg.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqUGS"]["name"].ToString(); tugg.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqUGS"]["desc"].ToString(); tugg.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqUGS"]["img"].ToString(); tugg.KitPic = "misc/Mp_Recon_Sc_Recon.png"; tugg.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqUGS"]["spots"].ToString() + " spots"; Equipments.Add(tugg); Equipment mine = new Equipment(); mine.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["name"].ToString(); mine.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["desc"].ToString(); mine.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["img"].ToString(); mine.KitPic = "misc/Mp_Engineer_Sc_Engineer.png"; mine.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["kills"].ToString() + " kills and " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["hits"].ToString() + " hits in " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMine"]["shots"].ToString() + " deploys"; Equipments.Add(mine); Equipment clay = new Equipment(); clay.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["name"].ToString(); clay.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["desc"].ToString(); clay.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["img"].ToString(); clay.KitPic = "misc/Mp_Support_Sc_Support.png"; clay.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["kills"].ToString() + " kills and " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["hits"].ToString() + " hits in " + data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeClay"]["shots"].ToString()+ " deploys"; Equipments.Add(clay); Equipment billy = new Equipment(); billy.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqEOD"]["name"].ToString(); billy.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqEOD"]["desc"].ToString(); billy.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqEOD"]["img"].ToString(); billy.KitPic = "misc/Mp_Engineer_Sc_Engineer.png"; billy.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqEOD"]["kills"].ToString() + " kills"; Equipments.Add(billy); Equipment sof = new Equipment(); sof.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqSOF"]["name"].ToString(); sof.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqSOF"]["desc"].ToString(); sof.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqSOF"]["img"].ToString(); sof.KitPic = "misc/Mp_Recon_Sc_Recon.png"; sof.LineTwo = ""; Equipments.Add(sof); Equipment mort = new Equipment(); mort.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMort"]["name"].ToString(); mort.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMort"]["desc"].ToString(); mort.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMort"]["img"].ToString(); mort.KitPic = "misc/Mp_Support_Sc_Support.png"; mort.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["waeMort"]["kills"].ToString() + " kills"; Equipments.Add(mort); Equipment mav = new Equipment(); mav.EquipName = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqMAV"]["name"].ToString(); mav.Description = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqMAV"]["desc"].ToString(); mav.EquipPic = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqMAV"]["img"].ToString(); mav.KitPic = "misc/Mp_Recon_Sc_Recon.png"; mav.LineTwo = data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqMAV"]["kills"].ToString() + " kills and "+ data["list"][Configs.GetPlayer()]["stats"]["equipment"]["seqMAV"]["spots"].ToString() + " spots"; Equipments.Add(mav); Equipments.Sort(); double assaulttime = Convert.ToDouble(Assault.TimeRaw); double recontime = Convert.ToDouble(Recon.TimeRaw); double supporttime = Convert.ToDouble(Support.TimeRaw); double engtime = Convert.ToDouble(Engineer.TimeRaw); double totaltime = assaulttime + recontime + supporttime + engtime; string assaultper = String.Format("{0:0.##}", ((assaulttime / totaltime) * 100)); string reconper = String.Format("{0:0.##}", ((recontime / totaltime) * 100)); string supportper = String.Format("{0:0.##}", ((supporttime / totaltime) * 100)); string engper = String.Format("{0:0.##}", ((engtime / totaltime) * 100)); string timesuri = "http://chart.googleapis.com/chart?&cht=pc&chd=t:100|" + assaultper + "," + engper + "," + supportper + "," + reconper + "&chco=ffffff,308DBF|C4B469|86AE31|A1562E&chs="; BackTilePic = timesuri; JArray upcomingranks = (JArray)data["list"][Configs.GetPlayer()]["stats"]["nextranks"]; int k = 0; while (k <= upcomingranks.Count - 1) { JObject u = JObject.Parse(upcomingranks[k].ToString()); NextRank nr = new NextRank(); nr.RankName = u["name"].ToString(); nr.RankPic = u["img_small"].ToString(); nr.Level = u["nr"].ToString(); nr.RequiredScore = Convert.ToInt32(u["score"].ToString()); nr.Left = Convert.ToInt32(u["left"].ToString()); NextRanks.Add(nr); k++; } Configs.SetPlayerRank(this.Rank); IntDateChecked = data["list"][Configs.GetPlayer()]["stats"]["date_check"].ToString(); IntDateUpdated = data["list"][Configs.GetPlayer()]["stats"]["date_update"].ToString(); }
private void SaveSetting() { MessageDisplay msgDisplay = CreateMessageDisplay("name", "levelname", "iconsrc", "condition"); MedalCollection medals = new MedalCollection(); int i = 0; foreach (Medal medal in MedalList) { Medal tempMedal = new Medal(); tempMedal.SortOrder = _Request.Get<int>("sortorder_" + medal.ID, Method.Post, 0); tempMedal.Name = _Request.Get("name_" + medal.ID, Method.Post, string.Empty).Trim(); if (tempMedal.Name == string.Empty) { msgDisplay.AddError("name", i, "勋章名称不能为空"); } tempMedal.Enable = _Request.Get<bool>("enable_" + medal.ID, Method.Post, false); tempMedal.IsHidden = _Request.Get<bool>("isHidden_" + medal.ID, Method.Post, false); tempMedal.Levels = new MedalLevelCollection(); tempMedal.Condition = medal.Condition; //if (medal.IsCustom) //{ // //tempMedal.Condition = _Request.Get("condition_" + medal.ID, Method.Post, string.Empty).Trim(); // //msgDisplay.AddError("condition", i, "点亮规则不能为空"); //} //else //{ List<int> values = new List<int>(); foreach (MedalLevel level in medal.Levels) { MedalLevel tempLevel = new MedalLevel(); tempLevel.Name = level.Name; tempLevel.Value = level.Value; tempLevel.IconSrc = level.IconSrc; tempLevel.Condition = level.Condition; //tempLevel.Name = _Request.Get("levelName_" + medal.ID + "_" + level.ID, Method.Post, string.Empty).Trim(); //if (tempLevel.Name == string.Empty) //{ // msgDisplay.AddError("levelname", i, "等级名称不能为空"); //} //tempLevel.Value = _Request.Get<int>("levelValue_" + medal.ID + "_" + level.ID, Method.Post, 0); //if (values.Contains(tempLevel.Value)) //{ // msgDisplay.AddError("Condition",i,"不同等级的点亮规则必须不同"); //} //values.Add(tempLevel.Value); //tempLevel.IconSrc = _Request.Get("iconSrc_" + medal.ID + "_" + level.ID, Method.Post, string.Empty).Trim(); //if (tempLevel.IconSrc == string.Empty) //{ // msgDisplay.AddError("iconSrc", i, "等级图标不能为空"); //} tempLevel.ID = level.ID; tempMedal.Levels.Add(tempLevel); } //} tempMedal.ID = medal.ID; tempMedal.IsCustom = medal.IsCustom; tempMedal.MaxLevelID = medal.MaxLevelID; medals.Add(tempMedal); i++; } if (msgDisplay.HasAnyError()) return; MedalSettings setting = new MedalSettings(); setting.Medals = medals; setting.MaxMedalID = AllSettings.Current.MedalSettings.MaxMedalID; try { if (!SettingManager.SaveSettings(setting)) { CatchError<ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); } else { UserBO.Instance.RemoveAllUserCache(); m_MedalList = null; _Request.Clear(Method.Post); } } catch (Exception ex) { msgDisplay.AddError(ex.Message); } }
public static void ConvertMedals() { MedalSettings medalSetting = new MedalSettings(); MedalCollection medals = new MedalCollection(); string sql = @" IF EXISTS(SELECT * FROM sysobjects WHERE [type]=N'TR' AND [name]=N'bx_UserMedals_AfterUpdate') DROP TRIGGER bx_UserMedals_AfterUpdate; --GO "; using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sql, connection); command.CommandTimeout = 60; try { command.ExecuteNonQuery(); } catch (Exception ex) { CreateLog(ex); throw new Exception("ɾ��������bx_UserMedals_AfterUpdateʧ��" + ex.Message + sql); } finally { connection.Close(); } } sql = @" IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'Max_Medals') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='Max_UserMedals') BEGIN SELECT * FROM Max_Medals; END ELSE SELECT -9999 AS MedalID; "; using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sql, connection); command.CommandTimeout = 60; try { bool hasCreateErrorLog = false; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { int medalID = reader.GetInt32(reader.GetOrdinal("MedalID")); if (medalID == -9999) return; Medal tempMedal = new Medal(); tempMedal.Condition = string.Empty; tempMedal.Enable = reader.GetBoolean(reader.GetOrdinal("IsEnabled")); tempMedal.IsCustom = true; tempMedal.ID = medalID; tempMedal.MaxLevelID = 1; tempMedal.Name = reader.GetString(reader.GetOrdinal("MedalName")); tempMedal.SortOrder = 0; tempMedal.Levels = new MedalLevelCollection(); MedalLevel tempLevel = new MedalLevel(); tempLevel.Condition = string.Empty; string iconUrl = reader.GetString(reader.GetOrdinal("LogoUrl")).Replace("\\", "/"); int i = iconUrl.LastIndexOf("/") + 1; string iconName = string.Empty; if (iconUrl.Length > i) iconName = iconUrl.Substring(i, iconUrl.Length - i); else continue; string targetDir = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, "/max-assets/icon-medal/"); string targetIconUrl = targetDir + iconName; iconUrl = MaxLabs.bbsMax.UrlUtil.JoinUrl(MaxLabs.bbsMax.Globals.ApplicationPath, iconUrl); if (File.Exists(iconUrl)) { if (File.Exists(targetIconUrl)) { } else { try { if (Directory.Exists(targetDir) == false) Directory.CreateDirectory(targetDir); File.Move(iconUrl, targetIconUrl); } catch { if (hasCreateErrorLog == false) { hasCreateErrorLog = true; ErrorMessages.Add("�ƶ�ѫ��ͼ��ʧ��,���ֶ��ѡ�/Images/Medals/��Ŀ¼�µ�����ͼ�긴�Ƶ���/max-assets/icon-medal/��Ŀ¼��"); } } } } tempLevel.IconSrc = "~/max-assets/icon-medal/" + iconName; tempLevel.Name = string.Empty; tempLevel.ID = 1; tempMedal.Levels.Add(tempLevel); medals.Add(tempMedal); if (medalSetting.MaxMedalID < tempMedal.ID) medalSetting.MaxMedalID = tempMedal.ID; } } foreach (Medal medal in new MedalSettings().Medals) { medal.ID = medalSetting.MaxMedalID + 1; medals.Add(medal); medalSetting.MaxMedalID += 1; } medalSetting.Medals = medals; sql = @" UPDATE bx_Settings SET [Value] = @MedalString WHERE TypeName = 'MaxLabs.bbsMax.Settings.MedalSettings' AND [Key] = '*'; IF @@ROWCOUNT = 0 INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('*', @MedalString, 'MaxLabs.bbsMax.Settings.MedalSettings'); IF EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='Max_UserMedals') BEGIN truncate table [bx_UserMedals]; INSERT INTO [bx_UserMedals] ([UserID] ,[MedalID] ,[MedalLevelID] ,[EndDate] ,[CreateDate]) SELECT UserID ,MedalID ,1 ,ExpiresDate ,CreateDate FROM Max_UserMedals WITH (NOLOCK); DROP TABLE Max_UserMedals; END DROP TABLE Max_Medals; "; command.CommandText = sql; command.CommandTimeout = 3600; //command.Parameters.AddWithValue("@MedalString", medalSetting.ToString()); SqlParameter param = new SqlParameter("@MedalString", SqlDbType.NText); param.Value = medalSetting.ToString(); command.Parameters.Add(param); command.ExecuteNonQuery(); //AllSettings.Current.MedalSettings = medalSetting; } catch (Exception ex) { CreateLog(ex); throw new Exception("����ѫ������ʧ��" + ex.Message + sql); } finally { connection.Close(); } } }
public void getCurrentMedal() { if (GoldMedalTime >= _time) { CurrentMedal = Medal.Gold; } if (SilverMedalTime >= _time && GoldMedalTime < _time) { CurrentMedal = Medal.Silver; } if (SilverMedalTime < _time) { CurrentMedal = Medal.Bronze; } }
private void SaveSetting() { MessageDisplay msgDisplay = CreateMessageDisplay("medalname", "sortorder", "medallevel"); Medal medal = new Medal(); if (IsEdit) { medal.ID = MedalID; } else { medal.ID = AllSettings.Current.MedalSettings.MaxMedalID + 1; } medal.Name = _Request.Get("medalname", Method.Post, string.Empty); if (medal.Name == string.Empty) msgDisplay.AddError("medalname", "图标名称不能为空"); medal.SortOrder = _Request.Get<int>("sortorder", Method.Post, 0); medal.Enable = _Request.Get<bool>("enable", Method.Post, false); medal.IsHidden = _Request.Get<bool>("IsHidden", Method.Post, false); medal.IsCustom = _Request.Get<bool>("isAuto", Method.Post, false) == false; if (medal.IsCustom) medal.Condition = string.Empty; else medal.Condition = _Request.Get("condition", Method.Post, string.Empty); m_MedalCondition = medal.Condition; bool hasMedallevelError = false; if (medal.Condition == string.Empty && medal.IsCustom == false) { msgDisplay.AddError("medallevel", "请选择规则"); hasMedallevelError = true; } medal.Levels = new MedalLevelCollection(); int[] ids = _Request.GetList<int>("ids", Method.Post, new int[0] { }); if (IsEdit) medal.MaxLevelID = Medal.MaxLevelID; List<int> values = new List<int>(); m_MedalLevels = new MedalLevelCollection(); foreach (int id in ids) { MedalLevel level = new MedalLevel(); if (IsEdit) { foreach (MedalLevel tempMedalLevel in Medal.Levels) { if (id == tempMedalLevel.ID) { level.ID = id; break; } } } if (level.ID == 0) { medal.MaxLevelID = medal.MaxLevelID + 1; level.ID = medal.MaxLevelID; } if (_Request.Get("levelName_" + id, Method.Post) == null) continue; level.Name = _Request.Get("levelName_" + id, Method.Post, string.Empty).Trim(); level.IconSrc = _Request.Get("IconSrc_" + id, Method.Post, string.Empty).Trim(); if (medal.IsCustom) level.Condition = _Request.Get("conditionDescription_" + id, Method.Post, string.Empty).Trim(); else { level.Condition = string.Empty; level.Value = _Request.Get<int>("levelValue_" + id, Method.Post, 0); } if (hasMedallevelError == false) { //if (level.Name == string.Empty) //{ // msgDisplay.AddError("medallevel", "等级名称不能为空"); //} if (level.IconSrc == string.Empty) { msgDisplay.AddError("medallevel", "等级图标不能为空"); } //else if (medal.IsCustom && level.Condition == string.Empty) //{ // msgDisplay.AddError("medallevel", "点亮图标说明不能为空"); //} else if (medal.IsCustom == false && values.Contains(level.Value)) { msgDisplay.AddError("medallevel", "点亮图标需达到的值不能相同"); } } if (medal.IsCustom == false) values.Add(level.Value); medal.Levels.Add(level,medal.IsCustom == false); m_MedalLevels.Add(level, false); } m_IsCustom = medal.IsCustom; if (msgDisplay.HasAnyError()) return; MedalSettings medalSetting = new MedalSettings(); medalSetting.Medals = new MedalCollection(); foreach (Medal tempMedal in AllSettings.Current.MedalSettings.Medals) { if (IsEdit && medal.ID == tempMedal.ID) { medalSetting.Medals.Add(medal); } else medalSetting.Medals.Add(tempMedal); } if (IsEdit) medalSetting.MaxMedalID = AllSettings.Current.MedalSettings.MaxMedalID; else { medalSetting.Medals.Add(medal); medalSetting.MaxMedalID = medal.ID; } bool success = false; try { using (new ErrorScope()) { if (SettingManager.SaveSettings(medalSetting) == false) { CatchError<ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); } else { if(IsEdit) UserBO.Instance.RemoveAllUserCache(); success = true; } } } catch (Exception ex) { msgDisplay.AddError(ex.Message); } if (success) JumpTo("interactive/setting-medals.aspx"); }
public void GetBestMedalByLevelName(string levelName) { // Retrieve BestMedal from XML file (Deserialization) if (_scoreHistory.ContainsKey(levelName)) { _bestMedal = _scoreHistory[levelName].GetBestMedal(); } else { _scoreHistory.Add(levelName, new ScoreHistory()); _bestMedal = Medal.None; } }
void OnGameOver() { //determinde the medal deserved, none for defeat if (bricksLeft <=0) medal = Medal.Gold; // The game ends in victory when there are no bricks left else if (shinyBricksGoal > 0) medal = Medal.None; else if (bricksDestroyed * 4 > bricksLeft * 3) medal = Medal.Silver; else medal = Medal.Bronze; gameScore.AddFinalScore(spheres, bricksLeft, GetRemainingTime()); SetMedal(medal); EndGame(); }
public void NewMedal(Medal.Categ type, bool client, bool updateMode) { Medal medal = new Medal(type); string notifText = ""; Medals.Add(medal); switch (type) { case Medal.Categ.FirstProcessPublished: notifText = "First process published in the game."; break; case Medal.Categ.MarkedProcessDuplicated: notifText = "Marked a process as a duplicate correctly."; break; case Medal.Categ.BestQualityContent: notifText = "Created process with best quality vote rate."; break; case Medal.Categ.BestVoteConvergence: notifText = "Best convergence in votes placed."; break; } Score += medal.ScorePoints; if (client && !updateMode) Painter.Manager.Notifications.Items.Add(new Notification(Notification.Type.Medal, notifText)); }