示例#1
0
    /// <summary>初期化</summary>
    private void Awake()
    {
        CanvasRect = GetComponentInParent <Canvas> ().GetComponent <RectTransform> ();
        ImageRect  = Image.GetComponent <RectTransform> ();
        var sprite = Image.sprite;

        ImageSize  = sprite.bounds.size * sprite.pixelsPerUnit;
        LastMethod = Method;
    }
示例#2
0
    /// <summary>
    /// 获取扇形重要点  (三个顶点,以及正方向上的N个点)
    /// </summary>
    private Vector3[] GetSectorPoints(Area area)
    {
        //float l_offest = area.radius * (1 - Mathf.Cos(area.angle * 0.5f * Mathf.Deg2Rad)); //弧形与三角形差距的补偿值
        float   l_offest     = 0;
        Vector3 l_v3_forward = area.direction; //扇形的正方向

        areaPoints[0] = area.position;
        areaPoints[1] = ExpandMethod.Vector3RotateInXZ(l_v3_forward, area.angle * 0.5f).normalized *(area.radius + l_offest) + area.position;
        areaPoints[2] = ExpandMethod.Vector3RotateInXZ2(l_v3_forward, area.angle * 0.5f).normalized *(area.radius + l_offest) + area.position;

        float step = 1 / (float)(6);

        for (int i = 3; i < 9; i++)
        {
            areaPoints[i] = area.position + area.direction * area.radius * (step * (i - 2));
        }

        return(areaPoints);
    }
示例#3
0
 /// <summary>駆動</summary>
 private void Update()
 {
     if (LastCanvasSize != CanvasRect.sizeDelta || LastMethod != Method)
     {
         LastCanvasSize = CanvasRect.sizeDelta;
         var narrow = (((float)LastCanvasSize.y / LastCanvasSize.x) <= (ImageSize.y / ImageSize.x));
         if (Method == ExpandMethod.Stretch)
         {
             ImageRect.sizeDelta = LastCanvasSize;
         }
         else
         {
             ImageRect.sizeDelta = ((Method == ExpandMethod.Fill && narrow) || (Method == ExpandMethod.Fit && !narrow)) ?
                                   new Vector2(LastCanvasSize.x, ImageSize.y * LastCanvasSize.x / ImageSize.x) :
                                   new Vector2(ImageSize.x * LastCanvasSize.y / ImageSize.y, LastCanvasSize.y);
         }
         LastMethod = Method;
     }
 }
示例#4
0
        /// <summary>
        /// 管理员登录操作
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="GetLoginIp"></param>
        /// <returns></returns>
        public ResultMsg ManagerLogin(LoginModelRequest Model, string GetLoginIp = "127.0.0.1")
        {
            Sys_Manager managerModel = baseDAL.GetModelAll<Sys_Manager>("Name=@Name", new { Name = Model.UserName });

            //检查用户是否存在
            if (managerModel == null)
            {
                return ReturnHelpMethod.ReturnWarning((int)HttpCodeEnum.Http_1002);
            }

            //检查密码
            string PassWord = DESEncryptMethod.Encrypt(Model.PassWord, managerModel.RandomCode);
            if (PassWord != managerModel.Password)
            {
                return ReturnHelpMethod.ReturnWarning((int)HttpCodeEnum.Http_1002);
            }

            //查询用户角色
            Sys_ManagerRole managerroleModel = baseDAL.GetModelById<Sys_ManagerRole>(managerModel.RelationId);

            //返回管理员信息
            ManagerReturnModel adminModel = new ManagerReturnModel()
            {
                UserId = managerModel.Id,
                AdminName = String.IsNullOrEmpty(managerModel.Nickname) ? managerModel.Name : managerModel.Nickname,
                Avatar = managerModel.Avatar,
                RoleName = managerroleModel.RoleName,
                RegisteTime = managerroleModel.AddTime.Value,
            };

            //登录成功报存管理员信息
            string Token = DESEncryptMethod.Encrypt(managerModel.Id.ToString(), ExpandMethod.GetTimeStamp());

            //处理单点登录问题
            //if (!String.IsNullOrEmpty(managerModel.TokenId))
            //{
            //    redis.KeyDelete(managerModel.TokenId);
            //}

            managerModel.TokenId = Token;
            managerModel.LoginTimes = managerModel.LoginTimes + 1;
            managerModel.LastLoginIP = GetLoginIp;
            managerModel.LastLoginTime = DateTime.Now;

            RedisManagerModel redisManagerModel = new RedisManagerModel()
            {
                Id = managerModel.Id,
                RelationId = managerModel.RelationId,
                Name = managerModel.Name,
                Avatar = managerModel.Avatar,
                Nickname = managerModel.Nickname,
                Phone = managerModel.Phone,
                Email = managerModel.Email,
                LoginTimes = managerModel.LoginTimes,
                LastLoginIP = managerModel.LastLoginIP,
                LastLoginTime = managerModel.LastLoginTime,
                IsDefault = managerModel.IsDefault,
                Remarks = managerModel.Remarks,
            };

            redis.StringSet(Token, redisManagerModel, TimeSpan.FromMinutes(30));

            baseDAL.UpdateModel<Sys_Manager>(managerModel);

            return ReturnHelpMethod.ReturnSuccess((int)HttpCodeEnum.Http_1001, new { Data = adminModel, Token = Token });
        }
