Beispiel #1
0
    public void M6()
    {
        var activityManager = discord.GetActivityManager();

        activityManager.RegisterSteam(1229730);

        var activity = new Discord.Activity
        {
            State      = "Points: " + GameControlScript.AchievementPointsATM.ToString(),
            Details    = "Total Clicks: " + GameControlScript.AchievementClicks.ToString(),
            Timestamps =
            {
                Start = CurrentTime,
            },
            Assets =
            {
                LargeImage = "puchar",              // Larger Image Asset Key
                LargeText  = "Achievement Clicker", // Large Image Tooltip
                SmallImage = "times64",             // Small Image Asset Key
                SmallText  = "x64",                 // Small Image Tooltip
            },
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });

        discord.RunCallbacks();
    }
    public void UpdateActivity()
    {
        Discord.Activity activity;

        activity = new Discord.Activity
        {
            State   = "Prision Escape",
            Details = "Ingame",
            Assets  =
            {
                LargeImage = "",
                LargeText  = "",
                SmallImage = "",
                SmallText  = "",
            },
            Party =
            {
                Id   = "ae488379-351d-4a4f-ad32-2b9b01c91657",
                Size =
                {
                    CurrentSize =                                      3,
                    MaxSize     =                                      3,
                },
            },
            Instance = false,
        };

        activityManager.UpdateActivity(activity, result =>
        {
        });
    }
Beispiel #3
0
    public void buttonStop()
    {
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = ":)",
            Details = "Playing with Gene",

            Assets =
            {
                LargeImage = "gene",
                LargeText  = "It's Gene!"
            }
        };

        activityManager.UpdateActivity(activity, (result) =>
        {
            if (result == Discord.Result.Ok)
            {
                statusText.text = "Button Stop success";
            }
            else
            {
                statusText.text = "Button Stop failed";
            }
        });
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        discord = new Discord.Discord(669298461312679966, (System.UInt64)Discord.CreateFlags.NoRequireDiscord);
        var activityManager = discord.GetActivityManager();

        activityManager.RegisterSteam(1229730);


        var activity = new Discord.Activity
        {
            State      = "Points: " + GameControlScript.AchievementPointsATM.ToString(),
            Details    = "Total Clicks: " + GameControlScript.AchievementClicks.ToString(),
            Timestamps =
            {
                Start = CurrentTime,
            },
            Assets =
            {
                LargeImage = "puchar",                 // Larger Image Asset Key
                LargeText  = "Achievement Clicker",    // Large Image Tooltip
            },
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });
    }
    public void SetActivity(string state, string details, string largeImageKey = "default", string largeImageText = "", string smallImageKey = "", string smallImageText = "")
    {
        if (discord == null)
        {
            return;
        }

        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State      = state,
            Details    = details,
            Timestamps =
            {
                Start = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
            },
            Assets =
            {
                LargeImage = largeImageKey,
                LargeText  = largeImageText,
                SmallImage = smallImageKey,
                SmallText  = smallImageText
            }
        };

        activityManager.UpdateActivity(activity, result => print("Discord Activity Updated"));
    }
Beispiel #6
0
    public void buttonStart()
    {
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "Playing with Gene",
            Details = ":)",

            Timestamps =
            {
                Start = System.DateTimeOffset.Now.ToUnixTimeSeconds()
            },

            Assets =
            {
                LargeImage = "gene",
                LargeText  = "It's Gene!",
                SmallImage = "gene",
                SmallText  = "It's smol Gene!"
            },

            Party =
            {
                Id   = "GeneParty",
                Size =
                {
                    CurrentSize =           1,
                    MaxSize     = 42069
                }
            },

            Secrets =
            {
                Match    = "aaaaaaaa",
                Join     = "bbbbbbbb",
                Spectate = "cccccccc"
            },
            Instance = true
        };

        activityManager.UpdateActivity(activity, (result) =>
        {
            if (result == Discord.Result.Ok)
            {
                statusText.text = "Button Start success";
            }
            else
            {
                statusText.text = "Button Start failed";
            }
        });
    }
Beispiel #7
0
 public void UpdateActivity(Discord.Activity activity)
 {
     activityManager.UpdateActivity(activity, (result) =>
     {
         if (result == Discord.Result.Ok)
         {
             Debug.Log("Succeeded to update activity!");
         }
         else
         {
             Debug.LogError("Failed to update activity: " + result);
         }
     });
 }
    /// <summary>
    /// Update the user status in Discord.
    /// If your game doesn't have multiplayer, then you can remove the "Party" and "Secrets" attributes within the activity
    /// </summary>
    void updateActivity()
    {
        var stateText       = updateStateInput.text;
        var stateDetails    = updateDetailInput.text;
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity {
            State      = stateText,
            Details    = stateDetails,
            Timestamps =
            {
                Start = 5,
            },
            Assets =
            {
                LargeImage = "thumbnail",          // Larger Image Asset Key
                LargeText  = "foo largeImageText", // Large Image Tooltip
                SmallImage = "thumbnail",          // Small Image Asset Key
                SmallText  = "foo smallImageText", // Small Image Tooltip
            },
            Party =
            {
                Id   = "foo partyID",
                Size =
                {
                    CurrentSize =             1,
                    MaxSize     =             4,
                },
            },
            Secrets =
            {
                Match    = "foo matchSecret",
                Join     = "foo joinSecret",
                Spectate = "foo spectateSecret",
            },
            Instance = true,
        };

        activityManager.UpdateActivity(activity, (result) => {
            if (result == Discord.Result.Ok)
            {
                Debug.Log("Update Success!");
            }
            else
            {
                Debug.Log("Update Failed");
            }
        });
    }
        public Task <Lobby> CreateLobby(LobbyCreateParams createParams)
        {
            var txn = _lobbyManager.GetLobbyCreateTransaction();

            txn.SetCapacity(createParams.Capacity);
            txn.SetType((DiscordApp.LobbyType)createParams.Type);
            if (createParams.Metadata != null)
            {
                foreach (var kvp in createParams.Metadata)
                {
                    if (kvp.Key == null || kvp.Value == null)
                    {
                        continue;
                    }
                    txn.SetMetadata(kvp.Key, kvp.Value.ToString());
                }
            }
            var future = new TaskCompletionSource <Lobby>();

            _lobbyManager.CreateLobby(txn, (DiscordApp.Result result, ref DiscordApp.Lobby lobby) => {
                if (result != DiscordApp.Result.Ok)
                {
                    future.SetException(DiscordUtility.ToError(result));
                    return;
                }
                SetupLobbyChannels(lobby.Id);
                var outputLobby = new DiscordLobby(this, lobby);
                _connectedLobbies.Add(lobby.Id, outputLobby);
                var secret   = _lobbyManager.GetLobbyActivitySecret(lobby.Id);
                var activity = new DiscordApp.Activity {
                    Party =
                    {
                        Id   = lobby.Id.ToString(),
                        Size =
                        {
                            CurrentSize =                   1,
                            MaxSize     = (int)createParams.Capacity
                        }
                    },
                    Secrets = { Join = secret }
                };
                _activityManager.UpdateActivity(activity, res => {});
                future.SetResult(outputLobby);
            });
            return(future.Task);
        }
    // Use this for initialization
    void Start()
    {
        discord = new Discord.Discord(740120236992364576, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "유니티 디스코드 Rich Presence 테스트",
            Details = "테스트"
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.Log("Success");
            }
        });
    }
    //  public float clientID;


    // Start is called before the first frame update
    void Start()
    {
        discord = new Discord.Discord(secret, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "Learning Discord Rich Presence",
            Details = "It's Easier Than I Thought",
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });
    }
