public void applyOnCard(string json)
    {
        print(json);
        GameObject     modelRessource        = GameObject.Find("ModelRessource");
        ModelRessource modelResScr           = modelRessource.GetComponent <ModelRessource>();
        Dictionary <string, string> cardData = new Dictionary <string, string>();
        Dictionary <string, object> resp     = DeserializeJson <Dictionary <string, object> >(json);

        cardData.Add("name", resp["name"].ToString());
        cardData.Add("description", resp["description"].ToString());
        cardData.Add("fk_id_project", resp["fk_id_project"].ToString());
        //txtPhases.GetComponent<TextMeshProUGUI>().text = phases.FirstOrDefault(x => x.Value == resp["fk_id_phase"].ToString()).Key;
        List <object> assocData = DeserializeJson <List <object> >(resp["associations"].ToString());

        inputName.GetComponent <TMP_InputField>().text = cardData["name"];
        inputDesc.GetComponent <TMP_InputField>().text = cardData["description"];
        Dictionary <int, Dictionary <string, string> > assocList = new Dictionary <int, Dictionary <string, string> >();
        int i = 0;

        foreach (object obj in assocData)
        {
            Dictionary <string, object> assocResp = DeserializeJson <Dictionary <string, object> >(obj.ToString());
            Dictionary <string, string> assoc     = new Dictionary <string, string>();

            assoc.Add("idr", assocResp["idr"].ToString());
            assoc.Add("value", assocResp["value"].ToString());
            assoc.Add("posX", assocResp["posX"].ToString());
            assoc.Add("posY", assocResp["posY"].ToString());

            assocList.Add(i, assoc);
            i++;
        }
        foreach (KeyValuePair <int, Dictionary <string, string> > assoc in assocList)
        {
            GameObject  dragable    = Instantiate(dragRessource) as GameObject;
            DragAndDrop dragableScr = dragable.GetComponent <DragAndDrop>();
            dragableScr.setAssocId(int.Parse(assoc.Value["idr"]));
            dragableScr.setCardId(cardId);
            dragableScr.setRessourceId(int.Parse(assoc.Value["idr"]));
            dragableScr.setProjectId(projectId);
            dragableScr.setProjectName(projectName);
            dragableScr.setTrash(trash);
            dragableScr.setValue(int.Parse(assoc.Value["value"]));
            dragableScr.setLinked(true);
            dragable.transform.SetParent(cardVisual.transform, false);
            modelResScr.find(int.Parse(assoc.Value["idr"]), projectName, null, setRessourceOnCardSprite, dragable);
            dragableScr.setPosition(float.Parse(assoc.Value["posX"]), float.Parse(assoc.Value["posY"]));
        }
    }
示例#2
0
    public override void apply()
    {
        int    id          = int.Parse(args["id"]);
        string projectName = args["project_name"];

        model = GameObject.Find("ModelRessource");
        ModelRessource modelScr = model.GetComponent <ModelRessource>();

        modelScr.find(id, projectName, applyInServerResponse);
        ConfirmModifyRessource butScr = confirmButton.GetComponent <ConfirmModifyRessource>();

        butScr.setIdToModify(id);
        butScr.setProjectId(args["project_id"]);
        butScr.setProjectName(projectName);
        RemoveRessourceButton rmButScr = removeButton.GetComponent <RemoveRessourceButton>();

        rmButScr.setProjectId(args["project_id"]);
        rmButScr.setProjectName(projectName);
        rmButScr.setIdToRemove(id);
    }