public static void Save(Leaderboards data) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/leaderboards.data"); bf.Serialize(file, data); }
private static void OwnScoresLoop(int count, int points, Action finished) { Thread.Sleep(500); points += 1000; count++; var score = new PlayerScore { playername = "test account", playerid = "*****@*****.**", table = "personal" + rnd, points = points, highest = true, allowduplicates = true, fields = { { "rnd", rnd } } }; Leaderboards.Save(score, r => { if (count < 9) { OwnScoresLoop(count, points, finished); return; } finished(); }); }
/// submit a score to the leaderboards, /// updating the client on a response static void SubmitScore(float time) { // The Leaderboards to submit our time to Leaderboards leaderboards = new Leaderboards(); // The score to submit string ourName = GamerTagManager.GetGamerTag(); string theirName = MultiPlayerController.Instance.theirName; int tenthSeconds = ClockController.SecondsToTenthsOfSeconds(time); Score score = new Score(tenthSeconds, ourName, theirName); // Submit the time the the leaderboards, and send a message // to the client upon response leaderboards.SubmitScoreAsync(SceneManager.opts.level, score, delegate(SubmissionResponse r, ServerException e) { if (e != null) { UILogger.Log(e.Message); } position = (byte)r.position; positionSet = true; updateManager.SendLeaderboardsUpdate(position); }); }
internal void UpdateTwitchStatus(bool vocal) { TwitchStatus.GetStatus(); if (ConfigInstance.ViewerPBEnabled) { ViewerPb.UpdateViewerPB(TwitchStatus.LastViewers); } if (ConfigInstance.LeaderboardsEnabled && !Leaderboards.GameOverride) { Leaderboards.CurrentGame = TwitchStatus.game; } if (ConfigInstance.LeaderboardsAutodetectCategory && TwitchStatus.isOnline) { if (TwitchStatus.TitleHasChanged || !Leaderboards.LastUpdateSuccessful || vocal) { Leaderboards.SetPreferedCategory(TwitchStatus.OldTitle, SuiBotInstance.IsAfterFirstStatusUpdate, vocal); } } if (vocal) { SendChatMessage(string.Format("New obtained stream status is {0}{1}.", TwitchStatus.isOnline == false ? "offline" : "online", TwitchStatus.game == "" ? "" : " and game is " + TwitchStatus.game )); } }
private void Awake() { entryContainer = transform.Find("Leaderboard Entry Container"); entryTemplate = entryContainer.Find("Leaderboard Entry Template"); entryTemplate.gameObject.SetActive(false); string jsonString = PlayerPrefs.GetString("Leaderboards"); if (jsonString.Equals("")) { ResetLeaderboard(); jsonString = PlayerPrefs.GetString("Leaderboards"); } Leaderboards leaderboards = JsonUtility.FromJson <Leaderboards>(jsonString); leaderboards.entries.Sort(); leaderboardEntryTransforms = new List <Transform>(); for (int i = 0; i < (leaderboards.entries.Count > 10 ? 10 : leaderboards.entries.Count); ++i) { CreateLeaderboardEntry(leaderboards.entries[i], entryContainer, leaderboardEntryTransforms); } gameObject.SetActive(false); }
public void AsyncUnableToConnectToServer() { // Test that if the server is unreachable, an error returned // And make sure that even if the request fails, the response is // still valid lb = new Leaderboards("localhost", 9999); ServerException ex = null; ScoresResponse? r = null; lb.RequestScoresAsync(uniqueLevelName, delegate(ScoresResponse response, ServerException error) { r = response; ex = error; callbackDone.Set(); }); callbackDone.WaitOne(); // make sure an error was returned Assert.NotNull(ex); // make sure the response is valid Assert.IsTrue(r.HasValue); Assert.AreEqual(r.Value.level, uniqueLevelName); Assert.IsNull(r.Value.leaders); }
static void Main(string[] args) { Riddlersoft.Core.Switch.NSwitch.Init(); // Console.Clear(); Leaderboards.Initalize(0x28BA8400, "ca527321"); if (Riddlersoft.Core.Switch.NSwitch.IsNSAAccount()) { Console.WriteLine("Yey you can play"); } else { Console.WriteLine("Bhoo go away!"); } // Leaderboards.Load(); CategoryHelper.AddCategory("test", 0, SortOrder.Accending); Leaderboards.UploadScore(NSwitch.GetNickName(), 15000, "test", 0); //return; List <HighScore> scores = Leaderboards.GetScores("test", SortOrder.Accending, LeaderboardFilter.RANGE_RANKING, 0, 100); Console.WriteLine("===============HIGHSCORE============="); Console.WriteLine("Leaderboard One"); for (int i = 0; i < scores.Count; i++) { Console.WriteLine($"{i}: {scores[i].CommonDataUserName}: {scores[i].Score}"); } return; }
void OnEnable() { playerController.IncreaseScore += OnScoreIncrease; playerController.PlayerDead += OnPlayerDead; MainMenuContainer.SetActive(true); newScoreObj.SetActive(false); ScoreBoard.SetActive(false); hudmenu.SetActive(false); Leaderboards.SetActive(false); LeaderboardSubmit.SetActive(false); //on game end scoreboard menu ,if user presses on restart , //we need to disable the mainmenu and changing player to readyto play. if (isRestartPressed) { MainMenuContainer.SetActive(false); isRestartPressed = false; readyToPlay = true; hudmenu.SetActive(true); playerController.currentState = playerController.playerStates.alive; } else { playerController.currentState = playerController.playerStates.idle; } scoreTextMesh.text = "" + 0; }
public bool IsHit(int level) { this.lastHitProgress = this.progress; if (this.TypeEnum == TBSUi.HitType.right) { this.lastHitProgress = this.totalWith - this.lastHitProgress; } int num = this.hitAreaLeft + this.hitAreaWith; Log.Info("lastHitProgress: " + this.lastHitProgress); Log.Info(string.Concat(new object[] { "hitAreaLeft: ", this.hitAreaLeft, "max", num })); bool flag = this.lastHitProgress >= (float)(this.hitAreaLeft - 1) && this.lastHitProgress <= (float)num; if (flag) { this.lastHitProgress = -1f; this.SetDifficulty(level); if (App.State.Statistic.TBSScore < App.State.Crits.Score(App.State.GameSettings.TBSEyesIsMirrored) + 1) { App.State.Statistic.TBSScore = App.State.Crits.Score(App.State.GameSettings.TBSEyesIsMirrored) + 1; Leaderboards.SubmitStat(LeaderBoardType.TBSScore, App.State.Crits.Score(App.State.GameSettings.TBSEyesIsMirrored) + 1, false); } } return(flag); }
public void StartLeaderboards() { if (Leaderboards == null) { Leaderboards = gameObject.AddComponent <Leaderboards>(); } }
private void openHS_Click(object sender, RoutedEventArgs e) { Leaderboards leaderboard = new Leaderboards(); this.Close(); leaderboard.Show(); }
public static void AllScores(Action done) { const string section = "TestLeaderboards.AllScores"; Console.WriteLine(section); var options = new Hashtable { { "table", "scores" + rnd }, { "mode", "newest" }, { "perpage", 2 } }; Leaderboards.List(options, (scores, numscores, r) => { scores = scores ?? new List <PlayerScore>(); AssertTrue(section, "Request succeeded", r.success); AssertEquals(section, "No errorcode", r.errorcode, 0); AssertTrue(section, "Received scores", scores.Count > 0); AssertTrue(section, "Received numscores", numscores > 0); if (scores.Count > 1) { AssertTrue(section, "First score is newer or equal to second", scores[0].date >= scores[1].date); } else { AssertTrue(section, "First score is newer or equal to second forced failure", false); } done(); }); }
public static void Construct() { Configuration = new Configuration(); Configuration.Initialize(); _logger = new Logger(); Logger.Log($"ENV: {(Utils.IsLinux ? "Linux" : "Windows")}"); Csv = new Csv(); Fingerprint = new Fingerprint(); _playerDb = new PlayerDb(); _replayDb = new ReplayDb(); _allianceDb = new AllianceDb(); _redis = new Redis(); Levels = new Levels(); PlayerCache = new Players(); AllianceCache = new Alliances(); LeaderboardCache = new Leaderboards(); ChatManager = new LogicGlobalChatManager(); Gateway = new Gateway(); StartDateTime = DateTime.UtcNow; Gateway.StartAsync().Wait(); }
void SortLeaderboard() { //reads from the leaderboard file string path = "Assets/TextFiles/Leaderboard.txt"; StreamReader r = new StreamReader(path); var temp = ""; //gets the number of things in the leaderboard var numberOfPlayers = Leaderboards.counter(); values = new string[numberOfPlayers]; ranking = new int[numberOfPlayers]; var score = 0; //parses the items and puts them in the correct integers for (int i = 0; i < numberOfPlayers; i++) { temp = r.ReadLine(); //if statement needed, otherwise the writer doesn't put the info in correctly if (temp != "") { split = temp.Split(char.Parse(" ")); score = int.Parse(split[1]); ranking[i] = score; values[i] = split[0]; } } r.Close(); }
private void OnEvent(byte eventcode, object content, int senderid) { //if (this.id != mainID) return; byte[] c = (byte[])content; //Debug.Log("Event Triggered: " + eventcode + " " + c[0]); if (eventcode == 0) //Player shot { NetworkPlayer sender; players.TryGetValue(c[0], out sender); if (sender == this) { return; } sender.gun.GetComponent <Gun>().NetworkShoot(); //return; } if (eventcode == 1) //Player was hit { //Debug.Log("Not yet Hits: " + c[1] + " " + c[0]); if (c[1] == mainID) { //Debug.Log("Hits: " + c[1] + " " + c[0]); this.Hit(c[0]); } return; } if (eventcode == 2) //Player was killed { Leaderboards.ReportKill(c[0], c[1]); return; } }
public static void FriendsScores(Action done) { const string section = "TestLeaderboards.FriendsScores"; Console.WriteLine(section); var playerids = new ArrayList() { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; FriendsScoresLoop(playerids, 0, () => { var list = new Hashtable { { "table", "friends" + rnd }, { "perpage", 3 }, { "friendslist", new ArrayList(new [] { "1", "2", "3" }) } }; Leaderboards.List(list, (scores, numscores, r2) => { scores = scores ?? new List <PlayerScore>(); AssertTrue(section, "Request succeeded", r2.success); AssertEquals(section, "No errorcode", r2.errorcode, 0); AssertTrue(section, "Received 3 scores", scores.Count == 3); AssertTrue(section, "Received numscores 3", numscores == 3); AssertTrue(section, "Player id #1", scores[0].playerid == "3"); AssertTrue(section, "Player id #2", scores[1].playerid == "2"); AssertTrue(section, "Player id #3", scores[2].playerid == "1"); done(); }); }); }
private static void FriendsScoresLoop(ArrayList playerids, int points, Action finished) { Thread.Sleep(500); points += 1000; var playerid = playerids [0].ToString(); playerids.RemoveAt(0); var score = new PlayerScore { playername = "playerid" + playerid, playerid = playerid, table = "friends" + rnd, points = points, highest = true, fields = { { "rnd", rnd } } }; Leaderboards.Save(score, r => { if (playerids.Count > 0) { FriendsScoresLoop(playerids, points, finished); return; } finished(); }); }
public ActionResult DeleteConfirmed(int id) { Leaderboards leaderboards = db.Leaderboards.Find(id); db.Leaderboards.Remove(leaderboards); db.SaveChanges(); return(RedirectToAction("Index")); }
public void UpdateScore(bool pressed) { //writes name and score into leaderboards. if (pressed) { Leaderboards.fileWriter(); } }
private void OnUpdateSucceeded(Leaderboards leaderboards) { if (_delayedUpdateCoroutine != null) { StopCoroutine(_delayedUpdateCoroutine); } _delayedUpdateCoroutine = StartCoroutine(DelayedUpdate(leaderboards)); }
private void CheckHighestPower(AfkyGame game) { if (App.State.Statistic.AfkyGodPower < game.Power.Level) { App.State.Statistic.AfkyGodPower = game.Power.Level; Leaderboards.SubmitStat(LeaderBoardType.AfkyGodPower, App.State.Statistic.AfkyGodPower.ToInt(), false); } }
void InitializeLeaderBoard() { leaderboards = new Leaderboards(); if (leaderboards.leaderboardItems == null) { leaderboards = new Leaderboards(MaxNumOfHighScores); } }
private void EndGame() { scoreText.text = ""; gameOver = true; endPanel.SetActive(true); thePlanker[plankerIndex].AddComponent <Rigidbody>(); Leaderboards.WriteEntry(leadboard, maxScore); StartCoroutine(updateScene()); }
override public void SavePlayerDistance(int distance) { _isReady = false; Leaderboards.WriteEntry( LONGEST_DISTANCE_LEADERBOARD_NAME , distance ).OnComplete(OnNewEntryAdded); }
// Start is called before the first frame update void Start() { startingPerfectTolerance = perfectTolerance; theLeaderboard = FindObjectOfType <Leaderboards>(); bonusStacks = false; stackHeight = startingStackHeight; // StartCoroutine(SetDeadzone()); r = Random.Range(0, 255); g = Random.Range(0, 255); b = Random.Range(0, 255); topStack.GetComponent <Renderer>().material.SetColor("_Color", CompColor()); theUIController = FindObjectOfType <UIController>(); theScoreManager = FindObjectOfType <ScoreManager>(); theLevelController = FindObjectOfType <LevelController>(); theAudioManager = FindObjectOfType <AudioManager>(); danceInitiated = false; danceTime = Random.Range(danceTimeMin, danceTimeMax); Application.targetFrameRate = 60; for (int i = 0; i < davesRigidbodies.Length; i++) { davesRigidbodies[i].isKinematic = true; } davesAnim = dave.GetComponent <Animator>(); stackOffset = startingStackOffset; stackCount = 0; restartPos = transform.position; currentStackWidth = startingStackWidth; currentStackLength = startingStackWidth; stackSpawned = false; if (!PlayerPrefs.HasKey("showCutscene") || PlayerPrefs.GetInt("showCutscene") == 1) { davesAnim.SetBool("ShowCutscene", true); } else if (PlayerPrefs.HasKey("showCutscene") && PlayerPrefs.GetInt("showCutscene") == 0) { davesAnim.SetBool("ShowCutscene", false); } /* var composer = theLevelController.vcam.GetCinemachineComponent<CinemachineComposer>(); * composer.m_DeadZoneWidth = 0f; * composer.m_DeadZoneHeight = 0f;*/ }
override protected void GetGlobalLeaderboard(int numberOfEntries) { Leaderboards .GetEntries( LONGEST_DISTANCE_LEADERBOARD_NAME , numberOfEntries , LeaderboardFilterType.None , LeaderboardStartAt.Top) .OnComplete(OnData); }
override protected void GetAroundMeLeaderboard(int numberOfEntries) { Leaderboards .GetEntries( LONGEST_DISTANCE_LEADERBOARD_NAME , numberOfEntries , LeaderboardFilterType.None , LeaderboardStartAt.CenteredOnViewer) .OnComplete(OnData); }
protected override void GetFriendsLeaderboard(int numberOfEntries) { Leaderboards .GetEntries( LONGEST_DISTANCE_LEADERBOARD_NAME , numberOfEntries , LeaderboardFilterType.Friends , LeaderboardStartAt.CenteredOnViewerOrTop) .OnComplete(OnData); }
internal Leaderboard(Leaderboards leaderboards, ulong leaderboard, string leaderboardName, int entryCount, ELeaderboardSortMethod sortMethod, ELeaderboardDisplayType displayType) { this._stats = Leaderboard.SteamUnityAPI_SteamUserStats(); this._leaderboards = leaderboards; this._leaderboard = leaderboard; this._leaderboardName = leaderboardName; this._entryCount = entryCount; this._sortMethod = sortMethod; this._displayType = displayType; }
public ActionResult Edit([Bind(Include = "LeaderboardsID,Name,TotalMarks")] Leaderboards leaderboards) { if (ModelState.IsValid) { db.Entry(leaderboards).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(leaderboards)); }
public void Die(int id) { GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().enabled = false; //stop moving Leaderboards.ReportKill(id, this.id); PhotonNetwork.RaiseEvent(2, new byte[] { (byte)id, (byte)this.id }, true, null); invulnurable = true; respawntime = RESPAWN_DELAY; //Color c = this.gameObject.GetComponentInChildren<Renderer>().material.color; //c.a = 0; //this.gameObject.GetComponentInChildren<Renderer>().material.color = c; }
void Start() { if (api == null) { api = GameObject.FindGameObjectWithTag("API").GetComponent<APIS>(); } if (leaderBoard == null) { leaderBoard = GameObject.FindGameObjectWithTag("Leaderboard").GetComponent<Leaderboards>(); } switch (Application.loadedLevel) { case(0): levelType = "mainMenu"; currentLevel = "MainMenu"; break; case (1): levelType = "Normal Mode"; currentLevel = "normalmode"; break; case (2): levelType = "Hard Mode"; currentLevel = "hardmode"; break; case (3): levelType = "Harder Mode"; currentLevel = "hardermode"; break; case (4): levelType = "Hardest Mode"; currentLevel = "hardestmode"; break; case (5): levelType = "Insane Mode"; currentLevel = "insanemode"; break; case (6): levelType = "mainMenu"; currentLevel = "MainMenu"; break; } }
public static string LeaderboardId(Leaderboards leaderboard) { return _leaderboardLookup[leaderboard]; }