示例#5
0
 public static long Move(this Stream stream, long destination, long count, int buffSize, ExpandMethod expandMethod)
 {
     return(Move(stream, destination, count, buffSize, expandMethod, null, 0L));
 }
示例#6
0
        public static void Move(this Stream stream, long destination, long count, int buffSize, ExpandMethod expandMethod, IProgress <double> progress, double unitPart)
        {
            if (unitPart < 0 || unitPart > 1)
            {
                throw new ArgumentOutOfRangeException("unitPart");
            }

            Move(stream, destination, count, buffSize, expandMethod, progress != null ? new Progress <long>(t => progress.Report((double)t / (double)count)) : null, (long)(count * unitPart));
        }
示例#7
0
        public static long Move(this Stream stream, long destination, long count, int buffSize, ExpandMethod expandMethod, IProgress <long> progress, long unitSize)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            long source = stream.Position;

            if (destination < 0)
            {
                throw new ArgumentOutOfRangeException("destination");
            }
            if (count < 0 || count > stream.Length - source)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (buffSize <= 0)
            {
                throw new ArgumentOutOfRangeException("bufferSize");
            }
            if (unitSize < 0)
            {
                throw new ArgumentOutOfRangeException("unitSize");
            }

            bool reverse = source < destination;
            long total   = 0L;
            long before  = 0L;
            int  read;

            byte[] buffer = new byte[buffSize];
            if (reverse)
            {
                if (stream.Length < destination + count)
                {
                    switch (expandMethod)
                    {
                    case ExpandMethod.SetLength:
                        stream.SetLength(destination + count);
                        break;

                    case ExpandMethod.WriteZero:
                    {
                        stream.Position = stream.Length;
                        long length = destination + count - stream.Length;
                        while (length > 0L)
                        {
                            int block = (int)Comparable.Min(length, (long)filler.Length);
                            stream.Write(filler, 0, block);
                            length -= block;
                        }
                    }
                    break;
                    }
                }
                stream.Position = source + count - Comparable.Min(count, buffer.Length);
            }
            while (total < count && (read = stream.Read(buffer, 0, (int)Comparable.Min(count - total, buffer.Length))) > 0)
            {
                stream.Position = destination + (reverse ? count - total - read : total);
                stream.Write(buffer, 0, read);
                stream.Position = source + (reverse ? count - total - read : total);
                total          += read;
                if (progress != null && total - before >= unitSize)
                {
                    before = total;
                    progress.Report(total);
                }
            }
            return(total);
        }
示例#8
0
 public PoolData(PoolData poolData)
 {
     this.objectPrefab     = poolData.objectPrefab;
     this.initialPoolCount = poolData.initialPoolCount;
     this.expandMethod     = poolData.expandMethod;
 }