Beispiel #12
0
    // Use this for initialization
    void Start()
    {
        discord = new Discord.Discord(758714048115245077, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "Playing",
            Details = "In-Game"
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });
    }
Beispiel #13
0
    // Use this for initialization
    void Start()
    {
        discord = new Discord.Discord(758714048115245077, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "",
            Details = "In Main Menu"
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Menu okay!");
            }
        });
    }
    // Use this for initialization
    void Start()
    {
        discord = new Discord.Discord(461618159171141643, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "Still Testing",
            Details = "Bigger Test"
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });
    }
Beispiel #15
0
    void UpdateActivity()
    {
        activity = new Discord.Activity
        {
            State   = "Online QA",
            Details = "Private Beta",

            Timestamps =
            {
                Start = currentEpochTime,
                //End = 1580210732,
            },

            Assets =
            {
                LargeImage = "gtasmall",
                LargeText  = "GTA VI",
                SmallImage = "online",
                SmallText  = "Online",
            },

            Party =
            {
                Id              = "foo partyID",

                Size            =
                {
                    CurrentSize =            15,
                    MaxSize     =           256,
                },
            },

            Secrets =
            {
                //Match = "meme",
                Join = "meme",
                //Spectate = "meme",
            },

            Instance = true,
        };
    }
Beispiel #16
0
        // Use this for initialization
        void Start()
        {
            discord = new Discord.Discord(461618159171141643, (System.UInt64)Discord.CreateFlags.Default);
            var activityManager = discord.GetActivityManager();
            var activity        = new Discord.Activity
            {
                Assets =
                {
                    LargeImage = "main"
                },
                Details = "In Menu"
            };

            activityManager.UpdateActivity(activity, (res) =>
            {
                if (res == Discord.Result.Ok)
                {
                    Debug.LogError("Everything is fine!");
                }
            });
        }
    void Update()
    {
        var activityManager = discord.GetActivityManager();
        var activity        = new Discord.Activity
        {
            State   = "Moving Boxes",
            Details = ""
        };

        activityManager.UpdateActivity(activity, (res) =>
        {
            if (res == Discord.Result.Ok)
            {
                Debug.LogError("Everything is fine!");
            }
        });

        if (Input.GetKey("r"))
        {
            discord.Dispose();
        }
    }
