示例#1
0
    IEnumerator SaveChanges()
    {
        LoadAlert.Instance.StartLoad("Saving Changes...", null, -1);
        Task save = _project.SaveAsync();

        while (!save.IsCompleted)
        {
            yield return(null);
        }

        LoadAlert.Instance.Done();

        if (save.IsFaulted || save.Exception != null)
        {
            DefaultAlert.Present("Sorry", "There was an error when updating the project. Please try again later");

            _project.Name        = _previousName;
            _project.Description = _previousDescription;
            _project.Client      = _previousClient;
            _project.Closed      = _previousClosed;
        }
        else
        {
            _previousName        = _project.Name;
            _previousDescription = _project.Description;
            _previousClosed      = _project.Closed;

            SetEditable();

            if (_project.Client != _previousClient && switchedClient != null)
            {
                switchedClient(this, _previousClient);
            }
        }
    }
示例#2
0
    IEnumerator CreateClient()
    {
        Task task = _client.SaveAsync();

        LoadAlert.Instance.StartLoad("Creating Client...", null, -1);

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        LoadAlert.Instance.Done();

        if (task.IsFaulted || task.Exception != null)
        {
            DefaultAlert.Present("Sorry!", "There was an error while " +
                                 "trying to create your client. Please try again later.");
        }
        else
        {
            Deactivate();

            if (createdClient != null)
            {
                createdClient(_client);
            }

            _client = null;
        }
    }
示例#3
0
    IEnumerator SwitchCoroutine(ExpenseListElement element, Project prevProject)
    {
        ExpenseList.RemoveListElement(element);

        prevProject.ItemCount--;
        element.Item.Project.ItemCount++;

        List <Project> projects = new List <Project>();

        projects.Add(prevProject);
        projects.Add(element.Item.Project);

        Task task = projects.SaveAllAsync();

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        if (task.Exception != null)
        {
            DefaultAlert.Present("Sorry!", "An error occured and we " +
                                 "could not update the projects' item count");
        }
    }
示例#4
0
    IEnumerator SwitchCoroutines(Project project)
    {
        Project prevProj = _item.Project;

        _item.Project = project;

        Task task = _item.SaveAsync();

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        if (task.Exception == null)
        {
            if (switchedProject != null)
            {
                switchedProject(this, prevProj);
            }
        }
        else
        {
            DefaultAlert.Present("Sorry!", "An error occured while trying " +
                                 "to delete this expense. Pleae try again later");
            _item.Project = prevProj;
        }
    }
示例#5
0
    IEnumerator DeleteCoroutine()
    {
        LoadAlert.Instance.StartLoad("Deleting expense...", null, -1);

        Task task = _item.DeleteAsync();

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        LoadAlert.Instance.Done();

        if (task.Exception == null)
        {
            if (remove != null)
            {
                remove(this);
            }
        }
        else
        {
            DefaultAlert.Present("Sorry!", "An error occured while trying " +
                                 "to delete this expense. Pleae try again later");
        }
    }
示例#6
0
    IEnumerator ClaimCoins()
    {
        yield return(StartCoroutine(OnlineManager.Instance.StartRedeemSteps()));

        _state  = HistoryViewState.REDUCE;
        enabled = true;
        DefaultAlert.Present("Hooray!", "You got " + OnlineManager.Instance.CoinsClaimed + " coins!");
    }
示例#7
0
        void LoadTimeout()
        {
            DefaultAlert.Present(LANGUAGE_ERROR_HEADER, LANGUAGE_ERROR_BODY, null, null);

            if (languageFailedToLoad != null)
            {
                languageFailedToLoad();
            }
        }
示例#8
0
 public void Submit()
 {
     if (PasswordField.text == ConfirmField.text)
     {
         StartCoroutine(UpdateUser());
     }
     else
     {
         DefaultAlert.Present("Sorry!", "You password fields do not match. Please try again.");
     }
 }
示例#9
0
    public void Confirm()
    {
        if (string.IsNullOrEmpty(InputField.Text) || Helper.CheckIfSpaces(InputField.Text))
        {
            DefaultAlert.Present("Sorry!", "Please input some text.", null, null);
            return;
        }

        Deactivate();//Close();

        if (confirm != null)
        {
            confirm(InputField.Text);
        }

        confirm = null;
        cancel  = null;
    }
