private void CollectFoods(GameObject foodSet = null)
 {
     GameObject[] foods = null;
     if (foodSet == null)
     {
         foods = GameObject.FindGameObjectsWithTag("Goods");
     }
     else
     {
         foods = new GameObject[foodSet.transform.childCount];
         for (int i = 0; i < foods.Length; i++)
         {
             foods[i] = foodSet.transform.GetChild(i).gameObject;
         }
     }
     condition             = new TaskCondition();
     condition.collectType = typeof(Food);
     condition.collectNum  = Random.Range(1, 10);
     for (int i = 0; i < condition.collectNum; i++)
     {
         foods[i].transform.position  = Random.insideUnitCircle * 3;
         foods[i].transform.position += foodSet == null ? Vector3.right * 3 : foodSet.transform.position;
         foods[i].SetActive(true);
     }
     OtherTool.SetText("ContentText", string.Format("任务内容:收集{0}个食物", condition.collectNum));
     workers = new GameObject[] { GameObject.Find("Sirika") };
 }
Ejemplo n.º 2
0
    public static int[] String2IntArray(string data, string split = "-")
    {
        string[] strArray = data.Split(split[0]);

        int[] ret = new int[strArray.Length];

        for (int i = 0; i < strArray.Length; ++i)
        {
            ret[i] = OtherTool.String2Int(strArray[i]);
        }

        return(ret);
    }
Ejemplo n.º 3
0
    public static Dictionary <string, string> GetUrlParmDict(string parmStr)
    {
        List <string> parmList             = OtherTool.String2ListString(parmStr, "&");
        Dictionary <string, string> kVDict = new Dictionary <string, string>();

        for (int i = 0; i < parmList.Count; ++i)
        {
            List <string> parms = OtherTool.String2ListString(parmList[i], "=");
            if (parms.Count == 2)
            {
                kVDict.Add(parms[0], parms[1]);
            }
        }
        return(kVDict);
    }
Ejemplo n.º 4
0
    public static List <bool> String2ListBool(string value, string splitter = ";")
    {
        List <bool> list = new List <bool>();

        if (string.IsNullOrEmpty(value) || splitter == null)
        {
            return(list);
        }

        string[] strArray = value.Split(splitter[0]);

        for (int i = 0; i < strArray.Length; i++)
        {
            list.Add(OtherTool.String2Bool(strArray[i]));
        }

        return(list);
    }
Ejemplo n.º 5
0
    public static int QueryIntArgs(object[] args, int index)
    {
        if (null == args || args.Length <= index)
        {
            return(0);
        }

        object obj = args[index];

        if (obj is int)
        {
            return((int)obj);
        }
        else if (obj is string)
        {
            return(OtherTool.String2Int((string)obj));
        }

        return(0);
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(pickUpKey))
        {
            GameObject[] canPickUpGameObjs = OtherTool.FindGameObjectsWithTags(tags);
            float        sqrRadius         = radius * radius;
            int          pickUpGameObjIdx  = -1;
            for (int i = 0; i < canPickUpGameObjs.Length; i++)
            {
                float sqrDistance = (canPickUpGameObjs[i].transform.position - transform.position).sqrMagnitude;
                if (sqrDistance <= sqrRadius)
                {
                    sqrRadius        = sqrDistance;
                    pickUpGameObjIdx = i;
                }
            }

            if (pickUpGameObjIdx >= 0)
            {
                canPickUpGameObjs[pickUpGameObjIdx].transform.parent = transform;
                canPickUpGameObjs[pickUpGameObjIdx].SetActive(false);
            }
        }
    }
Ejemplo n.º 7
0
    //发布文章
    protected void btnPublish_Click(object sender, EventArgs e)
    {
        string   artTitle   = txtArtTitle.Text;                    //文章标题
        int      artType    = int.Parse(ddlArtType.SelectedValue); //文章类别
        DateTime artPubTime = DateTime.Now;                        //文章发布时间
        //string artContent = CKEditorControl1.Text; //文章内容
        string artContent = Request.Params["content"];             //文章内容

        int       maxOrder = 0;
        string    sqlQuery = string.Format("select max(ArtOrder) from T_ARTICLE where ArtType={0}", artType);
        DataTable dtQuery  = SqlServerHooker.GetDataTable(sqlQuery);

        if (dtQuery == null || dtQuery.Rows[0][0].ToString() == "")
        {
            maxOrder = 1;
        }
        else
        {
            maxOrder = (int)dtQuery.Rows[0][0] + 1;
        }

        bool isSuc = true;

        if (radioList.SelectedIndex == 0) //新增文章
        {
            string sqlInsert = string.Format("insert into T_ARTICLE(ID,ArtType,ArtTitle,ArtDate,ArtContent,ArtOrder) values('{0}',{1},'{2}','{3}','{4}',{5})", Guid.NewGuid(), artType,
                                             artTitle, artPubTime.ToString("yyyy-MM-dd HH:mm:ss"), artContent, maxOrder);
            isSuc = SqlServerHooker.InsertDataToTable(sqlInsert);
        }
        else //更新文章
        {
            string sqlUpdate = string.Format("update T_ARTICLE set ArtType={0},ArtTitle='{1}',ArtContent='{2}' where ID='{3}'", artType,
                                             artTitle, artContent, _selectArtID);
            isSuc = SqlServerHooker.InsertDataToTable(sqlUpdate);
        }

        //生成静态html网页
        string url  = string.Format("http://127.0.0.1:8080/article/detail?type={0}&order={1}", artType, maxOrder);
        string id   = OtherTool.GuidTo16String();
        string path = Server.MapPath(string.Format("~/article/{0}.html", id));

        CreateStaticHtml.ReturnStaticHtml(url, path);

        //上传html文件
        bool isUpdateSuc = _ftpManager.UploadFile(path, "article/");

        File.Delete(path);

        //上传图片
        string ftpPath  = "ueditor/net/upload/image/";
        string imageDir = Server.MapPath("~/artpublish/ueditor/net/upload/image/");

        string[] filePaths  = Directory.GetFiles(imageDir);
        string   imageNames = string.Empty;

        foreach (string filePath in filePaths)
        {
            //压缩图片
            string newFilePath = Path.GetDirectoryName(filePath) + "\\" + Path.GetFileNameWithoutExtension(filePath) + "new" + Path.GetExtension(filePath);
            ResizeImage.GetPicThumbnail(filePath, newFilePath, 222, 650, 100);
            FileInfo fileInfo = new FileInfo(newFilePath);
            fileInfo.MoveTo(filePath);

            imageNames += Path.GetFileName(filePath) + ";";
            _ftpManager.UploadFile(filePath, ftpPath);

            File.Delete(filePath);
        }
        if (imageNames.Length > 0)
        {
            imageNames = imageNames.Remove(imageNames.Length - 1, 1);
        }

        string sqlUpdateUrl = string.Format("update T_ARTICLE set ArtUrl='{0}',ArtContent='',ArtImages='{3}' where ArtType={1} and ArtOrder={2}", id, artType, maxOrder, imageNames);

        isSuc = SqlServerHooker.UpdateDataToTable(sqlUpdateUrl);

        if (isSuc)
        {
            div_text.InnerText = isUpdateSuc.ToString() + "发布成功!";
            gvArtManager.DataBind();
        }
        else
        {
            div_text.InnerText = "发布失败!";
        }
    }