Beispiel #18
0
 public static void SetActivity(Discord.Activity _activity)
 {
     Plugin.DiscordActivity.UpdateActivity(_activity, result => {});
 }
    void connect()
    {
        System.Environment.SetEnvironmentVariable("DISCORD_INSTANCE_ID", "0");
        //System.Environment.SetEnvironmentVariable("DISCORD_INSTANCE_ID", "1");
        discord = new Discord.Discord(AppClientId, (System.UInt64)Discord.CreateFlags.Default);
        UserManager userManager = discord.GetUserManager();

        userManager.OnCurrentUserUpdate += () => {
            var currentUser = userManager.GetCurrentUser();
            userLabel.text = currentUser.Username;
            disconnectButton.interactable       = true;
            updateStateInput.interactable       = true;
            updateDetailInput.interactable      = true;
            updateButton.interactable           = true;
            clearButton.interactable            = true;
            dropDownFriends.interactable        = true;
            inviteToJoinButton.interactable     = true;
            inviteToSpectateButton.interactable = true;
        };

        var relationshipManager = discord.GetRelationshipManager();

        // Assign this handle right away to get the initial relationships update.
        // This callback will only be fired when the whole list is initially loaded or was reset

        // Wait for OnRefresh to fire to access a stable list
        // Filter a user's relationship list to be just friends
        // Use this list as your base
        relationships = new List <Relationship>();
        relationshipManager.OnRefresh += () => {
            relationshipManager.Filter((ref Relationship relationship) => {
                return(relationship.Type == Discord.RelationshipType.Friend);
            });

            // Loop over all friends a user has.
            List <Dropdown.OptionData> options = new List <Dropdown.OptionData>();
            for (var i = 0; i < relationshipManager.Count(); i++)
            {
                // Get an individual relationship from the list
                var r = relationshipManager.GetAt((uint)i);
                relationships.Add(r);

                Dropdown.OptionData option = new Dropdown.OptionData();
                option.text = r.User.Username;
                options.Add(option);
            }
            dropDownFriends.AddOptions(options);
        };

        var activityManager = discord.GetActivityManager();

        LobbyManager lobbyManager = discord.GetLobbyManager();

        // Received when someone accepts a request to join or invite.
        // Use secrets to receive back the information needed to add the user to the group/party/match
        activityManager.OnActivityJoin += secret => {
            Debug.Log("OnJoin " + secret);
            lobbyManager.ConnectLobbyWithActivitySecret(secret, (Discord.Result result, ref Discord.Lobby lobby) => {
                Debug.Log("Connected to lobby: " + lobby.Id);
                // Connect to voice chat, used in this case to actually know in overlay if your successful in connecting.
                lobbyManager.ConnectVoice(lobby.Id, (Discord.Result voiceResult) => {
                    if (voiceResult == Discord.Result.Ok)
                    {
                        Debug.Log("New User Connected to Voice! Say Hello! Result: " + voiceResult);
                    }
                    else
                    {
                        Debug.Log("Failed with Result: " + voiceResult);
                    };
                });
                //Connect to given lobby with lobby Id
                lobbyManager.ConnectNetwork(lobby.Id);
                lobbyManager.OpenNetworkChannel(lobby.Id, 0, true);
                foreach (var user in lobbyManager.GetMemberUsers(lobby.Id))
                {
                    //Send a hello message to everyone in the lobby
                    lobbyManager.SendNetworkMessage(lobby.Id, user.Id, 0,
                                                    Encoding.UTF8.GetBytes(string.Format("Hello, " + user.Username + "!")));
                }
                //Sends this off to a Activity callback named here as 'UpdateActivity' passing in the discord instance details and lobby details
                UpdateActivity(discord, lobby);
            });
        };

        void UpdateActivity(Discord.Discord discord, Discord.Lobby lobby)
        {
            //Creates a Static String for Spectate Secret.
            string discordSpectateSecret  = "wdn3kvj320r8vk3";
            string spectateActivitySecret = discordSpectateSecret;
            var    activity1 = new Discord.Activity
            {
                State   = "Playing Co-Op",
                Details = "In a Multiplayer Match!",

                Assets =
                {
                    LargeImage = "matchimage1",
                    LargeText  = "Inside the Arena!",
                },
                Party =
                {
                    Id   = lobby.Id.ToString(),
                    Size =
                    {
                        CurrentSize = lobbyManager.MemberCount(lobby.Id),
                        MaxSize     = (int)lobby.Capacity,
                    },
                },
                Secrets =
                {
                    Spectate = spectateActivitySecret,
                    Join     = "123",
                },
                Instance = true,
            };

            activityManager.UpdateActivity(activity1, result => {
                Debug.Log("Updated to Multiplayer Activity: " + result);

                // Send an invite to another user for this activity.
                // Receiver should see an invite in their DM.
                // Use a relationship user's ID for this.
                // activityManager
                //   .SendInvite(
                //       364843917537050624,
                //       Discord.ActivityActionType.Join,
                //       "",
                //       inviteResult =>
                //       {
                //           Console.WriteLine("Invite {0}", inviteResult);
                //       }
                //   );
            });
        }

        statusLabel.text = "Connected.";
    }
