// Draw a single rank entry void DrawRankEntry(RankEntry entry) { using (new GUIHorizontal("box")) { GUI.contentColor = Color.white; GUILayout.Label((entry.rankIndex + 1).ToString() + ".", rankingNumberStyle); // Load country icon if not loaded yet if (!countryCodeToIcon.ContainsKey(entry.country)) { countryCodeToIcon[entry.country] = LoadCountryIconAsync(entry.country); } if (entry.name == InGameLobby.instance.displayedAccount.playerName) { GUI.contentColor = GUIColor.RankingMine; } else { GUI.contentColor = GUIColor.RankingOther; } // Player name DrawPlayerName(entry.name, new GUIContent(" " + entry.name, countryCodeToIcon[entry.country].data), rankingNameStyle); GUILayout.FlexibleSpace(); GUILayout.Label(entry.bestRanking + " p", rankingScoreStyle); } }
int GetRank() { Dictionary <string, RemotePlayer> players = RacingGameManager.RemotePlayers; int index = 0; RankEntry[] ents = new RankEntry[players.Count + 1]; foreach (var e in players) { ents[index].Progress = e.Value.CompletionProgress; ents[index].ID = e.Value.ID; ents[index++].Name = e.Value.Name; } ents[index].Progress = RacingGameManager.Player.GetCompletionProgress(); ents[index].ID = RacingGameManager.LocalUID; ents[index].Name = RacingGameManager.LocalPlayerName; Array.Sort(ents, RankComparision); for (int i = 0; i < ents.Length; i++) { if (ents[i].ID == RacingGameManager.LocalUID) { return(i); } } return(0); }
// BitStream Writer public static void WriteToBitStream(uLink.BitStream stream, object val, params object[] args) { RankEntry myObj = (RankEntry)val; //stream.WriteInt32(myObj.rankIndex); //stream.WriteString(myObj.accountId); stream.WriteString(myObj.name); stream.WriteString(myObj.country); stream.WriteInt32(myObj.bestRanking); //stream.WriteInt64(myObj.totalDamage); }
// BitStream Reader public static object ReadFromBitStream(uLink.BitStream stream, params object[] args) { RankEntry myObj = new RankEntry(); //myObj.rankIndex = stream.ReadInt32(); //myObj.accountId = stream.ReadString(); myObj.name = stream.ReadString(); myObj.country = stream.ReadString(); myObj.bestRanking = stream.ReadInt32(); //myObj.totalDamage = stream.ReadInt64(); return(myObj); }
// BitStream Reader public static object ReadFromBitStream(uLink.BitStream stream, params object[] args) { RankEntry myObj = new RankEntry(); //myObj.rankIndex = stream.ReadInt32(); //myObj.accountId = stream.ReadString(); myObj.name = stream.ReadString(); myObj.country = stream.ReadString(); myObj.bestRanking = stream.ReadInt32(); //myObj.totalDamage = stream.ReadInt64(); return myObj; }
public RankEntry GetOrAdd(LevelPermission perm) { RankEntry rank = Find(perm); if (rank != null) { return(rank); } rank = new RankItem.RankEntry(); rank.Perm = perm; Ranks.Add(rank); Ranks.Sort((a, b) => a.Perm.CompareTo(b.Perm)); return(rank); }
protected internal override void OnStoreOverview(Player p) { RankEntry next = NextRank(p); if (next == null) { p.Message("&6Rankup %S- %Wno further ranks to buy."); } else { p.Message("&6Rankup to {0} %S- &a{1} %S{2}", Group.GetColoredName(next.Perm), next.Price, Server.Config.Currency); } }
// Reader public static object JsonDeserializer(JsonReader reader) { var scoreEntry = new RankEntry(); reader.ReadArrayStart(); scoreEntry.rankIndex = (int)reader.ReadNumber(); scoreEntry.accountId = reader.ReadString(); scoreEntry.name = reader.ReadString(); scoreEntry.country = reader.ReadString(); scoreEntry.bestRanking = (int)reader.ReadNumber(); scoreEntry.totalDamage = (long)reader.ReadNumber(); reader.ReadArrayEnd(); return(scoreEntry); }
// Reader public static object JsonDeserializer(JsonReader reader) { var scoreEntry = new RankEntry(); reader.ReadArrayStart(); scoreEntry.rankIndex = (int)reader.ReadNumber(); scoreEntry.accountId = reader.ReadString(); scoreEntry.name = reader.ReadString(); scoreEntry.country = reader.ReadString(); scoreEntry.bestRanking = (int)reader.ReadNumber(); scoreEntry.totalDamage = (long)reader.ReadNumber(); reader.ReadArrayEnd(); return scoreEntry; }
public override void Parse(string line, string[] args) { if (!args[1].CaselessEq("price")) { return; } LevelPermission perm = Group.ParsePermOrName(args[2], LevelPermission.Null); if (perm == LevelPermission.Null) { return; } RankEntry rank = GetOrAdd(perm); rank.Price = int.Parse(args[3]); }
/// <summary> /// Get info from entry and update properties accordingly /// </summary> /// <param name="entry"></param> private void ParseEntry(JournalEntry entry) { if (entry.Event == "FSDJump") { FSDJumpEntry jumpInfo = (FSDJumpEntry)entry; FuelLevel = jumpInfo.FuelLevel; CurrentPosition = jumpInfo.StarPos; } else if (entry.Event == "FuelScoop") { FuelScoopEntry scoopInfo = (FuelScoopEntry)entry; FuelLevel = scoopInfo.Total; } else if (entry.Event == "LoadGame") { LoadGameEntry loadGameInfo = (LoadGameEntry)entry; FuelLevel = loadGameInfo.FuelLevel; FuelCapacity = loadGameInfo.FuelCapacity; } else if (entry.Event == "Location") { LocationEntry locationInfo = (LocationEntry)entry; CurrentPosition = locationInfo.StarPos; } else if (entry.Event == "Promotion") { PromotionEntry promotionInfo = (PromotionEntry)entry; if (promotionInfo.RankName == "Explore") { RankExplore = new Rank("Exploration", promotionInfo.NewRank); } } else if (entry.Event == "Rank") { RankEntry rankInfo = (RankEntry)entry; RankExplore = new Rank("Exploration", rankInfo.Explore); } else if (entry.Event == "RefuelAll" || entry.Event == "RefuelPartial") { RefuelEntry refuelInfo = (RefuelEntry)entry; FuelLevel += refuelInfo.Amount; } UpdateProperties(); }
public void RefreshRank() { Memory.Player.Map[0] = _process.ReadValue <int>(Pointers.Map, Emulator.IsBigEndian); Memory.Player.Map[1] = _process.ReadValue <int>(IntPtr.Add(Pointers.Map, 8), Emulator.IsBigEndian); Memory.Player.Map[2] = _process.ReadValue <int>(IntPtr.Add(Pointers.Map, 16), Emulator.IsBigEndian); Memory.Player.Steve = _process.ReadValue <int>(Pointers.Steve, Emulator.IsBigEndian); Memory.Player.Rodrigo = _process.ReadValue <int>(Pointers.Rodrigo, Emulator.IsBigEndian); Memory.Rank.Time = RankEntry.PlayTimeScore(Memory.IGT.RunningTimer, (int)Memory.Difficulty, (int)Memory.Player.Character); Memory.Rank.Saves = RankEntry.SaveCountScore(Memory.Player.Saves); Memory.Rank.Retry = RankEntry.RetryCountScore(Memory.Player.Retry); Memory.Rank.FAS = RankEntry.HealItemUseScore(Memory.Player.FAS); Memory.Rank.Map = RankEntry.MapScore(Memory.Player.Map); Memory.Rank.Steve = RankEntry.SteveEventScore(Memory.Player.Steve); Memory.Rank.Rodrigo = RankEntry.RodrigoEventScore(Memory.Player.Rodrigo); Memory.Rank.UpdateScore(); }
private void CreateRankEntryTransform(RankEntry rankEntry, Transform container, List <Transform> transformList) { float templateHeight = 75f; Transform rankTransform = Instantiate(rankTemplate, container); rankTransform.transform.SetParent(rankTemplate.transform.parent); RectTransform rankRectTransform = rankTransform.GetComponent <RectTransform>(); rankRectTransform.anchoredPosition = new Vector2(0, -templateHeight * transformList.Count); rankTransform.gameObject.SetActive(true); int rank = transformList.Count + 1; string rankString; switch (rank) { default: rankString = rank + "TH"; break; case 1: rankString = "1ST"; break; case 2: rankString = "2ND"; break; case 3: rankString = "3RD"; break; } rankTransform.Find("rankText").GetComponent <Text>().text = rankString; int points = rankEntry.charScore; rankTransform.Find("pointText").GetComponent <Text>().text = points.ToString(); string name = rankEntry.userName; rankTransform.Find("nameText").GetComponent <Text>().text = name; int userId = rankEntry.userId; rankTransform.Find("userId").GetComponent <Text>().text = userId.ToString(); rankTransform.Find("userId").gameObject.SetActive(false); rankTransform.Find("bgForEntry").gameObject.SetActive(true); transformList.Add(rankTransform); }
protected internal override void OnBuyCommand(Player p, string message, string[] args) { if (args.Length >= 2) { p.Message("%WYou cannot provide a rank name, use %T/Buy rank %Wto buy the NEXT rank."); return; } RankEntry nextRank = NextRank(p); if (nextRank == null) { p.Message("%WYou are already at or past the max buyable rank"); return; } if (p.money < nextRank.Price) { p.Message("%WYou don't have enough &3" + Server.Config.Currency + " %Wto buy the next rank"); return; } Group rank = Group.Find(nextRank.Perm); // TODO: What if null reference happens here Command.Find("SetRank").Use(Player.Console, p.name + " " + rank.Name); p.Message("You bought the rank " + rank.ColoredName); Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + rank.ColoredName); }
protected internal override void OnPurchase(Player p, string args) { if (args.Length > 0) { p.Message("&WYou cannot provide a rank name, use &T/Buy rank &Wto buy the NEXT rank."); return; } RankEntry nextRank = NextRank(p); if (nextRank == null) { p.Message("&WYou are already at or past the max buyable rank"); return; } if (!CheckPrice(p, nextRank.Price, "the next rank")) { return; } Group rank = Group.Find(nextRank.Perm); // TODO: What if null reference happens here Command.Find("SetRank").Use(Player.Console, p.name + " " + rank.Name); p.Message("You bought the rank " + rank.ColoredName); Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + rank.ColoredName); }
/// <summary> /// Render game user interface /// </summary> /// <param name="currentGameTime">Current game time</param> /// <param name="bestLapTime">Best lap time</param> /// <param name="lapNumber">Lap number</param> /// <param name="speed">Speed</param> /// <param name="gear">Gear</param> /// <param name="trackName">Track name</param> /// <param name="top5LapTimes">Top 5 lap times</param> public void RenderGameUI(int currentGameTime, int bestLapTime, int lapNumber, float speed, int gear, float acceleration, string trackName, Dictionary <string, RemotePlayer> players) { Color baseUIColor = Color.White;//ColorHelper.HalfAlpha; // If game is over, set speed, gear and acceleration to 0 if (RacingGameManager.Player.GameOver) { speed = 0; gear = 1; acceleration = 0; } // More distance to the screen borders on the Xbox 360 to fit better into // the save region. Calculate all rectangles for each platform, // then they will be used the same way on both platforms. #if XBOX360 // Draw all boxes and background stuff Rectangle lapsRect = BaseGame.CalcRectangle1600( 60, 46, LapsGfxRect.Width, LapsGfxRect.Height); ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor); Rectangle timesRect = BaseGame.CalcRectangle1600( 60, 46, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height); timesRect.Y = BaseGame.Height - timesRect.Bottom; ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor); Rectangle trackNameRect = BaseGame.CalcRectangle1600( 60, 46, TrackNameGfxRect.Width, TrackNameGfxRect.Height); trackNameRect.X = BaseGame.Width - trackNameRect.Right; ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor); Rectangle top5Rect1 = BaseGame.CalcRectangle1600( 60, 4, Best5GfxRect.Width, Best5GfxRect.Height); top5Rect1.X = trackNameRect.X; int top5Distance = top5Rect1.Y; top5Rect1.Y += trackNameRect.Bottom; ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor); Rectangle top5Rect2 = new Rectangle(top5Rect1.X, top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor); Rectangle top5Rect3 = new Rectangle(top5Rect1.X, top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor); Rectangle top5Rect4 = new Rectangle(top5Rect1.X, top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor); Rectangle top5Rect5 = new Rectangle(top5Rect1.X, top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor); Rectangle tachoRect = BaseGame.CalcRectangle1600( 60, 46, TachoGfxRect.Width, TachoGfxRect.Height); tachoRect.X = BaseGame.Width - tachoRect.Right; tachoRect.Y = BaseGame.Height - tachoRect.Bottom; #else // Draw all boxes and background stuff Rectangle lapsRect = BaseGame.CalcRectangle1600( 10, 10, LapsGfxRect.Width, LapsGfxRect.Height); ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor); Rectangle timesRect = BaseGame.CalcRectangle1600( 10, 10, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height); timesRect.Y = BaseGame.Height - timesRect.Bottom; ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor); Rectangle trackNameRect = BaseGame.CalcRectangle1600( 10, 10, TrackNameGfxRect.Width, TrackNameGfxRect.Height); trackNameRect.X = BaseGame.Width - trackNameRect.Right; ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor); Rectangle tachoRect = BaseGame.CalcRectangle1600( 10, 10, TachoGfxRect.Width, TachoGfxRect.Height); tachoRect.X = BaseGame.Width - tachoRect.Right; tachoRect.Y = BaseGame.Height - tachoRect.Bottom; #endif // Rest can stay the same because we use the rectangles from now on ingame.RenderOnScreen(tachoRect, TachoGfxRect, baseUIColor); // Ok, now add the numbers, text and speed values TextureFontBigNumbers.WriteNumber( lapsRect.X + BaseGame.XToRes1600(15), lapsRect.Y + BaseGame.YToRes1200(12), lapNumber); // Current and best game times Color highlightColor = new Color(255, 185, 80); int blockHeight = BaseGame.YToRes1200(74); TextureFont.WriteGameTime( timesRect.X + BaseGame.XToRes1600(154), timesRect.Y + blockHeight / 2 - TextureFont.Height / 2, currentGameTime, highlightColor); TextureFont.WriteGameTime( timesRect.X + BaseGame.XToRes1600(154), timesRect.Y + timesRect.Height / 2 + blockHeight / 2 - TextureFont.Height / 2, bestLapTime, Color.White); // Track name TextureFont.WriteTextCentered( trackNameRect.X + trackNameRect.Width / 2, trackNameRect.Y + blockHeight / 2, trackName); Rectangle top5Rect1 = BaseGame.CalcRectangle1600( 10, 4, Best5GfxRect.Width, Best5GfxRect.Height); top5Rect1.X = trackNameRect.X; int top5Distance = top5Rect1.Y; top5Rect1.Y += trackNameRect.Bottom; Rectangle top5Rect2 = new Rectangle(top5Rect1.X, top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); Rectangle top5Rect3 = new Rectangle(top5Rect1.X, top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); Rectangle top5Rect4 = new Rectangle(top5Rect1.X, top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); Rectangle top5Rect5 = new Rectangle(top5Rect1.X, top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height); int index = 0; RankEntry[] ents = new RankEntry[players.Count + 1]; foreach (var e in players) { ents[index].Progress = e.Value.CompletionProgress; ents[index].ID = e.Value.ID; ents[index++].Name = e.Value.Name; } ents[index].Progress = RacingGameManager.Player.GetCompletionProgress(); ents[index].ID = RacingGameManager.LocalUID; ents[index].Name = RacingGameManager.LocalPlayerName; Array.Sort(ents, RankComparision); if (ents.Length > 0) { // Top 5 ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor); Color rankColor = ents[0].ID == RacingGameManager.LocalUID ? highlightColor : Color.White; TextureFont.WriteTextCentered( top5Rect1.X + BaseGame.XToRes(32) / 2, top5Rect1.Y + blockHeight / 2, "1.", rankColor, 1.0f); TextureFont.WriteText( top5Rect1.X + BaseGame.XToRes(35 + 15), top5Rect1.Y + blockHeight / 2 - TextureFont.Height / 2, ents[0].Name, rankColor); if (ents.Length > 1) { rankColor = ents[1].ID == RacingGameManager.LocalUID ? highlightColor : Color.White; TextureFont.WriteTextCentered( top5Rect2.X + BaseGame.XToRes(32) / 2, top5Rect2.Y + blockHeight / 2, "2.", rankColor, 1.0f); TextureFont.WriteText( top5Rect2.X + BaseGame.XToRes(35 + 15), top5Rect2.Y + blockHeight / 2 - TextureFont.Height / 2, ents[1].Name, rankColor); ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor); if (ents.Length > 2) { rankColor = ents[2].ID == RacingGameManager.LocalUID ? highlightColor : Color.White; TextureFont.WriteTextCentered( top5Rect3.X + BaseGame.XToRes(32) / 2, top5Rect3.Y + blockHeight / 2, "3.", rankColor, 1.0f); TextureFont.WriteText( top5Rect3.X + BaseGame.XToRes(35 + 15), top5Rect3.Y + blockHeight / 2 - TextureFont.Height / 2, ents[2].Name, rankColor); ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor); if (ents.Length > 3) { rankColor = ents[3].ID == RacingGameManager.LocalUID ? highlightColor : Color.White; TextureFont.WriteTextCentered( top5Rect4.X + BaseGame.XToRes(32) / 2, top5Rect4.Y + blockHeight / 2, "4.", rankColor, 1.0f); TextureFont.WriteText( top5Rect4.X + BaseGame.XToRes(35 + 15), top5Rect4.Y + blockHeight / 2 - TextureFont.Height / 2, ents[3].Name, rankColor); ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor); if (ents.Length > 4) { rankColor = ents[4].ID == RacingGameManager.LocalUID ? highlightColor : Color.White; TextureFont.WriteTextCentered( top5Rect5.X + BaseGame.XToRes(32) / 2, top5Rect5.Y + blockHeight / 2, "5.", rankColor, 1.0f); TextureFont.WriteText( top5Rect5.X + BaseGame.XToRes(35 + 15), top5Rect5.Y + blockHeight / 2 - TextureFont.Height / 2, ents[4].Name, rankColor); ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor); } } } } } Viewport vp = RacingGameManager.graphicsManager.GraphicsDevice.Viewport; var rp = RacingGameManager.RemotePlayers; foreach (var e in rp) { Matrix trans = e.Value.Transform; Vector3 pos = trans.Translation + trans.Up * 2.8f; Vector3 screnPos = vp.Project(pos, BaseGame.ProjectionMatrix, BaseGame.ViewMatrix, Matrix.Identity); if (screnPos.Z > 0 && screnPos.Z < 0.985f) { Vector2 size = nameFont.MeasureString(e.Value.Name); screnPos.X -= size.X * 0.5f; screnPos.Y -= size.Y * 0.5f; TextureFont.WriteText((int)screnPos.X, (int)screnPos.Y, e.Value.Name); //nameBatch.DrawString(nameFont, e.Value.Name, new Vector2(pos.X, pos.Y), Color.White); } } //// Acceleration //Point tachoPoint = new Point( // tachoRect.X + // BaseGame.XToRes1600(194), // tachoRect.Y + // BaseGame.YToRes1200(194)); ////ingame.RenderOnScreenWithRotation( //// tachoPoint, TachoArrowGfxRect, -acceleration*2); //if (acceleration < 0) // acceleration = 0; //if (acceleration > 1) // acceleration = 1; //float rotation = -2.33f + acceleration * 2.5f; //int tachoArrowWidth = BaseGame.XToRes1600(TachoArrowGfxRect.Width); //int tachoArrowHeight = BaseGame.YToRes1200(TachoArrowGfxRect.Height); //Vector2 rotationPoint = new Vector2( // TachoArrowGfxRect.Width / 2, // TachoArrowGfxRect.Height - 13); //ingame.RenderOnScreenWithRotation( // new Rectangle(tachoPoint.X, tachoPoint.Y, // tachoArrowWidth, tachoArrowHeight), // TachoArrowGfxRect, // rotation, rotationPoint); // Speed in mph TextureFontBigNumbers.WriteNumber( tachoRect.X + BaseGame.XToRes1600(TachoMphGfxRect.X), tachoRect.Y + BaseGame.YToRes1200(TachoMphGfxRect.Y), TachoMphGfxRect.Height, (int)Math.Round(speed * 0.8f)); //// Gear //TextureFontBigNumbers.WriteNumber( // tachoRect.X + BaseGame.XToRes1600(TachoGearGfxRect.X), // tachoRect.Y + BaseGame.YToRes1200(TachoGearGfxRect.Y), // TachoGearGfxRect.Height, // Math.Min(5, gear)); }
int RankComparision(RankEntry a, RankEntry b) { return(a.Progress.CompareTo(b.Progress)); }