private bool DoLoadGame()
    {
        bool loaded = false;
        int  fReq   = 3;

        if (PlayerPrefs.HasKey("SaveData"))
        {
            SaveData data = JsonUtility.FromJson <SaveData>(PlayerPrefs.GetString("SaveData"));
            state    = data.state;
            stats    = data.stats;
            presents = data.presents;
            friends  = data.friends;
            fReq     = data.friendRequests;
            if (!string.IsNullOrEmpty(data.playerName))
            {
                string[] nameBits = data.playerName.Split(new [] { ' ' }, 2);
                NameManager.SetMyName(nameBits[0], nameBits[1]);
            }
            if (!string.IsNullOrEmpty(data.ldName))
            {
                LudumDareAPI.SetUser(data.ldName, () => {});
            }
            loaded = true;
        }
        pendingRequests.Clear();
        for (int i = 0; i < fReq; ++i)
        {
            pendingRequests.Add(GenerateFriend());
        }
        PrepareFriends();
        SetUpgrades();
        ApplyUpgrades();
        return(loaded);
    }
示例#2
0
 void Update()
 {
     if (lastUserID != LudumDareAPI.GetUserID())
     {
         Texture2D tex = LudumDareAPI.GetAvatar();
         if (tex != null)
         {
             lastUserID    = LudumDareAPI.GetUserID();
             image.texture = tex;
             image.enabled = true;
         }
     }
 }
    private void DoSaveGame()
    {
        SaveData data = new SaveData();

        data.state          = state;
        data.stats          = stats;
        data.presents       = presents;
        data.friends        = friends;
        data.friendRequests = pendingRequests.Count;
        data.playerName     = NameManager.GetMyName();
        data.ldName         = LudumDareAPI.GetUsername();
        PlayerPrefs.SetString("SaveData", JsonUtility.ToJson(data));
        SendHighscore();
    }
    public static Coroutine SendHighscore()
    {
        SaveData data = new SaveData();

        data.state          = instance.state;
        data.stats          = instance.stats;
        data.friendRequests = instance.pendingRequests.Count;
        data.playerName     = NameManager.GetMyName();
        data.ldName         = LudumDareAPI.GetUsername();
        WWWForm form = new WWWForm();

        form.AddField("SaveData", JsonUtility.ToJson(data));
        WWW req = new WWW("https://hitchh1k3rsguide.com/api/ld40_highscore.php", form);

        return(instance.StartCoroutine(req));
    }
示例#5
0
    public void SubmitButton()
    {
        if (!isProcessing)
        {
            errorLine.text            = "";
            isProcessing              = true;
            submitButton.interactable = false;
            buttonText.text           = "working...";

            if (firstName.text.Trim() == "" || lastName.text.Trim() == "")
            {
                errorLine.text            = "*First and Last Name are Required";
                isProcessing              = false;
                submitButton.interactable = true;
                buttonText.text           = "Submit";
                return;
            }
            NameManager.SetMyName(firstName.text, lastName.text);

            if (ldName.text != "")
            {
                LudumDareAPI.SetUser(ldName.text, () => {
                    isProcessing = false;
                    if (LudumDareAPI.GetUserID() > 2)
                    {
                        InterfaceManager.ShowFriendBay();
                    }
                    else
                    {
                        submitButton.interactable = true;
                        buttonText.text           = "Submit";
                        errorLine.text            = "*Ludum Dare Username Could Not Be Found";
                    }
                });
            }
            else
            {
                InterfaceManager.ShowFriendBay();
            }
        }
    }
示例#6
0
    // Interface Singleton:

    protected override void SetInstance(GameObject gameObject)
    {
        instance = gameObject.GetComponent <LudumDareAPI>();
    }