public void TakeInput() { if (!ValidateInputs()) { return; } InvalidText.gameObject.SetActive(false); BigInteger bounty = new BigInteger(Bounty.CurrentValue) * new BigInteger(1e18); BigInteger entryFee = new BigInteger(EntryFee.CurrentValue) * new BigInteger(1e18); double start = Utils.Time.ToUnixTime(startDatePicker.fecha); double end = Utils.Time.ToUnixTime(endDatePicker.fecha); double duration = (endDatePicker.fecha - startDatePicker.fecha).TotalSeconds; MatryxRound.RoundDetails roundDetails = new MatryxRound.RoundDetails() { Start = new BigInteger(start), Duration = new BigInteger(duration), Bounty = bounty, Review = 60 * 60 * 24 * 14 }; MatryxTournament tournament = new MatryxTournament(Title.text, Description.text, null, "math", bounty, entryFee, roundDetails); resultsMenu.GetComponent <ResultsMenu>().Start(); Async.runInCoroutine(delegate(Async thread, object param) { return(tournament.create(delegate(object result) { // Check success if ((bool)result) { StatisticsTracking.EndEvent("Matryx", "Tournament Creation"); ResultsMenu.Instance.PostSuccess(tournament, (nothin) => { Instance.ClearInputs(true); TournamentsMenu.Instance.ReloadTournaments(0); } ); } else { ResultsMenu.Instance.PostFailure(tournament); } })); }); this.gameObject.SetActive(false); resultsMenu.SetActive(true); }
public void MakeSubmission() { var title = TitleField.text; if (!TitleField.gameObject.GetComponent <InputValidator>().isValid) { InvalidLabel.gameObject.SetActive(true); return; } this.gameObject.SetActive(false); InvalidLabel.gameObject.SetActive(false); var submission = new MatryxSubmission(tournament, title, "", DescriptionField.text, SerializeSurface(), Convert.ToInt32(ValueField.text)); clearInputs(); resultsCanvasObject.SetActive(true); gameObject.SetActive(false); Async.runInCoroutine(delegate(Async thread, object param) { return(submission.submit(delegate(object result) { // Debug Debug.Log("Submission uploaded"); Debug.Log(result); // Check success if ((bool)result) { StatisticsTracking.EndEvent("Matryx", "Submission Creation"); ResultsMenu.Instance.PostSuccess(submission, (nothin) => { TournamentMenu.Instance.ReloadSubmissions(3f); } ); } else { ResultsMenu.Instance.PostFailure(submission); } })); }); }
public virtual void UnpressButton(GameObject other) { #if UNITY_EDITOR if (verbose) { print("button released"); } #endif if (OnButtonExit != null) { OnButtonExit.Invoke(other); } string eventName = gameObject.name; if (!eventName.Equals("Body")) { StatisticsTracking.EndEvent("Button Press", eventName); } }
void OnDisable() { StatisticsTracking.EndEvent("Tool Switching", "To Drawing Tool"); leftController.components[ButtonId.TRIGGER].ComponentPressing += startDrawing; leftController.components[ButtonId.TRIGGER].ComponentUnpressed += stopDrawing; leftController.components[ButtonId.GRIP].ComponentPressed += startErasing; leftController.components[ButtonId.GRIP].ComponentPressing += startErasing; leftController.components[ButtonId.GRIP].ComponentUnpressed += stopErasing; rightController.components[ButtonId.TRIGGER].ComponentPressing += startDrawing; rightController.components[ButtonId.TRIGGER].ComponentUnpressed += stopDrawing; rightController.components[ButtonId.GRIP].ComponentPressed += startErasing; rightController.components[ButtonId.GRIP].ComponentPressing += startErasing; rightController.components[ButtonId.GRIP].ComponentUnpressed += stopErasing; leftController.transform.Find("Pen").gameObject.SetActive(false); rightController.transform.Find("Pen").gameObject.SetActive(false); leftController.transform.Find("Controller (right)").Find("PenLabel").gameObject.SetActive(false); rightController.transform.Find("Controller (left)").Find("PenLabel").gameObject.SetActive(false); }
protected override void StateChanged(int _old, int _new, GameObject source = null) { if (_new == -1) { transform.Find("Body").GetComponent <Renderer>().material.color = disabledColor; } else if (_new == 1) { transform.Find("Body").GetComponent <Renderer>().material.color = hoveringColor; string eventName = "Unknown"; if (gameObject != null) { eventName = gameObject.name; } if (!eventName.Equals("Body")) { StatisticsTracking.StartEvent("Button Hover", eventName); } } else if (_new == 2) { transform.Find("Body").GetComponent <Renderer>().material.color = selectedColor; } else { transform.Find("Body").GetComponent <Renderer>().material.color = passiveColor; string eventName = "Unknown"; if (gameObject != null) { eventName = gameObject.name; } if (!eventName.Equals("Body") && _old == 1) { StatisticsTracking.EndEvent("Button Hover", eventName); } } }
public void FireSelectWinners() { Async.runInCoroutine(delegate(Async thread, object param) { var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList(); return(TournamentMenu.Tournament.selectWinners(submissions, distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.DoNothing), BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, delegate(object result) { Debug.Log((bool)result ? "Successfully selected winners!" : "Winner selection unsuccessful."); SpinForTheWin(false); SetButtonsEnabled(true); PressButton("WinnersOnlyButton"); if ((bool)result) { StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>() { { "success", true } }); Tippies.SpawnTippy("Winner Selection Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); TournamentMenu.Tournament.currentRound.winningSubmissions = winningSubmissions; TournamentMenu.Instance.ProcessRound(TournamentMenu.Tournament.currentRound); Close(); TournamentMenu.Instance.actionState = TournamentMenu.ActionState.ManageTournament; TournamentMenuCenterButton.Instance.updateState(); } else { StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>() { { "success", false } }); Tippies.SpawnTippy("Winner Selection Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); } })); }); }
public void FireCloseTournament() { if (TournamentMenu.Tournament.currentRound.winningSubmissions.Count == 0) { Async.runInCoroutine(delegate(Async thread, object param) { var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList(); return(TournamentMenu.Tournament.selectWinners(submissions, distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.CloseTournament), BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, BigInteger.Zero, delegate(object result) { Debug.Log((bool)result ? "Successfully closed the tournament!" : "Close tournament unsuccessful."); SpinForTheClose(false); PressButton("CloseTournamentButton"); if ((bool)result) { StatisticsTracking.EndEvent("Matryx", "Winner Selection & Tournament Close", new Dictionary <string, object>() { { "success", true } }); Tippies.SpawnTippy("Close Tournament Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); Close(); TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction; TournamentMenuCenterButton.Instance.updateState(); } else { StatisticsTracking.EndEvent("Matryx", "Winner Selection Only", new Dictionary <string, object>() { { "success", false } }); Tippies.SpawnTippy("Close Tournament Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); } })); }); } else { Async.runInCoroutine(delegate(Async thread, object param) { var submissions = winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList(); return(TournamentMenu.Tournament.closeTournament( delegate(object result) { Debug.Log((bool)result ? "Successfully closed the tournament!" : "Close tournament unsuccessful."); SetButtonsEnabled(true); SpinForTheClose(false); if ((bool)result) { StatisticsTracking.EndEvent("Matryx", "Tournament Close Only", new Dictionary <string, object>() { { "success", true } }); Tippies.SpawnTippy("Close Tournament Transaction Successful", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 5f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); buttons["CloseButton"].transform.Find("Body").GetComponent <RayCastButton>().PressButton(null); Close(); TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction; TournamentMenuCenterButton.Instance.updateState(); } else { StatisticsTracking.EndEvent("Matryx", "Tournament Close Only", new Dictionary <string, object>() { { "success", false } }); Tippies.SpawnTippy("Close Tournament Transaction Failed", 4f, TMPro.TextAlignmentOptions.Center, new Vector3(1f, 0.25f, 0.05f), 15f, AvatarSelector.centerEye, new Vector3(0f, 0f, 0.4f), 0.5f, 0.5f, Tippy.MovementMode.Soft, true); } })); }); } }
public IEnumerator runCreateRound() { InvalidLabel.gameObject.SetActive(false); if (!InputsValid().Equals(string.Empty)) { yield break; } gameObject.SetActive(false); InvalidLabel.gameObject.SetActive(false); resultsCanvasObject.SetActive(true); var start = new BigInteger(Utils.Time.ToUnixTime(startDatePicker.fecha)); var duration = new BigInteger((endDatePicker.fecha - startDatePicker.fecha).TotalSeconds); var reviewDuration = new BigInteger((reviewEndDatePicker.fecha - endDatePicker.fecha).TotalSeconds); var bounty = new BigInteger(Convert.ToDecimal(bountyPicker.CurrentValue)); MatryxRound.RoundDetails details = new MatryxRound.RoundDetails() { Start = start, Duration = duration, Review = reviewDuration, Bounty = bounty * new BigInteger(1e18) }; MatryxRound newRound = new MatryxRound(tournament.currentRound.index + 1, details); newRound.tournament = TournamentMenu.Tournament; ManageTournamentMenu.SetButtonsEnabled(false); resultsMenu.SetStatus("Checking MTX balance and platform allowance..."); var allowance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.allowance(NetworkSettings.currentAddress, MatryxPlatform.address)); yield return(allowance); var balance = new Utils.CoroutineWithData <BigInteger>(MatryxCortex.Instance, MatryxToken.balanceOf(NetworkSettings.currentAddress)); yield return(balance); if (balance.result < details.Bounty) { ResultsMenu.Instance.SetStatus("Insufficient MTX. Please visit <link=https://app.matryx.ai/><u>our Matryx Dapp</u></link> for MTX Tokens.", true); ResultsMenu.Instance.ReturnToCalcflowAfterSeconds(8f); yield break; } if (allowance.result < details.Bounty) { ResultsMenu.Instance.SetStatus("Approving MatryxPlatform for " + bounty + " MTX..."); if (allowance.result != BigInteger.Zero) { var approveZero = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, BigInteger.Zero)); yield return(approveZero); if (!approveZero.result) { resultsMenu.PostFailure(newRound, "Failed to reset the platform allowance to zero"); yield break; } } var approveBounty = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, MatryxToken.approve(MatryxPlatform.address, details.Bounty)); yield return(approveBounty); if (!approveBounty.result) { resultsMenu.PostFailure(newRound, "Failed to give the platform an MTX allowance"); yield break; } } resultsMenu.SetStatus("Adding to Tournament bounty..."); var addToBountyCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, TournamentMenu.Tournament.addToBounty(details.Bounty)); yield return(addToBountyCoroutine); if (!addToBountyCoroutine.result) { resultsMenu.PostFailure(newRound, "Could not add to tournament bounty"); yield break; } resultsMenu.SetStatus("Creating new round..."); var submissions = ManageTournamentMenu.winningSubmissions.Select(sub => Utils.HexStringToByteArray(sub.hash)).ToList(); if (TournamentMenu.Tournament.currentRound.winningSubmissions.Count == 0) { IEnumerator selectWinnersCoroutine = tournament.selectWinners(submissions, ManageTournamentMenu.distribution, new BigInteger((int)MatryxTournament.SelectWinnerAction.StartNextRound), details.Start, details.Duration, details.Review, details.Bounty); var selectWinnersDataCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, selectWinnersCoroutine); yield return(selectWinnersDataCoroutine); ClearInputs(); gameObject.SetActive(false); ManageTournamentMenu.SetButtonsEnabled(true); ManageTournamentMenu.Instance.PressButton("NewRoundButton"); ResultsMenu.transactionObject = newRound; Debug.Log((bool)selectWinnersDataCoroutine.result ? "Successfully created new round!" : "Round creation unsuccessful."); if (selectWinnersDataCoroutine.result) { StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>() { { "success", true } }); tournament.currentRound = newRound; resultsMenu.PostSuccess(newRound, delegate(object nothin) { TournamentMenu.Instance.SetRound(newRound.index); TournamentMenu.Instance.UpdateActionState(); ManageTournamentMenu.Close(); TournamentMenu.Instance.actionState = TournamentMenu.ActionState.NoAction; TournamentMenuCenterButton.Instance.updateState(); }); } else { StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>() { { "success", false } }); resultsMenu.PostFailure(newRound, "Failed to create new round"); } } else { resultsMenu.SetStatus("Updating next round..."); IEnumerator updateNextRoundCoroutine = tournament.updateNextRound(details); var updateNextRoundDataCoroutine = new Utils.CoroutineWithData <bool>(MatryxCortex.Instance, updateNextRoundCoroutine); yield return(updateNextRoundDataCoroutine); ClearInputs(); gameObject.SetActive(false); ManageTournamentMenu.SetButtonsEnabled(true); ManageTournamentMenu.Instance.PressButton("NewRoundButton"); if (updateNextRoundDataCoroutine.result) { StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>() { { "success", true } }); tournament.currentRound = newRound; resultsMenu.PostSuccess(newRound, (nothin) => { TournamentMenu.Instance.actionState = TournamentMenu.ActionState.ManageTournament; TournamentMenuCenterButton.Instance.updateState(); }); } else { StatisticsTracking.EndEvent("Matryx", "New Round Creation", new Dictionary <string, object>() { { "success", false } }); resultsMenu.PostFailure(newRound, "Failed to create new round"); } } }