Beispiel #20
0
    void FixedUpdate()
    {
        if (previousLang != language)
        {
            previousLang = language;
            UpdateLang();
        }
        if (platformCompat())
        {
            var activityManager = discord.GetActivityManager();
            int rpclvl          = GameEngine.instance.level < 2100 ? (GameEngine.instance.curSect + 1) * 100 : 2100;
            var activity        = new Discord.Activity {
                Details = curBoard != null ? "Level " + GameEngine.instance.level + " | " + rpclvl + (GameEngine.instance.level > 800 ? ". Struggling." : string.Empty) : null,
                State   = !Application.genuine ? "The game is tampered" : framerate > 2600 ? "Suspiciously high framerate" : framerate < 10 ? "Suspiciously low framerate" : IntentionalGameOver ? "Exiting..." : GameOver ? "Topped out" : curBoard != null && GameEngine.instance.paused && !GameEngine.instance.FrameStep ? "Paused" : curBoard != null && GameEngine.instance.replay.mode ? "Currently replaying" : curBoard != null && GameEngine.instance.paused && GameEngine.instance.FrameStep ? "Currently playing (Framestepping)" : curBoard != null ? "Currently playing" : quitting ? "Quitting" : menu == 1 ? "Currently in settings menu" :"Currently in main menu",
                Assets  =
                {
                    LargeImage = "icon"
                }
            };
            activityManager.UpdateActivity(activity, (res) => {
            });
            if (drpcSwitch)
            {
                discord.RunCallbacks();
            }
        }
        var MMf    = mainMenuGUI.Length * 8;
        var SBf    = settingsMenuGUI.Length * 8;
        var IPf    = inputsMenuGUI.Length * 8;
        var SBVf   = settingsGUIMovement.Length * 8;
        var MMSBf  = (MMf + SBf);
        var SBIPf  = (SBf + IPf);
        var MMSf   = (MMf + 50);
        var MMSCf  = (MMSf + SBf);
        var MMSCVf = (MMSf + SBVf);

        if (curBoard == null && Input.GetKeyDown(KeyCode.Escape))
        {
            if (menu > 0)
            {
                Back();
                audioSourceConfirmation.Play();
            }
            else
            {
                QuitGame();
                audioSourceConfirmation.Play();
            }
        }
        reswidth = (float)(Screen.width / 1920.0);
        framerateCounter.text = (Math.Floor((framerate) * 100) / 100) + " FPS";
        if (GameOver)
        {
            GameEngine.instance.readyGoIndicator.sprite = null;
            GameEngine.instance.gameMusic.Stop();
            if (frames % 10 == 9 && frames < 400)
            {
                BoardController.instance.DestroyLine(frames / 10);
            }
            if (frames < 400)
            {
                BoardController.instance.DecayLine(frames / 10, 0.1f);
            }
            frames++;
            if (frames > 300)
            {
                boardpos    = this.transform.position;
                boardpos.y -= (float)(0.1f + (((frames - 300) / 33) * ((frames - 300) / 33)));
                this.transform.position = boardpos;
                // boardrot = curBoard.transform.Rotate;
                // boardrot.z -= 0.16f;
                curBoard.transform.Rotate(new Vector3(0f, 0f, -0.1f - (float)(((frames - 300) / 66) * ((frames - 400) / 66))));
                if (frames == 301)
                {
                    audioSource2.PlayOneShot(topoutSE);
                }
                if (frames == 351)
                {
                    audioSource2.Play();
                }
                if (frames == 400)
                {
                    // SceneManager.LoadScene("MenuScene");
                }
                if (frames == 401)
                {
                    int pieceCountHoldRed = PiecesController.instance.pieceHold == 28 ? 0 : -1;
                    if (GameEngine.instance.singles > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 0] + GameEngine.instance.singles, Color.white);                                 // Singles
                    }
                    if (GameEngine.instance.doubles > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 1] + GameEngine.instance.doubles, Color.white);                                 // Doubles
                    }
                    if (GameEngine.instance.triples > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 2] + GameEngine.instance.triples, Color.white);                                 // Triples
                    }
                    if (GameEngine.instance.tetrises > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 3] + GameEngine.instance.tetrises, Color.white);                                  // Tetrises
                    }
                    if (GameEngine.instance.pentrises > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification("5 " + notifLangString[(int)language, 4] + GameEngine.instance.pentrises, Color.white);                                   // 5 lines
                    }
                    if (GameEngine.instance.sixtrises > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification("6 " + notifLangString[(int)language, 4] + GameEngine.instance.sixtrises, Color.white);                                   // 6 lines
                    }
                    if (GameEngine.instance.septrises > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification("7 " + notifLangString[(int)language, 4] + GameEngine.instance.septrises, Color.white);                                   // 7 lines
                    }
                    if (GameEngine.instance.octrises > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification("8+ " + notifLangString[(int)language, 4] + GameEngine.instance.octrises, Color.white);                                  // 8+ lines
                    }
                    if (GameEngine.instance.totalLines > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 5] + notifLangString[(int)language, 4] + GameEngine.instance.totalLines, Color.white);                                    // Total lines
                    }
                    if (PiecesController.instance.pieces > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 6] + (PiecesController.instance.pieces + pieceCountHoldRed), Color.white); // Pieces
                    }
                    NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 7] + gradeStringConversion[GameEngine.instance.grade], Color.white);           // Grade
                    if (GameEngine.instance.statGradePoints > 0)
                    {
                        NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 8], Color.white);                                          // Total grade score
                        NotificationEngine.instance.InstantiateNotification(Math.Floor(GameEngine.instance.statGradePoints).ToString(), Color.white);
                    }
                    NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 9] + GameEngine.instance.level + "/" + (GameEngine.instance.level < 2100 ? (GameEngine.instance.curSect + 1) * 100 : 2100), Color.white); // Level
                    NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 10] + GameEngine.instance.gravity, Color.white);                                                                                          // Gravity
                    NotificationEngine.instance.InstantiateNotification(notifLangString[(int)language, 11] + GameEngine.instance.timeCounter.text, Color.white);
                    frames                  = 0;
                    GameOver                = false;
                    IntentionalGameOver     = false;
                    starting                = true;
                    this.transform.position = Vector3.zero;
                    BackgroundController.bginstance.TriggerBackgroundChange(0);
                    if (!GameEngine.instance.replay.mode)
                    {
                        GameEngine.instance.replay.SaveReplay("1");
                    }
                }
            }
        }
        if (quitting || pressedSettingsMenu || startGame)
        {
            frames++;
            if (frames == 1)
            {
                mainMenu.SetActive(true);
                audioSource.PlayOneShot(clip);
            }
            else if (frames % 8 == 7 && frames < MMf - 1)
            {
                if (mainMenuGUI[(frames - 1) / 8].activeSelf)
                {
                    audioSource.PlayOneShot(clip);
                }
            }
            if (frames < MMf + 1)
            {
                posMMGUI[(frames - 1) / 8]    = mainMenuGUIMovement[(frames - 1) / 8].position;
                posMMGUI[(frames - 1) / 8].x -= (float)(62.5 * reswidth);
                mainMenuGUIMovement[(frames - 1) / 8].position = posMMGUI[(frames - 1) / 8];
            }
            if (startGame && frames > MMf + 10)
            {
                if (frames == MMf + 11)
                {
                    GameEngine.instance.replay.Reset();
                    if (GameEngine.instance.replay.mode)
                    {
                        GameEngine.instance.replay.LoadReplay("1");
                    }
                    mainMenu.SetActive(false);
                    GameEngine.instance.gradePoints           = 0;
                    GameEngine.instance.gradePointRequirement = 100;
                    GameEngine.instance.statGradePoints       = 0;
                    // SceneManager.LoadScene("GameScene");
                    GameObject board = GameObject.Instantiate(inGameBoard, transform);
                    curBoard = board;
                    this.transform.position = new Vector3(0.0f, 20f, 0.0f);
                    indicatorActivity(true, 6);
                    mainMenuMusic.Stop();
                    PiecesController.instance.UpdateShownPieces();
                }
                if (frames == MMf + 12)
                {
                    this.transform.position = new Vector3(0.0f, 18f, 0.0f);
                }
                if (frames == MMf + 13)
                {
                    this.transform.position = new Vector3(0.0f, 16f, 0.0f);
                }
                if (frames == MMf + 14)
                {
                    this.transform.position = new Vector3(0.0f, 14f, 0.0f);
                }
                if (frames == MMf + 15)
                {
                    this.transform.position = new Vector3(0.0f, 12f, 0.0f);
                }
                if (frames == MMf + 16)
                {
                    this.transform.position = new Vector3(0.0f, 10f, 0.0f);
                }
                if (frames == MMf + 17)
                {
                    this.transform.position = new Vector3(0.0f, 8f, 0.0f);
                }
                if (frames == MMf + 18)
                {
                    this.transform.position = new Vector3(0.0f, 6f, 0.0f);
                }
                if (frames == MMf + 19)
                {
                    this.transform.position = new Vector3(0.0f, 4f, 0.0f);
                }
                if (frames == MMf + 20)
                {
                    this.transform.position = new Vector3(0.0f, 2f, 0.0f);
                }
                if (frames == MMf + 21)
                {
                    this.transform.position = new Vector3(0.0f, 0f, 0.0f);
                }
                if (frames == MMf + 22)
                {
                    this.transform.position = new Vector3(0.0f, -0.8f, 0.0f);
                }
                if (frames == MMf + 23)
                {
                    this.transform.position = new Vector3(0.0f, -1.4f, 0.0f);
                }
                if (frames == MMf + 24)
                {
                    this.transform.position = new Vector3(0.0f, -2f, 0.0f);
                }
                if (frames == MMf + 25)
                {
                    this.transform.position = new Vector3(0.0f, -1.3f, 0.0f);
                }
                if (frames == MMf + 26)
                {
                    this.transform.position = new Vector3(0.0f, -0.7f, 0.0f);
                }
                if (frames == MMf + 27)
                {
                    this.transform.position = new Vector3(0.0f, 0f, 0.0f);
                }
                // if (frames == 23)
                // {
                //     SceneManager.UnloadSceneAsync("MenuScene");
                // }
                if (frames > MMf + 27)
                {
                    // PiecesController.instance.bagPieceResult=Random.Range(0,7);
                    startGame = false;
                    frames    = 0;
                    // imgbg.SetActive(false);
                    // imgprjchlg.SetActive(false);
                    GameEngine.instance.paused = false;
                    PiecesController.instance.UpdatePieceBag();
                }
            }
            if (pressedSettingsMenu && frames > MMSf && menu == 1)
            {
                if (frames % 8 == 0)
                {
                    mainMenu.SetActive(false);
                    if (settingsMenuGUI[((frames - 1) - MMSf) / 8].activeSelf)
                    {
                        audioSource.PlayOneShot(clip);
                    }
                }
                if (frames == MMSf + 1)
                {
                    settingsMenu.SetActive(true);
                }
                if (frames < MMSCf + 1)
                {
                    posSGUI[((frames - 1) - MMSf) / 8]    = settingsGUIMovement[((frames - 1) - MMSf) / 8].position;
                    posSGUI[((frames - 1) - MMSf) / 8].x += (float)(62.5 * reswidth);
                    settingsGUIMovement[((frames - 1) - MMSf) / 8].position = posSGUI[((frames - 1) - MMSf) / 8];
                    if ((frames - 1) < MMSf + settingsGUIPartMovement.Length * 8)
                    {
                        posSGUIP[((frames - 1) - MMSf) / 8]    = settingsGUIPartMovement[((frames - 1) - MMSf) / 8].position;
                        posSGUIP[((frames - 1) - MMSf) / 8].x += (float)(125.0 * reswidth);
                        settingsGUIPartMovement[((frames - 1) - MMSf) / 8].position = posSGUIP[((frames - 1) - MMSf) / 8];
                    }
                }
                else
                {
                    pressedSettingsMenu = false;
                    mainMenu.SetActive(false);
                    frames = 0;
                }
            }
            if (frames > MMf + 65 && quitting)
            {
                discord.Dispose();
                Application.Quit();
            }
        }
        if (pressedBack)
        {
            frames++;
            if (menu == 0)
            {
                if (frames == 1)
                {
                    mainMenu.SetActive(true);
                    audioSource.PlayOneShot(clip);
                }
                else if (frames % 8 == 0)
                {
                    audioSource.PlayOneShot(clip);
                }
                if (frames < SBf + 1)
                {
                    posSGUI[(frames - 1) / 8]    = settingsGUIMovement[(frames - 1) / 8].position;
                    posSGUI[(frames - 1) / 8].x -= (float)(62.5 * reswidth);
                    settingsGUIMovement[(frames - 1) / 8].position = posSGUI[(frames - 1) / 8];
                    if (frames < settingsMenuGUIpart.Length * 8 + 1)
                    {
                        posSGUIP[(frames - 1) / 8]    = settingsGUIPartMovement[(frames - 1) / 8].position;
                        posSGUIP[(frames - 1) / 8].x -= (float)(125.0 * reswidth);
                        settingsGUIPartMovement[(frames - 1) / 8].position = posSGUIP[(frames - 1) / 8];
                    }
                }
                else if (frames < MMSBf + 1)
                {
                    posMMGUI[((frames - 1) - SBf) / 8]    = mainMenuGUIMovement[((frames - 1) - SBf) / 8].position;
                    posMMGUI[((frames - 1) - SBf) / 8].x += (float)(62.5 * reswidth);
                    mainMenuGUIMovement[((frames - 1) - SBf) / 8].position = posMMGUI[((frames - 1) - SBf) / 8];
                }
                else
                {
                    settingsMenu.SetActive(false);
                    pressedBack = false;
                    frames      = 0;
                }
            }
            if (menu == 1)
            {
                if (frames == 1)
                {
                    settingsMenu.SetActive(true);
                    audioSource.PlayOneShot(clip);
                }
                else if (frames % 8 == 0)
                {
                    audioSource.PlayOneShot(clip);
                }
                if (frames < IPf + 1)
                {
                    posIGUI[(frames - 1) / 8]    = inputsGUIMovement[(frames - 1) / 8].position;
                    posIGUI[(frames - 1) / 8].x -= (float)(62.5 * reswidth);
                    inputsGUIMovement[(frames - 1) / 8].position = posIGUI[(frames - 1) / 8];
                }
                else if (frames < SBIPf + 1)
                {
                    posSGUI[((frames - 1) - IPf) / 8]    = settingsGUIMovement[((frames - 1) - IPf) / 8].position;
                    posSGUI[((frames - 1) - IPf) / 8].x += (float)(62.5 * reswidth);
                    settingsGUIMovement[((frames - 1) - IPf) / 8].position = posSGUI[((frames - 1) - IPf) / 8];
                    if (frames < settingsMenuGUIpart.Length * 8 + 1 + IPf)
                    {
                        posSGUIP[((frames - 1) - IPf) / 8]    = settingsGUIPartMovement[((frames - 1) - IPf) / 8].position;
                        posSGUIP[((frames - 1) - IPf) / 8].x += (float)(125.0 * reswidth);
                        settingsGUIPartMovement[((frames - 1) - IPf) / 8].position = posSGUIP[((frames - 1) - IPf) / 8];
                    }
                }
                else
                {
                    inputsMenu.SetActive(false);
                    pressedBack = false;
                    frames      = 0;
                }
            }
        }
        if (pressedInputsMenu)
        {
            frames++;
            if (frames == 1)
            {
                inputsMenu.SetActive(true);
                audioSource.PlayOneShot(clip);
            }
            else if (frames % 8 == 0)
            {
                audioSource.PlayOneShot(clip);
            }
            if (frames < SBf + 1)
            {
                posSGUI[(frames - 1) / 8]    = settingsGUIMovement[(frames - 1) / 8].position;
                posSGUI[(frames - 1) / 8].x -= (float)(62.5 * reswidth);
                settingsGUIMovement[(frames - 1) / 8].position = posSGUI[(frames - 1) / 8];
                if (frames < settingsMenuGUIpart.Length * 8 + 1)
                {
                    posSGUIP[(frames - 1) / 8]    = settingsGUIPartMovement[(frames - 1) / 8].position;
                    posSGUIP[(frames - 1) / 8].x -= (float)(125.0 * reswidth);
                    settingsGUIPartMovement[(frames - 1) / 8].position = posSGUIP[(frames - 1) / 8];
                }
            }
            else if (frames < SBIPf + 1)
            {
                posIGUI[((frames - 1) - SBf) / 8]    = inputsGUIMovement[((frames - 1) - SBf) / 8].position;
                posIGUI[((frames - 1) - SBf) / 8].x += (float)(62.5 * reswidth);
                inputsGUIMovement[((frames - 1) - SBf) / 8].position = posIGUI[((frames - 1) - SBf) / 8];
            }
            else
            {
                pressedInputsMenu = false;
                settingsMenu.SetActive(false);
                frames = 0;
            }
        }
        if (starting)
        {
            GameEngine.instance.time                  = 0;
            GameEngine.instance.rollTime              = 0;
            GameEngine.instance.level                 = 0;
            GameEngine.instance.curSect               = 0;
            GameEngine.instance.sectAfter20g          = 0;
            GameEngine.instance.ARE                   = 41.66666666666666;
            GameEngine.instance.AREf                  = 42 - 300;
            GameEngine.instance.paused                = true;
            GameEngine.instance.DAS                   = 25;
            GameEngine.instance.AREline               = 16.66666666666666666;
            GameEngine.instance.nextibmblocks         = 0;
            GameEngine.instance.LockDelay             = 50;
            GameEngine.instance.lineDelayf            = 0;
            GameEngine.instance.lineDelay             = 25;
            GameEngine.instance.gravity               = 3 / 64f;
            GameEngine.instance.singles               = 0;
            GameEngine.instance.doubles               = 0;
            GameEngine.instance.triples               = 0;
            GameEngine.instance.tetrises              = 0;
            GameEngine.instance.pentrises             = 0;
            GameEngine.instance.sixtrises             = 0;
            GameEngine.instance.septrises             = 0;
            GameEngine.instance.octrises              = 0;
            GameEngine.instance.totalLines            = 0;
            GameEngine.instance.lineClonePiecesLeft   = 2147483647;
            GameEngine.instance.grade                 = 0;
            GameEngine.instance.gradeIndicator.sprite = GameEngine.instance.gradeSprites[0];
            GameEngine.instance.bgmlv                 = 1;
            GameEngine.instance.timeCounter.text      = "00:00:00";
            GameEngine.instance.nextSecLv.text        = "100";
            GameEngine.instance.levelTextRender.text  = "0";
            GameEngine.instance.ending                = false;
            GameEngine.instance.sectionTime           = new int[21];
            Destroy(curBoard);
            GameEngine.instance.gameMusic.Stop();
            GameEngine.instance.gameMusic.clip   = GameEngine.instance.bgm_1p_lv[0];
            GameEngine.instance.gameMusic.volume = 1f;
            GameEngine.instance.tileInvisTime    = -1;
            if (!mainMenuMusic.isPlaying)
            {
                mainMenuMusic.Play();
            }
            frames++;
            // if (SceneManager.GetActiveScene().name != "MenuScene")SceneManager.LoadScene("MenuScene");
            // imgbg.SetActive(true);
            // imgprjchlg.SetActive(true);
            indicatorActivity(false, 7);
            mainMenu.SetActive(true);
            if (frames == 1)
            {
                // mainMenu.SetActive(true);
                audioSource.PlayOneShot(clip);
            }
            else if (frames % 17 == 16 && frames < mainMenuGUI.Length * 17 - 1)
            {
                if (mainMenuGUI[(frames - 1) / 17].activeSelf)
                {
                    audioSource.PlayOneShot(clip);
                }
            }
            if (frames < mainMenuGUI.Length * 17 + 1)
            {
                posMMGUI[(frames - 1) / 17]    = mainMenuGUIMovement[(frames - 1) / 17].position;
                posMMGUI[(frames - 1) / 17].x += (float)(29.411764705882352941176470588235 * reswidth);
                mainMenuGUIMovement[(frames - 1) / 17].position = posMMGUI[(frames - 1) / 17];
            }
            else
            {
                starting = false;
                frames   = 0;
            }
        }
    }
