/// <summary> /// Get leaderboard data relative to a username. /// </summary> /// <param name="platform">Platform to get leaderboards for</param> /// <param name="time">Length of time to return leaderboard data for</param> /// <param name="type">Type of mode to search for</param> /// <param name="mode">Gamemode to get leaderboard data for</param> /// <param name="username">User to find on leaderboards</param> /// <returns>Leaderboard data</returns> public static Leaderboards.Data GetLeaderboards(Platform platform, Time time, Type type, Gamemode mode, string username) { using (var client = new HttpClient()) { //Business logic if (type == Type.Arena && !IsValidArenaMode(mode)) { throw new CODException($"Mode {mode.ToString()} is not a valid Arena mode."); } if (type == Type.Hardcore && !IsValidHardcoreMode(mode)) { throw new CODException($"Mode {mode.ToString()} is not a valid Hardcore mode."); } var response = client.GetAsync($"{Utilities.BO3_LEADERBOARDS_URL}platform/{platform.GetDescription()}/time/{time.GetDescription()}/type/{type.GetDescription()}/mode/{mode.GetDescription()}/gamer/{username}/").Result; if (response.StatusCode != HttpStatusCode.OK) { throw new Exception($"Bad response {response.StatusCode}"); } var responseData = response.Content.ReadAsStringAsync().Result; if (Utilities.ValidResponse(responseData)) { return(JsonConvert.DeserializeObject <Leaderboards>(responseData).data); } dynamic data = JsonConvert.DeserializeObject(responseData); throw new CODException(data.data.message.ToString()); } }
//Pre-Setup, Server also starts in awake so any data requiring server info is after Awake() private void Awake() { Initialize(); //Output Gamemode Details to Log System.Console.Write("Current Gamemode: " + gamemode.ToString() + "\n"); }
protected override void Init() { base.Init(); switch (Gamemode) { case Type.Rush: MaxTimer = 10; PointsToAdd = 5; break; case Type.Rush_Crazy: MaxTimer = 6; PointsToAdd = 10; break; case Type.Rush_Insane: MaxTimer = 3; PointsToAdd = 20; break; default: Debug.LogError("Gamemode: " + Gamemode.ToString() + " is NOT handled in rush script!"); break; } SetUp(); }
private void AddProgressField(int?oldRank, int?newRank, Gamemode gamemode) { if (oldRank != null && newRank != null && oldRank != newRank) { int difference = oldRank.Value - newRank.Value; AddField($"Progress in {gamemode.ToString().ToUpperInvariant()}:", $"#{oldRank} => #{newRank} ({(difference >= 0 ? "↗️" : "↘️")} {difference})"); } }
/// <summary> /// Draws the room list button. /// </summary> /// <param name="top">The distance to the top border of the screen</param> /// <param name="roomInfo">The room information.</param> void DrawRoomListButton(float top, RoomInfo roomInfo) { //Receive the map and mode data from the rooms custom properties string map = (string)roomInfo.CustomProperties[RoomProperty.Map]; Gamemode mode = (Gamemode)((int)roomInfo.CustomProperties[RoomProperty.Mode]); //Create the rect where the button should be drawn Rect buttonRect = new Rect(40, top, Screen.width - 80, 40); //Is the user hovering the button? bool isMouseOver = buttonRect.Contains(Event.current.mousePosition); //I first draw an empty button here, because it's contents should be nicely formated //If I'd draw the content in this button, I could only type one long text string and //it wouldn't look very nice //But this is still the button that responds to the player click and joins the room if this happens if (GUI.Button(buttonRect, "", Styles.DarkButton)) { m_IsJoiningRoom = true; m_JoinRoomName = roomInfo.Name; PhotonNetwork.JoinRoom(roomInfo.Name); } //Now we fake a mouse over color change for our button content //since the content isn't actually part of the Unity button, we have to do this ourselves if (isMouseOver == true) { GUI.color = new Color(1f, 0.8f, 0f); } else { GUI.color = Color.white; } //Create a GUILayout area at the same position we drew the button GUILayout.BeginArea(buttonRect); { //And draw all the content nicely spaced out so that multiple buttons will have the //different texts starting at the same x-position. That'll look way nicer in a big list GUILayout.BeginHorizontal(); { GUILayout.Space(20); GUILayout.Label(roomInfo.Name, Styles.LabelSmall, GUILayout.Width(RoomNameWidth), GUILayout.Height(buttonRect.height)); GUILayout.Label(roomInfo.PlayerCount + "/" + roomInfo.MaxPlayers, Styles.LabelSmall, GUILayout.Width(RoomPlayerWidth), GUILayout.Height(buttonRect.height)); GUILayout.Label(mode.ToString(), Styles.LabelSmall, GUILayout.Width(RoomModeWidth), GUILayout.Height(buttonRect.height)); GUILayout.Label(map, Styles.LabelSmall, GUILayout.Width(RoomMapWidth), GUILayout.Height(buttonRect.height)); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); GUI.color = Color.white; }
public void SetGamemode(Gamemode target, bool silent) { Gamemode = target; new PlayerListItem(Wrapper) { Action = 1, Gamemode = Gamemode, Uuid = Uuid }.Broadcast(Level); new ChangeGameState(Wrapper) { Reason = GameStateReason.ChangeGameMode, Value = (float)target }.Write(); if (!silent) { ConsoleFunctions.WriteInfoLine(Username + "'s gamemode was changed to " + target.ToString("D")); SendChat("Your gamemode was changed to " + target.ToString(), ChatColor.Yellow); } }
protected override void Init() { base.Init(); switch (Gamemode) { case Type.TimeAttack_Short: MaxScore = 25; break; case Type.TimeAttack: MaxScore = 50; break; case Type.TimeAttack_Long: MaxScore = 100; break; default: Debug.LogError("Gamemode: " + Gamemode.ToString() + " is NOT handled in timeattack script!"); break; } SetUp(); }
public void SetGamemode(Gamemode target, bool silent) { Gamemode = target; new PlayerListItem(Wrapper) { Action = 1, Gamemode = Gamemode, Uuid = Uuid }.Broadcast(Level); new ChangeGameState(Wrapper) { Reason = GameStateReason.ChangeGameMode, Value = (float) target }.Write(); if (!silent) { ConsoleFunctions.WriteInfoLine(Username + "'s gamemode was changed to " + target.ToString("D")); SendChat("Your gamemode was changed to " + target.ToString(), ChatColor.Yellow); } }
public string GetSelectorString() { var elements = new List <string>(); var result = String.Empty; if (selectorType == SelectorType.SINGLE) { if (entityType == EntityType.Player) { result = "@p"; } else { result = "@e"; elements.Add("c=1"); } } else if (selectorType == SelectorType.MULTIPLE) { if (entityType == EntityType.Player) { result = "@a"; } else { result = "@e"; } if (count != null) { elements.Add("c=" + count); } } else if (selectorType == SelectorType.RANDOM) { result = "@r"; if (count != null) { elements.Add("count=" + count); } } if (name != null) { elements.Add("name=" + name); } if (team != null) { elements.Add("team=" + team); } if (entityType != EntityType.Player && entityType != EntityType.ANY) { elements.Add("type=" + entityType.ToString()); } if (experienceMin != null) { elements.Add("lm=" + experienceMin); } if (experienceMax != null) { elements.Add("l=" + experienceMax); } if (gamemode != Gamemode.ANY) { elements.Add("m=" + gamemode.ToString().ToLower()); } if (x != null && y != null && z != null) { elements.Add("x=" + x); elements.Add("y=" + y); elements.Add("z=" + z); } if (dx != null && dy != null && dz != null) { elements.Add("dx=" + dx); elements.Add("dy=" + dy); elements.Add("dz=" + dz); } if (minRadius != null) { elements.Add("rm=" + minRadius); } if (maxRadius != null) { elements.Add("r=" + maxRadius); } if (rotationMinX != null) { elements.Add("rxm=" + rotationMinX); } if (rotationMaxX != null) { elements.Add("rx=" + rotationMaxX); } if (rotationMinY != null) { elements.Add("rym=" + rotationMinY); } if (rotationMaxY != null) { elements.Add("ry=" + rotationMaxY); } if (tag != null) { elements.Add("tag=" + tag); } foreach (var scoreName in scores.Keys) { var score = scores[scoreName]; if (score.min != null) { elements.Add("score_" + scoreName + "_min=" + score.min); } if (score.max != null) { elements.Add("score_" + scoreName + "=" + score.max); } } if (elements.Count > 0) { result += "[" + String.Join(",", elements) + "]"; } return(result); }
public override string ToString() { return(Name + " (" + Mode.ToString() + ")"); }
/// <summary> /// Chages what map will be played for the round will be /// </summary> /// <param name="b"></param> public void ChangeGametype(bool gametypeBool) { if (gametypeBool) { if (m_ModeCount < ServerOptions.AvailableModes.Length) { m_ModeCount++; if (m_ModeCount > (ServerOptions.AvailableModes.Length - 1)) { m_ModeCount = 0; } } } else { if (m_ModeCount < ServerOptions.AvailableModes.Length) { m_ModeCount--; if (m_ModeCount < 0) { m_ModeCount = ServerOptions.AvailableModes.Length - 1; } } } m_SelectedMode = ServerOptions.AvailableModes[m_ModeCount]; MapNameText.text = "Mode: "+ m_SelectedMode.ToString(); }