//----------------------------------------------------------------------------------------------------------------------------------------------//

    public void Create()
    {
        creating = true;

        string groupName      = groupManager.activeGroup.groupName;
        string projectRefName = "(" + groupName + ") " + projectName.text;

        DataRef.Groups(groupName).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;
            SetReference(groupName, "Project" + (snapshot.Child("Projects").ChildrenCount + 1).ToString(), projectRefName);
        });

        DataRef.Projects(projectRefName).Child("ProjectName").SetValueAsync(projectName.text).ContinueWith(async(task) => { await new WaitForUpdate(); });
        DataRef.Projects(projectRefName).Child("ProjectDescription").SetValueAsync(projectDescription.text).ContinueWith(async(task) => { await new WaitForUpdate(); });
        DataRef.Projects(projectRefName).Child("FundingGoal").SetValueAsync((int.Parse(fund) * 100).ToString()).ContinueWith(async(task) => { await new WaitForUpdate(); });
        DataRef.Projects(projectRefName).Child("FundingAmount").SetValueAsync("0").ContinueWith(async(task) => { await new WaitForUpdate(); });
        DataRef.Projects(projectRefName).Child("Group").SetValueAsync(groupName).ContinueWith(async(task) => { await new WaitForUpdate(); });
        foreach (string tag in categoryTags)
        {
            DataRef.Projects(projectRefName).Child("Tags").Child("Categories").Child(tag).SetValueAsync(tag).ContinueWith(async(task) => { await new WaitForUpdate(); });
            DataRef.Filters("Category").Child(tag).Child(projectRefName).SetValueAsync(projectRefName).ContinueWith(async(task) => { await new WaitForUpdate(); });
        }
        DataRef.Filters("Location").Child(locationText.text).Child(projectRefName).SetValueAsync(projectRefName).ContinueWith(async(task) => { await new WaitForUpdate(); });
        DataRef.Projects(projectRefName).Child("Tags").Child("Location").SetValueAsync(locationText.text).ContinueWith(async(task) => {
            await new WaitForUpdate();
            ResetFields();
            canvasScript.ToggleDoerSub(false);
            creating = false;
            groupManager.activeGroup.Populate();
        });

        activityManager.SetAlertNewProject(projectRefName, "Group_Default");
        //activityManager.Resubscribe ();
    }
Beispiel #2
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void GetBucketTeamProject()
    {
        DataRef.Projects("(Bucket NZ) Bucket Team").GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;

            string pName             = snapshot.Child("ProjectName").Value.ToString();
            string gName             = snapshot.Child("Group").Value.ToString();
            string pRef              = "(" + gName + ") " + pName;
            string description       = snapshot.Child("ProjectDescription").Value.ToString();
            string fundingGoal       = snapshot.Child("FundingGoal").Value.ToString();
            string fundingAmount     = snapshot.Child("FundingAmount").Value.ToString();
            string location          = snapshot.Child("Tags").Child("Location").Value.ToString();
            string pictureID         = snapshot.Child("PictureID").Value.ToString();
            List <string> categories = new List <string> ();
            foreach (DataSnapshot snap in snapshot.Child("Tags").Child("Categories").Children)
            {
                categories.Add(snap.Value.ToString());
            }
            List <string> goalTitles = new List <string> ();
            foreach (DataSnapshot s2 in snapshot.Child("Measurements").Children)
            {
                goalTitles.Add(s2.Child("Title").Value.ToString());
            }
            List <string> goalValues = new List <string> ();
            foreach (DataSnapshot s3 in snapshot.Child("Measurements").Children)
            {
                goalValues.Add(s3.Child("Value").Value.ToString());
            }

            bucketTeam.SetInformation(pRef, gName, pName, description, fundingGoal, fundingAmount, location, categories, goalTitles, goalValues, pictureID);
        });
    }
