コード例 #1
0
    void sourceUpdate()
    {
        foreach (ResourceType type in Enum.GetValues(typeof(ResourceType)))
        {
            int te = (int)type;

            //print(AssignJob.instance.assign.AssignList.Count);
            AssignID temp = AssignJob.instance.assign.AssignList[te];
            Text     text = GameObject.Find("Canvas/Source(" + te + ")/Text").GetComponent <Text>();


            var rate  = temp.LevelDataList.Find((x) => { return(x.Level == 0); });
            var rate2 = rate.Output.Find((x) => { return(x.RourceName == (ResourceType)te); });
            instance.Resour[0].ResourceQuantity += (rate2.ResourceQuantity + 1) * (temp.Quantity + 1);

            text.text = (instance.Resour[0].ResourceQuantity).ToString();
        }
    }
コード例 #2
0
    void initialisze()
    {
        //初始化资源  shuliang Uplimit waiyi



        foreach (AssignType type in Enum.GetValues(typeof(AssignType)))//job assign
        {
            AssignID asID = new AssignID();
            asID.UpLimit      = upLimit;
            asID.Quantity     = 0;
            asID.ID           = type;
            asID.CurrentLevel = 0;
            for (int i = 0; i < upLimit; i++)//level
            {
                LevelData lData = new LevelData();
                Resource  rs    = new Resource();

                rs.ResourceQuantity = 1 * i;
                rs.RourceName       = (ResourceType)(int)type;

                lData.Level = i;
                lData.Output.Add(rs);
                lData.RequestedSource.Add(rs);
                //  lData.RequestedSource.Add(rs);
                lData.UpSource.Add(rs);
                asID.LevelDataList.Add(lData);
            }
            assign.AssignList.Add(asID);
        }

        //写入Json
        string json = JsonMapper.ToJson(assign);

        string fp = "info.json";

        File.WriteAllText(fp, json);
        //读取json
        //  string Tson =  File.ReadAllText("info.json");
        // List <LevelData> player2 = JsonMapper.ToObject<List<LevelData>>(Tson);
        // print(player2);
    }