Beispiel #21
0
    public void UpdateActivity()
    {
        Discord.Activity activity;
        long             time = Convert.ToInt64(GetParent().Call("getStateTime"));
        int state             = (int)GetParent().Call("getState");

        if (state == 0)
        {
            activity = new Discord.Activity
            {
                Details = "In the Main Menu",
                Assets  =
                {
                    LargeImage = "better",
                    LargeText  = "Large Image Text",
                    SmallImage = "zahra",
                    SmallText  = "Small Image Text",
                },
                Instance = false,
            };
        }
        else if (state == 1)
        {
            activity = new Discord.Activity
            {
                Details    = "Connecting",
                Timestamps =
                {
                    Start = time
                },
                Assets =
                {
                    LargeImage = "better",
                    LargeText  = "Large Image Text",
                    SmallImage = "zahra",
                    SmallText  = "Small Image Text",
                },
                Instance = false,
            };
        }
        else
        {
            activity = new Discord.Activity
            {
                State      = "Doing Things",
                Details    = "Ingame",
                Timestamps =
                {
                    Start = time
                },
                Assets =
                {
                    LargeImage = "better",
                    LargeText  = "Large Image Text",
                    SmallImage = "zahra",
                    SmallText  = "Small Image Text",
                },
                Party =
                {
                    Id   = "ae488379-351d-4a4f-ad32-2b9b01c91657",
                    Size =
                    {
                        CurrentSize = rng.Next(1,                               8),
                        MaxSize     = rng.Next(8,                             100),
                    },
                },
                Instance = false,
            };
        }

        activityManager.UpdateActivity(activity, result =>
        {
            //GD.Print("Update Activity {0}" + result.ToString());

            // Send an invite to another user for this activity.
            // Receiver should see an invite in their DM.
            // Use a relationship user's ID for this.
            // activityManager
            //   .SendInvite(
            //       364843917537050624,
            //       Discord.ActivityActionType.Join,
            //       "",
            //       inviteResult =>
            //       {
            //           Console.WriteLine("Invite {0}", inviteResult);
            //       }
            //   );
        });
    }
