Beispiel #1
0
    void Awake()
    {
        // Announce existance
        World.worldRenderer = this;

        // Prepare sprites
        TileInfo.BuildSpriteDictionary();
        BackInfo.BuildSpriteDictionary();

        // Acquire camera
        cam = Camera.main;

        // Prepare empty structures of Renderer pooling
        activeTileRenderers = new Dictionary <Coordinate, TileRenderer>();
        activeWireRenderers = new Dictionary <Coordinate, TileRenderer>();
        activeBackRenderers = new Dictionary <Coordinate, TileRenderer>();
        freeRenderers       = new Queue <TileRenderer>();
        coordinatesToCheck  = new HashSet <Coordinate>();

        // Populate Renderer pool
        CreateRenderers(500);
    }
Beispiel #2
0
            UnAttrRst UnIntUdpServer.upSuccess(EndPoint point, UnUdpEntity entity)
            {
                // 转正式文件
                string dicName = DateTime.Now.ToString("yyyy-MM-dd") + "/" + entity.HashCode + entity.Extent;
                string newPath = Img1_Path + dicName;
                UnFile.move(entity.TmpPath, newPath, true);

                // 自定义返回
                BackInfo bi = new BackInfo();
                bi.ReturnCode = 1;
                bi.ReturnMsg = "上传成功";
                bi.MD5 = entity.HashCode;
                bi.Url = Img1_Domain + dicName;

                UnAttrRst rst = new UnAttrRst();
                rst.back = UnXMMPXml.tToXml(typeof(BackInfo), bi);

                Console.WriteLine("***************上传成功***************");
                Console.WriteLine("【路径】" + newPath);
                Console.WriteLine("【URL】" + bi.Url);
                return rst;
            }
Beispiel #3
0
            UnAttrRst UnIntUdpServer.upStart(EndPoint point, UnUdpEntity entity)
            {
                UnAttrRst rst = new UnAttrRst();
                BackInfo bi = new BackInfo();

                // 类型检测
                if (fileTypes.IndexOf(".*") < 0 && ("," + fileTypes.ToLower() + ",").IndexOf("," + entity.Extent.ToLower() + ",") < 0)
                {
                    bi.ReturnCode = -1;
                    bi.ReturnMsg = "只允许: " + fileTypes + " 格式";

                    rst.code = -1;
                    rst.msg = "文件类型错误";
                    rst.back = UnXMMPXml.tToXml(typeof(BackInfo), bi);
                    return rst;
                }
                // 大小检测
                if (entity.TotalSize > fileSize)
                {
                    bi.ReturnCode = -2;
                    bi.ReturnMsg = "文件超过: " + fileSize + " 字节";

                    rst.code = -2;
                    rst.msg = "文件大小错误";
                    rst.back = UnXMMPXml.tToXml(typeof(BackInfo), bi);
                    return rst;
                }
                // 查询文件是否已存在
                UnFileInfo fi = UnFile.findFromDir(Img1_Path, entity.HashCode);
                if (fi != null)
                {
                    bi.ReturnCode = 2;
                    bi.ReturnMsg = "极速秒传";
                    bi.MD5 = entity.HashCode;
                    bi.Url = Img1_Domain + fi.fullName.Replace(Img1_Path, "");

                    rst.code = 1;
                    rst.msg = "传输完成";
                    rst.back = UnXMMPXml.tToXml(typeof(BackInfo), bi);

                    Console.WriteLine("***************极速秒传***************");
                    Console.WriteLine("【路径】" + fi.fullName);
                    Console.WriteLine("【URL】" + bi.Url);

                    return rst;
                }
                return null;
            }
Beispiel #4
0
        // 获取文件
        public void getFile(HttpContext context)
        {
            UnAttrRst rst = new UnAttrRst();
            string type = context.Request["type"];
            long allowSize = 0;
            string allowType = "";
            switch (type)
            {
                case "Image":
                    allowSize = 1024 * 1024;
                    allowType = ".jpg,.jpeg,.png,.gif,.bmp";
                    break;
                case "File":
                    allowSize = 1024 * 1024;
                    allowType = ".txt,.rar,.zip";
                    break;
                default:
                    break;
            }
            HttpPostedFile hpf = context.Request.Files[0];
            if (hpf.ContentLength > 0)
            {
                if (hpf.ContentLength <= allowSize)
                {
                    string ext = System.IO.Path.GetExtension(hpf.FileName).ToLower();
                    var imp = UnFileEvent.important;
                    var name = UnStrRan.getRandom() + ext;
                    string UpPath = imp.fullPath() + "/" + name;
                    DirectoryInfo di = new DirectoryInfo(UnFileEvent.important.fullPath());
                    if (di.Exists == false)
                    {
                        di.Create();
                    }
                    hpf.SaveAs(UpPath);

                    UnFileInfo fi = new UnFileInfo(UpPath, null, allowType, null);
                    if (!fi.isWrongExtens && !fi.isWrongType)
                    {
                        rst.pid = 0;
                        rst.code = 1;
                        rst.msg = "上传成功";

                        BackInfo bi = new BackInfo();
                        switch (type)
                        {
                            case "Image":
                                bi.ReturnCode = 1;
                                bi.ReturnMsg = "传输完成";
                                bi.Url = ImgPath + imp.floder() + "/" + name;
                                break;
                            case "File":
                                bi.ReturnCode = 2;
                                bi.ReturnMsg = "传输完成";
                                bi.UNCode = "UNCODE//:" + UnEncDES.encrypt(UpPath);
                                break;
                            default:
                                break;
                        }
                        rst.back = UnXMMPXml.tToXml(typeof(BackInfo), bi);
                    }
                    else
                    {
                        File.Delete(fi.fullName);
                        rst.pid = 0;
                        rst.code = -3;
                        rst.msg = "允许类型:" + allowType;
                    }
                }
                else
                {
                    rst.pid = 0;
                    rst.code = -2;
                    rst.msg = "不能超过 " + allowSize / 1024 + "KB";
                }
            }
            else
            {
                rst.pid = 0;
                rst.code = -1;
                rst.msg = "文件不存在";
                rst.back = "";
            }

            context.Response.ContentType = "text/xml";
            var xml = UnXMMPXml.tToXml(typeof(UnAttrRst), rst);
            context.Response.Write(xml);
        }