示例#10
0
    IEnumerator UploadImage(byte[] data)
    {
        LoadAlert.Instance.StartLoad("Uploading photo...", null, -1);

        ParseFile file = new ParseFile(_item.Name + ".png", data);
        Task      task = file.SaveAsync();

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        LoadAlert.Instance.Done();

        if (task.Exception == null)
        {
            DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again");
        }
        else
        {
            _item.Image = file;

            task = _item.SaveAsync();

            while (!task.IsCompleted)
            {
                yield return(null);
            }

            if (task.Exception == null)
            {
                Texture2D tex = new Texture2D(1, 1);
                tex.LoadImage(data);

                Image.texture = tex;
            }
            else
            {
                DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again");
            }
        }
    }
示例#11
0
    IEnumerator AddUserCoroutine(string email)
    {
        LoadAlert.Instance.StartLoad("Adding " + email, null, -1);

        ParseQuery <ParseUser> userQuery = new ParseQuery <ParseUser>().WhereEqualTo("email", email);
        Task <ParseUser>       fetch     = userQuery.FirstAsync();

        while (!fetch.IsCompleted)
        {
            yield return(null);
        }

        if (fetch.Exception != null)
        {
            LoadAlert.Instance.Done();
            DefaultAlert.Present("Sorry!", "We could not find that user. " +
                                 "Make sure you spelled their email correctly.");
        }
        else
        {
            _project.ACL.SetReadAccess(fetch.Result, true);
            _project.ACL.SetWriteAccess(fetch.Result, true);
            _project.UserCount++;

            Task save = _project.SaveAsync();

            while (!save.IsCompleted)
            {
                yield return(null);
            }

            LoadAlert.Instance.Done();

            if (save.Exception != null)
            {
                DefaultAlert.Present("Sorry!", "The database failed " +
                                     "to add that user. Please try again later.");
            }
        }
        //_project.ACL.SetReadAccess(Data
    }
示例#12
0
    IEnumerator ClaimExercise()
    {
        int beforeGems = Avatar.Instance.Gems;

        yield return(StartCoroutine(OnlineManager.Instance.StartRedeemActiveMinutes()));

        int gemsClaimed = Avatar.Instance.Gems - beforeGems;

        ActivityClaimButton.ButtonIconImage.sprite = AssetLookUp.Instance.ClaimedButton;

        string message = "You got ";

        if (gemsClaimed == 1)
        {
            message += "a gem!";
        }
        else
        {
            message += gemsClaimed.ToString() + " gems!";
        }
        DefaultAlert.Present("Hooray!", message);
    }
示例#13
0
    public void ClickArrow()
    {
        bool canSpend = Avatar.Instance.CanSpendCoins(ARROW_COST);
        int  index    = AmmoBeltView.Instance.FindNextOpenIndex();

        if (canSpend && index > -1)
        {
            _index = index;
            YesNoAlert.Present("Balloon Arrow", "Are you sure you want to purchase this?", BuyArrow, null);
        }
        else
        {
            if (!canSpend)
            {
                DefaultAlert.Present("Sorry", "You don't have enough coins", null, null, false, "OK");
            }
            else
            {
                DefaultAlert.Present("Sorry", "Your ammo bandelier is full", null, null, false, "OK");
            }
        }
    }
示例#14
0
    IEnumerator SubmitCoroutine()
    {
        LoadAlert.Instance.StartLoad("Marking your expenses as opened.");
        _project.SubmittedUsers.Add(User.CurrentParseUser.ObjectId);

        Task task = _project.SaveAsync();

        while (!task.IsCompleted)
        {
            yield return(null);
        }

        LoadAlert.Instance.Done();

        if (task.Exception != null)
        {
            DefaultAlert.Present("Sorry!", "The database failed to close your expenses.");
        }
        else
        {
            SubmitText.text = OPEN;
        }
    }
示例#15
0
    public void Action()
    {
        StoreItem storeItem = _currentItem.Object as StoreItem;

        if (storeItem.Purchased)
        {
            if (!storeItem.Equipped)
            {
                StartCoroutine(StartEquip(storeItem));
            }
            else
            {
                StartCoroutine(StartUnequip(storeItem));
            }
        }
        else
        {
            bool canSpendCoins = Avatar.Instance.CanSpendCoins(storeItem.Coins);
            bool canSpendGems  = Avatar.Instance.CanSpendGems(storeItem.Gems);

            if (canSpendCoins && canSpendGems)
            {
                YesNoAlert.Present("Gear", "Are you sure you want to purchase this?", BuyGear, null);
            }
            else
            {
                if (!canSpendCoins)
                {
                    DefaultAlert.Present(SORRY, INSUFFICIENT_COINS);
                }
                else
                {
                    DefaultAlert.Present(SORRY, INSUFFICIENT_GEMS);
                }
            }
        }
    }