Beispiel #22
0
    // Timer powoduje dziwne opoznienie 25 sekundowe
    // Update is called once per frame
    void Update()
    {
        //	timer += Time.deltaTime;

        //	if (timer > FiveSecTimer) {
        //		timer = timer - FiveSecTimer;

        if (GameControlScript.M1ActiveAPI == true)
        {
            if (GameControlScript.M2ActiveAPI == true)
            {
                if (GameControlScript.M3ActiveAPI == true)
                {
                    if (GameControlScript.M4ActiveAPI == true)
                    {
                        if (GameControlScript.M5ActiveAPI == true)
                        {
                            if (GameControlScript.M6ActiveAPI == true)
                            {
                                M6();
                            }
                            else
                            {
                                M5();
                            }
                        }
                        else
                        {
                            M4();
                        }
                    }
                    else
                    {
                        M3();
                    }
                }
                else
                {
                    M2();
                }
            }
            else
            {
                M1();
            }
        }
        else
        {
            var activityManager = discord.GetActivityManager();
            activityManager.RegisterSteam(1229730);

            var activity = new Discord.Activity
            {
                State      = "Points: " + GameControlScript.AchievementPointsATM.ToString(),
                Details    = "Total Clicks: " + GameControlScript.AchievementClicks.ToString(),
                Timestamps =
                {
                    Start = CurrentTime,
                },
                Assets =
                {
                    LargeImage = "puchar",                             // Larger Image Asset Key
                    LargeText  = "Achievement Clicker",                // Large Image Tooltip
                },
            };
            activityManager.UpdateActivity(activity, (res) =>
            {
                if (res == Discord.Result.Ok)
                {
                    Debug.LogError("Everything is fine!");
                }
            });

            discord.RunCallbacks();
        }
        //}
    }
        private void UpdateActivity(int VersionNumber, Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            //var clientID = Environment.GetEnvironmentVariable("DISCORD_CLIENT_ID");
            string clientID = collection["ClientID"].ToString();

            if (clientID == "")
            {
                clientID = "418559331265675294";
                clientID = "636181032353136640";
            }
            var discord         = new Discord.Discord(long.Parse(clientID), (ulong)Discord.CreateFlags.Default);
            var activityManager = discord.GetActivityManager();
            var activity        = new Discord.Activity
            {
                State   = collection["State"],
                Details = collection["Details"],
                Assets  =
                {
                    LargeImage = collection["LargeImage"],
                    LargeText  = collection["LargeText"],
                    SmallImage = collection["SmallImage"],
                    SmallText  = collection["SmallText"],
                },


                Instance = true,
            };

            if (collection["timeStart"] != "")
            {
                activity.Timestamps.Start = long.Parse(collection["timeStart"]);
            }
            if (collection["timeEnd"] != "")
            {
                activity.Timestamps.End = long.Parse(collection["timeEnd"]);
            }
            ;
            if (collection["EnableParty"].ToString() == "on")
            {
                activity.Party.Id   = Guid.NewGuid().ToString();
                activity.Party.Size = new PartySize
                {
                    CurrentSize = collection["CurrentSize"] == "" ? 1 : int.Parse(collection["CurrentSize"]),
                    MaxSize     = collection["MaxSize"] == "" ? 1 : int.Parse(collection["MaxSize"])
                };
                activity.Secrets = new Discord.ActivitySecrets
                {
                    Join     = Guid.NewGuid().ToString(),
                    Match    = Guid.NewGuid().ToString(),
                    Spectate = Guid.NewGuid().ToString(),
                };
            }
            Discord.Result result1 = new Discord.Result();
            activityManager.UpdateActivity(activity, result =>
            {
                Console.WriteLine("Update Activity {0}", result);
                result1 = result;
                // Send an invite to another user for this activity.
                // Receiver should see an invite in their DM.
                // Use a relationship user's ID for this.
                // activityManager
                //   .SendInvite(
                //       364843917537050624,
                //       Discord.ActivityActionType.Join,
                //       "",
                //       inviteResult =>
                //       {
                //           Console.WriteLine("Invite {0}", inviteResult);
                //       }
                //   );
            });
            try
            {
                while (VersionNumber == (int)_cache.Get("DiscordActivityVersion"))
                {
                    discord.RunCallbacks();
                    Thread.Sleep(1000 / 10);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                discord.Dispose();
                _cache.Set("DisposeVersionCode", VersionNumber);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String curActivity = "";
            String curDetail   = "";

            if (textBox1.Text != ActivitiesFiller)
            {
                curActivity = textBox1.Text;
            }
            if (textBox2.Text != DetailsFiller)
            {
                curDetail = textBox2.Text;
            }

            Discord.Activity activity = new Discord.Activity {
            };

            activity.State   = curDetail;   // add basic details
            activity.Details = curActivity;

            if (checkBox1.Checked) // add lobbies
            {
                activity.Party.Id = "Party";
                activity.Party.Size.CurrentSize = (int)Math.Ceiling(numericUpDown1.Value);
                activity.Party.Size.MaxSize     = (int)Math.Ceiling(numericUpDown2.Value);
            }

            if (checkBox2.Checked) // add thumbnails
            {
                activity.Assets.LargeImage = textBox3.Text;
                activity.Assets.LargeText  = textBox4.Text;
                activity.Assets.SmallImage = textBox5.Text;
                activity.Assets.SmallText  = textBox6.Text;
            }

            if (checkBox3.Checked) // add time elapsed
            {
                TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
                int      secondsSinceEpoch = (int)t.TotalSeconds;
                int      timespan          = 0;
                timespan = timespan + (dateTimePicker1.Value.Hour * 60 * 60) + (dateTimePicker1.Value.Minute * 60) + (dateTimePicker1.Value.Second);
                int timeElapsed = secondsSinceEpoch - timespan;

                activity.Timestamps.Start = timeElapsed;
            }

            if (checkBox4.Checked) // add time remaining
            {
                TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
                int      secondsSinceEpoch = (int)t.TotalSeconds;
                int      timespan          = 0;
                timespan = timespan + (dateTimePicker2.Value.Hour * 60 * 60) + (dateTimePicker2.Value.Minute * 60) + (dateTimePicker2.Value.Second);
                int timeElapsed = secondsSinceEpoch + timespan;

                activity.Timestamps.End = timeElapsed;
            }

            bool updatedActivity = false;

            activityManager.UpdateActivity(activity, (result) =>
            {
                if (result == Discord.Result.Ok)
                {
                    Console.WriteLine("Success!");
                    updatedActivity = true;
                }
                else
                {
                    Console.WriteLine("Failed");
                }
            });

            System.Timers.Timer aTimer = new System.Timers.Timer(5000);
            bool TimeRanOut            = false;

            aTimer.Elapsed += (s, ev) =>
            {
                TimeRanOut = true;
            };

            while (!updatedActivity && !TimeRanOut)
            {
                discord.RunCallbacks();
            }
        }
Beispiel #25
0
    // Start is called before the first frame update
    void Start()
    {
        LevelManager levelData = null;

        if (GameObject.Find("LevelManager"))
        {
            levelData = GameObject.Find("LevelManager").GetComponent <LevelManager>();
        }

        string discordAppId = Utils.GetSecret("DISCORD_APP_ID");

        discord         = new Discord.Discord(long.Parse(discordAppId), (System.UInt64)Discord.CreateFlags.Default);
        userManager     = discord.GetUserManager();
        activityManager = discord.GetActivityManager();
        //lobbyManager = discord.GetLobbyManager();

        discord.SetLogHook(Discord.LogLevel.Debug, LogProblemsFunction);

        userManager.OnCurrentUserUpdate += () =>
        {
            var currentUser = userManager.GetCurrentUser();
            Debug.Log(currentUser.Username);
            Debug.Log(currentUser.Discriminator);
            Debug.Log(currentUser.Id);
        };

        if (levelData)
        {
            if (levelData.isMultiplayer)
            {
                state = "In a multiplayer game with (User)"; // Fetch the User here somehow, no multiplayer system is in place yet anyway
            }
            else
            {
                //state = "Playing a test build";
                state = "In a singleplayer game";
            }
            details = "Currently on: " + levelData.levelName;

            activity = new Discord.Activity
            {
                State   = state,
                Details = details
            };

            UpdateActivity(activity);
        }
        else
        {
            GameObject.Find("DiscordData").GetComponent <DiscordData>().RefeshActivity();
        }


        /*
         * var txn = lobbyManager.GetLobbyCreateTransaction();
         *
         * txn.SetCapacity(2);
         * txn.SetType(Discord.LobbyType.Private);
         * txn.SetMetadata("info", "testing the lobby system");
         *
         * lobbyManager.CreateLobby(txn, (Result result, ref Lobby lobby) =>
         * {
         *  Debug.Log(string.Format("lobby {0} created with secret {1}", lobby.Id, lobby.Secret));
         *
         *  lobbyManager.ConnectNetwork(lobby.Id);
         *  lobbyManager.OpenNetworkChannel(lobby.Id, 0, true);
         *
         *  //lobbyManager.SendNetworkMessage
         * });
         */
    }