Beispiel #3
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void GetLink(string type, string reference)
    {
        messageType = type;
        referenceID = reference;

        if (type == "Project")
        {
            DataRef.Projects(reference).GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;

                referenceName = snapshot.Child("ProjectName").Value.ToString();

                SetMessageInfo();
            });
        }
        else if (type == "Circle")
        {
            DataRef.Circles(reference).GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;

                referenceName = snapshot.Child("Name").Value.ToString();

                SetMessageInfo();
            });
        }
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    // 0 = top message
    // 1 = type message
    // 2 = timestamp
    // 3 = picture
    // 4 = project link

    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void AssignDonation(DataSnapshot snap)
    {
        DataRef.User(snap.Child("UserID").Value.ToString()).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                return;
            }
            DataSnapshot snapshot = task.Result;

            Sprite image = Resources.Load <Sprite> ("2D/Animals/" + snapshot.Child("PictureID").Value.ToString());
            this.transform.GetChild(3).GetChild(0).GetChild(0).GetComponent <Image> ().sprite = image;
        });

        DataRef.Projects(snap.Child("Reference").Value.ToString()).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            if (task.IsFaulted || task.IsCanceled)
            {
                return;
            }
            DataSnapshot snapshot = task.Result;

            this.transform.GetChild(0).GetComponent <Text> ().text = snap.Child("Donor").Value.ToString();
            this.transform.GetChild(1).GetComponent <Text> ().text = "Donated $" + snap.Child("Amount").Value.ToString() + " to " + snapshot.Child("ProjectName").Value.ToString();
            this.transform.GetChild(2).GetComponent <Text> ().text = snap.Child("Date").Value.ToString();

            string pName             = snapshot.Child("ProjectName").Value.ToString();
            string gName             = snapshot.Child("Group").Value.ToString();
            string pRef              = "(" + gName + ") " + pName;
            string description       = snapshot.Child("ProjectDescription").Value.ToString();
            string fundingGoal       = snapshot.Child("FundingGoal").Value.ToString();
            string fundingAmount     = snapshot.Child("FundingAmount").Value.ToString();
            string location          = snapshot.Child("Tags").Child("Location").Value.ToString();
            string pictureID         = snapshot.Child("PictureID").Value.ToString();
            List <string> categories = new List <string> ();
            foreach (DataSnapshot s1 in snapshot.Child("Tags").Child("Categories").Children)
            {
                categories.Add(s1.Value.ToString());
            }
            List <string> goalTitles = new List <string> ();
            foreach (DataSnapshot s2 in snapshot.Child("Measurements").Children)
            {
                goalTitles.Add(s2.Child("Title").Value.ToString());
            }
            List <string> goalValues = new List <string> ();
            foreach (DataSnapshot s3 in snapshot.Child("Measurements").Children)
            {
                goalValues.Add(s3.Child("Value").Value.ToString());
            }

            this.transform.GetChild(4).GetComponent <ProjectInformation> ().SetInformation(pRef, gName, pName, description, fundingGoal, fundingAmount, location, categories, goalTitles, goalValues, pictureID);
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void UpdateProjectBalance(int donation)
    {
        int    newBalance = projectInfo.currentBalance + (donation * 100);
        string newAmount  = newBalance.ToString();

        DataRef.Projects(projectInfo.projectReference).Child("FundingAmount").SetValueAsync(newAmount).ContinueWith(async(task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                await new WaitForUpdate();
                print(task.Exception);
                return;
            }
            await new WaitForUpdate();
            projectInfo.UpdateDisplay(newBalance);
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void InstantiateProject(string target)
    {
        DataRef.Projects(target).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot snapshot = task.Result;

            string pName             = snapshot.Child("ProjectName").Value.ToString();
            string gName             = snapshot.Child("Group").Value.ToString();
            string pRef              = "(" + gName + ") " + pName;
            string description       = snapshot.Child("ProjectDescription").Value.ToString();
            string fundingGoal       = snapshot.Child("FundingGoal").Value.ToString();
            string fundingAmount     = snapshot.Child("FundingAmount").Value.ToString();
            string location          = snapshot.Child("Tags").Child("Location").Value.ToString();
            string pictureID         = snapshot.Child("PictureID").Value.ToString();
            List <string> categories = new List <string> ();
            foreach (DataSnapshot snap in snapshot.Child("Tags").Child("Categories").Children)
            {
                categories.Add(snap.Value.ToString());
            }
            List <string> goalTitles = new List <string> ();
            foreach (DataSnapshot s2 in snapshot.Child("Measurements").Children)
            {
                goalTitles.Add(s2.Child("Title").Value.ToString());
            }
            List <string> goalValues = new List <string> ();
            foreach (DataSnapshot s3 in snapshot.Child("Measurements").Children)
            {
                goalValues.Add(s3.Child("Value").Value.ToString());
            }

            GameObject project = Instantiate(projectPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            project.transform.SetParent(resultsBox);
            if (pRef == "(Bucket NZ) Bucket Team")
            {
                project.name = "zzzzz - " + pName;
            }
            else
            {
                project.name = pName;
            }
            project.transform.localScale = new Vector3(1, 1, 1);
            project.GetComponent <ProjectInformation> ().SetInformation(pRef, gName, pName, description, fundingGoal, fundingAmount, location, categories, goalTitles, goalValues, pictureID);

            OrganiseResults(filterType);
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void CheckForName()
    {
        if (projectName.text.Length > 5)
        {
            DataRef.Projects("(" + groupManager.activeGroup.name + ") " + projectName.text).GetValueAsync().ContinueWith(async(task) => {
                await new WaitForUpdate();
                DataSnapshot snapshot = task.Result;
                if (snapshot.Exists)
                {
                    taken = true;
                }
                else
                {
                    taken = false;
                }
            });
        }
    }
Beispiel #8
0
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void InstantiateProject(int members, int money, DataSnapshot snapshot, string projectRef)
    {
        GameObject project = Instantiate(circlesProjectPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        project.transform.SetParent(projectsContent);
        project.transform.localScale = new Vector3(1, 1, 1);

        DataRef.Projects(projectRef).GetValueAsync().ContinueWith(async(task) => {
            await new WaitForUpdate();
            DataSnapshot projectSnap = task.Result;

            string pName = projectSnap.Child("ProjectName").Value.ToString();
            project.name = pName;
            string gName = projectSnap.Child("Group").Value.ToString();
            //string pRef = "(" + gName + ") " + pName;
            string pRef              = projectRef;
            string description       = projectSnap.Child("ProjectDescription").Value.ToString();
            string fundingGoal       = projectSnap.Child("FundingGoal").Value.ToString();
            string fundingAmount     = projectSnap.Child("FundingAmount").Value.ToString();
            string location          = projectSnap.Child("Tags").Child("Location").Value.ToString();
            string pictureID         = projectSnap.Child("PictureID").Value.ToString();
            List <string> categories = new List <string> ();
            foreach (DataSnapshot snap in projectSnap.Child("Tags").Child("Categories").Children)
            {
                categories.Add(snap.Value.ToString());
            }
            List <string> goalTitles = new List <string> ();
            foreach (DataSnapshot s2 in projectSnap.Child("Measurements").Children)
            {
                goalTitles.Add(s2.Child("Title").Value.ToString());
            }
            List <string> goalValues = new List <string> ();
            foreach (DataSnapshot s3 in projectSnap.Child("Measurements").Children)
            {
                goalValues.Add(s3.Child("Value").Value.ToString());
            }

            project.transform.GetComponent <ProjectInformation> ().SetCircleRelevantInfo(pRef, gName, pName, description, fundingGoal, fundingAmount, location, categories, goalTitles, goalValues, pictureID, money.ToString(), members.ToString());
            //project.transform.GetComponent<ProjectInformation> ().SetInformation (pRef, gName, pName, description, fundingGoal, fundingAmount, location, categories, goalTitles, goalValues, pictureID);
        });
    }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    public void SetDoerBalance(string target, string value)
    {
        DataRef.Projects(target).Child("Funds").SetValueAsync(value).ContinueWith(async(task) => { await new WaitForUpdate(); });
    }