Esempio n. 1
0
        /// <summary>
        /// 新增一筆活動資料
        /// </summary>
        /// <param name="myActivatyVO">活動資料型別物件</param>
        /// <returns>新增一筆活動資料</returns>
        public int INSERT_NewOne(VO.ActivatyVO myActivatyVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[4];

            sqlParams[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
            sqlParams[0].Value = myActivatyVO.id;
            sqlParams[1] = new SqlParameter("@activity_type", SqlDbType.NChar, 1);
            sqlParams[1].Value = myActivatyVO.activity_type;
            sqlParams[2] = new SqlParameter("@activity_info", SqlDbType.NText);
            sqlParams[2].Value = myActivatyVO.activity_info;
            sqlParams[3] = new SqlParameter("@emp_id", SqlDbType.NVarChar, myActivatyVO.emp_id.Length );
            sqlParams[3].Value = myActivatyVO.emp_id;

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("INSERT Activity ");
            //sb.AppendLine("([id],[activity_info],[activity_name],[activity_type],[people_type],[activity_startdate],[activity_enddate],[limit_count],[limit2_count],[team_member_max],[team_member_min],[regist_deadline],[cancelregist_deadline],[is_showfile],[is_showprogress],[is_showextpeoplecount],[is_showremark],[is_grouplimit]) ");
            //sb.AppendLine("SELECT ");
            //sb.AppendLine("(@id,@activity_info,@activity_name,@activity_type,@people_type,@activity_startdate,@activity_enddate,@limit_count,@limit2_count,@team_member_max,@team_member_min,@regist_deadline,@cancelregist_deadline,@is_showfile,@is_showprogress,@is_showextpeoplecount,@is_showremark,@is_grouplimit) ");

            sb.AppendLine("INSERT Activity ");
            sb.AppendLine("([id],[activity_type],[activity_info],[org_id],[activity_name],[people_type],[activity_startdate],[activity_enddate],[limit_count],[limit2_count],[team_member_max],[team_member_min],[regist_startdate],[regist_deadline],[cancelregist_deadline],[is_showfile],[is_showprogress],[is_showperson_fix1],[is_showperson_fix2],[personextcount_max],[personextcount_min],[is_showidno],[is_showremark],[remark_name],[is_showteam_fix1],[is_showteam_fix2],[teamextcount_max],[teamextcount_min],[is_grouplimit],[notice],[active],[emp_id]) ");
            sb.AppendLine("VALUES ");
            sb.AppendLine("(@id,@activity_type,'','','','',null,null,null,null,null,null,null,null,null,'N','N','N','N',null,null,'N','N','','N','N',null,null,'N','',null,@emp_id) ");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 2
0
 public void Add(VO vo)
 {
     if (length >= buffer.Length)
     {
         var nbuffer = new VO[buffer.Length * 2];
         buffer.CopyTo(nbuffer, 0);
         buffer = nbuffer;
     }
     buffer[length++] = vo;
 }
Esempio n. 3
0
 public override void copyWrapProperty(WrapProperty otherWrapProperty)
 {
     if (otherWrapProperty != null && otherWrapProperty is VO <T> )
     {
         VO <T> otherVP = (VO <T>)otherWrapProperty;
         this.v = otherVP.v;
     }
     else
     {
         Logger.LogError("why not the same type wrapProperty: " + this + "; " + otherWrapProperty);
     }
 }
Esempio n. 4
0
        void GenerateObstacleVOs(VOBuffer vos)
        {
            var range = maxSpeed * obstacleTimeHorizon;

            // Iterate through all obstacles that we might need to avoid
            for (int i = 0; i < simulator.obstacles.Count; i++)
            {
                var obstacle = simulator.obstacles[i];
                var vertex   = obstacle;
                // Iterate through all edges (defined by vertex and vertex.dir) in the obstacle
                do
                {
                    // Ignore the edge if the agent should not collide with it
                    if (vertex.ignore || (vertex.layer & collidesWith) == 0)
                    {
                        vertex = vertex.next;
                        continue;
                    }

                    // Start and end points of the current segment
                    float elevation1, elevation2;
                    var   p1 = To2D(vertex.position, out elevation1);
                    var   p2 = To2D(vertex.next.position, out elevation2);

                    Vector2 dir = (p2 - p1).normalized;

                    // Signed distance from the line (not segment, lines are infinite)
                    // TODO: Can be optimized
                    float dist = VO.SignedDistanceFromLine(p1, dir, position);

                    if (dist >= -0.01f && dist < range)
                    {
                        float factorAlongSegment = Vector2.Dot(position - p1, p2 - p1) / (p2 - p1).sqrMagnitude;

                        // Calculate the elevation (y) coordinate of the point on the segment closest to the agent
                        var segmentY = Mathf.Lerp(elevation1, elevation2, factorAlongSegment);

                        // Calculate distance from the segment (not line)
                        var sqrDistToSegment = (Vector2.Lerp(p1, p2, factorAlongSegment) - position).sqrMagnitude;

                        // Ignore the segment if it is too far away
                        // or the agent is too high up (or too far down) on the elevation axis (usually y axis) to avoid it.
                        // If the XY plane is used then all elevation checks are disabled
                        if (sqrDistToSegment < range * range && (simulator.movementPlane == MovementPlane.XY || (elevationCoordinate <= segmentY + vertex.height && elevationCoordinate + height >= segmentY)))
                        {
                            vos.Add(VO.SegmentObstacle(p2 - position, p1 - position, Vector2.zero, radius * 0.01f, 1f / ObstacleTimeHorizon, 1f / simulator.DeltaTime));
                        }
                    }

                    vertex = vertex.next;
                } while (vertex != obstacle && vertex != null && vertex.next != null);
            }
        }
    public DataDecoder(byte[] data, VO entity = null)
    {
        memoryStream = new MemoryStream(data);

        if (entity == null)
        {
            int    clazzIdentifer = readByte2();
            string clazzName      = VoIdentiferMap [clazzIdentifer];
            //根据名称反射其对象
            entity = VO.createVO(clazzName);
        }
        this.entity = entity;
    }
        /// <summary>
        /// 刪除1筆角色對應資料
        /// </summary>
        /// <param name="myRoleUserMappingVO">角色對應型別物件</param>
        /// <returns>刪除1筆角色對應資料</returns>
        public int DeleteRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[1];

            sqlParams[0] = new SqlParameter("@id", SqlDbType.Int);
            sqlParams[0].Value = myRoleUserMappingVO.id;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("DELETE RoleUserMapping WHERE id=@id;");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 7
0
        /// <summary>
        /// 新增主辦單位資料
        /// </summary>
        /// <param name="myUnitVO">主辦單位資料型別物件</param>
        /// <returns>新增主辦單位資料</returns>
        public int InsertUnit(VO.UnitVO myUnitVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[1];

            sqlParams[0] = new SqlParameter("@name", SqlDbType.NVarChar, 50);
            sqlParams[0].Value = myUnitVO.name;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT Unit (name,active) Values (@name,'Y'); ");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 8
0
        public virtual List <T> GetAll()
        {
            List <T> result = dataAccessObject.GetAll();

            Close();

            if (result.Count > 0 && ((result[0] is NameBasedVO && !(result[0] is FileVO)) || (result[0] is UserVO)))
            {
                result.Sort(VO.GetSorter <VO>());
            }

            return(result);
        }
Esempio n. 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="vo">The offset of the sine wave</param>
 /// <param name="va">The amplitude of the sine wave</param>
 /// <param name="freq">The frequency in Hz</param>
 /// <param name="td">The delay in seconds</param>
 /// <param name="theta">The damping factor</param>
 public Sine(double vo, double va, double freq, double td = double.NaN, double theta = double.NaN) : base()
 {
     VO.Set(vo);
     VA.Set(va);
     Freq.Set(freq);
     if (!double.IsNaN(td))
     {
         Delay.Set(td);
     }
     if (!double.IsNaN(theta))
     {
         Theta.Set(theta);
     }
 }
Esempio n. 10
0
    private void write(VO entity)
    {
        Type type = entity.GetType();

        FieldInfo[] fields = type.GetFields();
        foreach (FieldInfo fieldInfo in fields)
        {
            if (!fieldInfo.IsPublic)
            {
                continue;
            }
            bool   primitive = fieldInfo.FieldType.IsPrimitive;
            string varName   = fieldInfo.Name;
            string typeName  = fieldInfo.FieldType.Name;

            if (fieldInfo.FieldType.IsPrimitive)              //int float double long
            {
                writePrimitive(entity, varName, typeName);
                continue;
            }


            //非基本类型: string  object  array
            if (typeName == "String")            //字符串
            {
                writeString(entity.getVarValue <string> (varName), entity.getVarId(varName));
                continue;
            }
            //集合类
            if (typeName == "ArrayList")
            {
                writeArray(entity.getVarValue <ArrayList> (varName), entity.getVarId(varName));
            }

            if (typeName == "VO")
            {
                writeObject(entity.getVarValue <VO> (varName), entity.getVarId(varName), true);
            }
            else
            {
                //通过BaseType来找
                typeName = fieldInfo.FieldType.BaseType.Name;
                if (typeName == "VO")
                {
                    writeObject(entity.getVarValue <VO> (varName), entity.getVarId(varName), true);
                }
            }
            Console.WriteLine(varName + "  " + typeName + "  " + (primitive ? "true" :"false"));
        }
    }
Esempio n. 11
0
 public LocalDataModel()
 {
     _path = Runtime.Ins.localResDir + FILE_NAME;
     if (File.Exists(_path))
     {
         //读取已有的数据
         _vo = LitJson.JsonMapper.ToObject <VO>(File.ReadAllText(_path));
     }
     else
     {
         //新数据初始化
         _vo = new VO();
     }
 }
Esempio n. 12
0
    private void readArray(VO entity)
    {
        int identity           = memoryStream.ReadByte();
        int itemClazzIdentifer = readByte2();

        ArrayList array    = new ArrayList();
        bool      loop     = true;
        long      endIndex = memoryStream.Length - 1;
        int       dataType = 0;

        while (loop && memoryStream.Position <= endIndex)
        {
            dataType = memoryStream.ReadByte();
            if (dataType == (int)DataType.Object)
            {
                string clazzName = VoIdentiferMap [itemClazzIdentifer];
                readObject(array, null);
            }
            else if (dataType == (int)DataType.Array)
            {
                //				readArray ();
                continue;                 //暂不支持数组嵌套
            }
            else if (dataType == (int)DataType.Int32 || dataType == (int)DataType.Int16 ||
                     dataType == (int)DataType.UInt8 || dataType == (int)DataType.UInt16 || dataType == (int)DataType.UInt32 ||
                     dataType == (int)DataType.Double || dataType == (int)DataType.Long || dataType == (int)DataType.Float ||
                     dataType == (int)DataType.Boolean)
            {
                readPrimitive(array, dataType);
            }
            else if (dataType == (int)DataType.StringShort)
            {
                readStringShort(array);
            }
            else if (dataType == (int)DataType.String)
            {
                readString(array);
            }
            else if (dataType == (int)DataType.StringLong)
            {
                readStringLong(array);
            }
            else if (dataType == (int)DataType.Split)
            {
                loop = false;
            }
        }
        entity.setVarValue((byte)identity, array);
    }
Esempio n. 13
0
 public LocalDataModel()
 {
     _path = Runtime.Ins.localResDir + FILE_NAME;
     if (File.Exists(_path))
     {
         //读取已有的数据
         _vo = LitJson.JsonMapper.ToObject <VO>(File.ReadAllText(_path));
     }
     else
     {
         //新数据初始化
         _vo.isInit        = false;
         _vo.localValueDic = new Dictionary <string, string>();
     }
 }
Esempio n. 14
0
        public LocalDataModel()
        {
            _path = FileSystem.CombinePaths(Runtime.Ins.generateFilesDir, FILE_NAME);

            if (File.Exists(_path))
            {
                //读取已有的数据
                _vo = LitJson.JsonMapper.ToObject <VO>(File.ReadAllText(_path));
            }
            else
            {
                //新数据初始化
                _vo = new VO();
            }
        }
Esempio n. 15
0
        //Insert GridView的Insert
        /// <summary>
        /// 新增1筆角色對應資料
        /// </summary>
        /// <param name="myRoleUserMappingVO">角色對應型別物件</param>
        /// <returns>新增1筆角色對應資料</returns>
        public int InsertRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[3];

            sqlParams[0] = new SqlParameter("@role_id", SqlDbType.Int);
            sqlParams[0].Value = myRoleUserMappingVO.role_id;
            sqlParams[1] = new SqlParameter("@unit_id", SqlDbType.Int);
            sqlParams[1].Value = myRoleUserMappingVO.unit_id;
            sqlParams[2] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 100);
            sqlParams[2].Value = myRoleUserMappingVO.emp_id;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT INTO RoleUserMapping  SELECT @role_id,@unit_id,ID FROM V_ACSM_USER2 WHERE ID=@emp_id and status!=2 ; ");

            int Result=-1;

            try
            {
                Result = SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);

                if (Result == 0)
                {
                    clsMyObj.ShowMessage("無法新增此人員!該人員不存在或已離職。");
                }
            }
            catch (Exception ex)
            {
                try
                {
                    if ((ex as System.Data.SqlClient.SqlException).Number == 2627)
                    {
                        clsMyObj.ShowMessage("該角色人員已存在!");
                    }
                    else
                    {
                        throw ex;
                    }

                }
                catch
                {
                    throw ex;
                }
            }

            return Result;
        }
Esempio n. 16
0
    /**
     * 对象编码
     * @param objValue
     * @param identity 标识码
     * 规则: 数据类型+标识码+对象字节+分割符
     * 编码后长度为对象字节+3个字节
     */
    private void writeObject(VO objValue, byte identity = 0, bool writeClazzIdentifer = true)
    {
        if (objValue == null)
        {
            return;
        }
        //写入数据类型
        memoryStream.WriteByte((byte)DataType.Object);
        //写入数据
        DataEncoder encoder = new DataEncoder(objValue, identity, writeClazzIdentifer);

        byte[] data = encoder.encode();
        memoryStream.Write(data, 0, data.Length);
        //写入分隔符
        memoryStream.WriteByte((byte)DataType.Split);
    }
Esempio n. 17
0
        private List <int> GetAssociationsOfTable(VO tableElement, string providedTableColumnName, string requiredTableColumnName)
        {
            List <int> result    = new List <int>();
            string     condition = string.Format("{0} = @{0}", providedTableColumnName);
            string     statement = SqlStatememtGenerator.Select_ReadAllColumnsByCondition(tableName, condition);

            SqlParameter[] parameters = new SqlParameter[] { MakeSqlParameter(providedTableColumnName, tableElement.Id) };
            SqlDataReader  reader     = executer.ExecuteSelectStatement(statement, parameters);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    result.Add(reader.GetInt32(reader.GetOrdinal(requiredTableColumnName)));
                }
            }

            reader.Close();
            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// 新增1筆自訂欄位選項資料
        /// </summary>
        /// <param name="myCustomFieldItemVO">自訂欄位選項資料型別物件</param>
        /// <returns 新增1筆自訂欄位選項資料></returns>
        public int INSERT(VO.CustomFieldItemVO myCustomFieldItemVO)
        {
            //field_item_id欄位自動識別遞增
            SqlParameter[] sqlParams = new SqlParameter[3];

            sqlParams[0] = new SqlParameter("@field_id", SqlDbType.Int);
            sqlParams[0].Value = myCustomFieldItemVO.field_id;
            sqlParams[1] = new SqlParameter("@field_item_name", SqlDbType.NText);
            sqlParams[1].Value = myCustomFieldItemVO.field_item_name;
            sqlParams[2] = new SqlParameter("@field_item_text", SqlDbType.NText);
            sqlParams[2].Value = myCustomFieldItemVO.field_item_text;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT CustomFieldItem ");
            sb.AppendLine("([field_id],[field_item_name],[field_item_text]) ");
            sb.AppendLine("VALUES ");
            sb.AppendLine("(@field_id,@field_item_name,@field_item_text); ");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 19
0
    private void readObject(object entity, VO item = null)
    {
        int identity = 0;

        if (entity is VO)          //读标识
        {
            identity = memoryStream.ReadByte();
        }
        int position = (int)memoryStream.Position;

        byte[] data = new byte[memoryStream.Length - memoryStream.Position];

        memoryStream.Read(data, 0, data.Length);
        DataDecoder decoder = new DataDecoder(data, item);
        VO          vo      = decoder.decode();

        position += decoder.Position;
        memoryStream.Position = position;


        setVarValue(entity, identity, vo);
    }
Esempio n. 20
0
    public DataEncoder(VO entity, byte identity = 0, bool writeClazzIdentifer = true)
    {
        this.entity = entity;

        if (identity == 0)
        {
            identity = (byte)DataType.Default;
        }
        else          //写入标识 ,当标识不等于DataType.Default时
        {
            memoryStream.WriteByte(identity);
        }
        this.identity = identity;

        if (writeClazzIdentifer)
        {
            if (!VoMapping.ContainsKey(entity.GetType().Name))
            {
                int i = 0;
            }
            int clazzIdentifer = VoMapping[entity.GetType().Name];
            writeByte2(clazzIdentifer);
        }
    }
Esempio n. 21
0
 public int DeleteRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO)
 {
     DAO.RoleUserMappingDAO myRoleUserMappingDAO = new ACMS.DAO.RoleUserMappingDAO();
     return myRoleUserMappingDAO.DeleteRoleUserMapping(myRoleUserMappingVO);
 }
Esempio n. 22
0
        public Vector3 ClampMovement(Vector3 direction)
        {
            Vector3 targetDir     = direction * delta;
            Vector3 targetPoint   = transform.position + direction;
            Vector3 bestPoint     = targetPoint;
            float   bestPointDist = 0;

            //float lowestVO = float.PositiveInfinity;
            int lowestVOCounter = 0;


            //List<VO> vos = new List<VO> ();
            vos.Clear();

            float velocityMagn = velocity.magnitude;

            foreach (LocalAvoidance agent in agents)
            {
                if (agent == this || agent == null)
                {
                    continue;
                }


                Vector3 rCenter   = agent.transform.position - transform.position;
                float   dist      = rCenter.magnitude;
                float   doubleRad = (radius + agent.radius);

                if (dist > targetDir.magnitude * delta + doubleRad + velocityMagn + agent.GetVelocity().magnitude)
                {
                    continue;
                }

                if (lowestVOCounter > maxVOCounter)
                {
                    continue;
                }
                else
                {
                    lowestVOCounter++;
                }

                VO vo = new VO();

                vo.origin    = transform.position + Vector3.Lerp(velocity * delta, agent.GetVelocity() * delta, responability);
                vo.direction = rCenter.normalized;



                if (doubleRad > rCenter.magnitude)
                {
                    vo.angle = Mathf.PI * 0.5F;

                    /*vo.limit = dist-doubleRad;
                     * if (vo.limit < 0) {
                     *      vo.limit = 0.001F;
                     * }
                     *
                     * vos.Add (vo);
                     * continue;*/
                    //doubleRad = rCenter.magnitude*0.99F;
                    //continue;
                }
                else
                {
                    vo.angle = (float)Math.Asin(doubleRad / dist);
                }

                //float n = (float)Math.Tan (Math.Asin ((doubleRad)/rCenter.magnitude))*(rCenter.magnitude-doubleRad);
                //Vector3 m = (rCenter.magnitude - doubleRad)*rCenter.normalized;//+(agent.velocity+velocity)/2F;

                /*if (drawGizmos) {
                 *      Debug.DrawLine (transform.position,m,Color.red);
                 *      Debug.Log (n);
                 * }*/
                vo.limit = dist - doubleRad;                //m.magnitude;

                if (vo.limit < 0)
                {
                    vo.origin += vo.direction * (vo.limit);
                    vo.limit   = 0.000F;
                }

                float ax = Mathf.Atan2(vo.direction.z, vo.direction.x);
                vo.pRight = new Vector3(Mathf.Cos(ax + vo.angle), 0, Mathf.Sin(ax + vo.angle));
                vo.pLeft  = new Vector3(Mathf.Cos(ax - vo.angle), 0, Mathf.Sin(ax - vo.angle));

                vo.nLeft  = new Vector3(Mathf.Cos(ax + vo.angle - Mathf.PI * 0.5F), 0, Mathf.Sin(ax + vo.angle - Mathf.PI * 0.5F));
                vo.nRight = new Vector3(Mathf.Cos(ax - vo.angle + Mathf.PI * 0.5F), 0, Mathf.Sin(ax - vo.angle + Mathf.PI * 0.5F));

                //Debug.DrawRay (vo.origin,vo.nLeft,Color.red);
                //Debug.DrawRay (vo.origin,vo.nRight,Color.magenta);

                //vo.limit = Mathf.Min (rCenter.magnitude - doubleRad, rCenter.magnitude/2F);
                //doubleRad /= delta;
                //doubleRad /= 2;

                //vo.limit = doubleRad/Mathf.Tan (vo.angle);

                vos.Add(vo);
            }


            if (resType == ResolutionType.Geometric)
            {
                //Is there any need to run more calculations
                for (int i = 0; i < vos.Count; i++)
                {
                    if (vos[i].Contains(bestPoint))
                    {
                        bestPointDist = float.PositiveInfinity;
                        if (drawGizmos)
                        {
                            Debug.DrawRay(bestPoint, Vector3.down, Color.red);
                        }
                        bestPoint = transform.position;
                        break;
                    }
                }

                if (drawGizmos)
                {
                    for (int i = 0; i < vos.Count; i++)
                    {
                        vos[i].Draw(Color.black);

                        /*if (vos[i].Contains	(testPoint)) {
                         *      Debug.DrawLine (vos[i].origin,testPoint,Color.green);
                         * } else {
                         *      Debug.DrawLine (vos[i].origin,testPoint,Color.red);
                         * }*/
                    }
                }

                if (bestPointDist == 0)
                {
                    return(targetDir);
                }

                List <VOLine> lines = new List <VOLine> ();
                //List<VOIntersection> ints = new List<VOIntersection>();

                for (int i = 0; i < vos.Count; i++)
                {
                    VO vo = vos[i];


                    float a = (float)Math.Atan2(vo.direction.z, vo.direction.x);

                    //Vector3 cross = Vector3.Cross (vo.direction,Vector3.up);
                    //Vector3 p1 = cross*(float)Math.Tan (vo.angle)*vo.limit;

                    Vector3 pLeft  = vo.origin + new Vector3((float)Math.Cos(a + vo.angle), 0, (float)Math.Sin(a + vo.angle)) * vo.limit;
                    Vector3 pRight = vo.origin + new Vector3((float)Math.Cos(a - vo.angle), 0, (float)Math.Sin(a - vo.angle)) * vo.limit;

                    //Vector3 pLeft = vo.origin+vo.direction*vo.limit+p1;
                    //Vector3 pRight = vo.origin+vo.direction*vo.limit-p1;

                    Vector3 pLeft2  = pLeft + new Vector3((float)Math.Cos(a + vo.angle), 0, (float)Math.Sin(a + vo.angle)) * 100;
                    Vector3 pRight2 = pRight + new Vector3((float)Math.Cos(a - vo.angle), 0, (float)Math.Sin(a - vo.angle)) * 100;

                    int IgnoreDirection = Polygon.Left(vo.origin, vo.origin + vo.direction, transform.position + velocity) ? 1 : 2;               //Vector3.Dot (transform.position+velocity-vo.origin,cross) > 0 ? 2 : 1;//(pRight-(transform.position+velocity)).sqrMagnitude < (pLeft-(transform.position+velocity)).sqrMagnitude ? 2 : 1;//Vector3.Dot (pRight-pLeft,transform.position+velocity-pLeft) > 0 ? 1 : 2;

                    lines.Add(new VOLine(vo, pLeft, pLeft2, true, 1, IgnoreDirection == 1));
                    lines.Add(new VOLine(vo, pRight, pRight2, true, 2, IgnoreDirection == 2));
                    lines.Add(new VOLine(vo, pLeft, pRight, false, 3, false));

                    bool pLeftInside  = false;                   // || IgnoreDirection == 1;
                    bool pRightInside = false;                   // || IgnoreDirection == 2;

                    if (!pLeftInside)
                    {
                        for (int q = 0; q < vos.Count; q++)
                        {
                            if (q != i)
                            {
                                if (vos[q].Contains(pLeft))
                                {
                                    pLeftInside = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!pRightInside)
                    {
                        for (int q = 0; q < vos.Count; q++)
                        {
                            if (q != i)
                            {
                                if (vos[q].Contains(pRight))
                                {
                                    pRightInside = true;
                                    break;
                                }
                            }
                        }
                    }

                    vo.AddInt(0, pLeftInside, 1);                   //pLeftInside	|| IgnoreDirection == 1,1);
                    vo.AddInt(0, pRightInside, 2);                  //pRightInside  || IgnoreDirection == 2,2);
                    vo.AddInt(0, pLeftInside, 3);                   //pLeftInside	,3);//@ Ignore shouldn't really be there, but it works better with it of some reason
                    vo.AddInt(1, pRightInside, 3);                  //pRightInside	,3);//@ Ignore shouldn't really be there, but it works better with it of some reason
                }


                for (int i = 0; i < lines.Count; i++)
                {
                    for (int j = i + 1; j < lines.Count; j++)
                    {
                        //if (i==j) continue;

                        VOLine line  = lines[i];
                        VOLine line2 = lines[j];

                        if (line.vo == line2.vo)
                        {
                            continue;
                        }

                        float factor1;
                        float factor2;
                        if (Polygon.IntersectionFactor(line.start, line.end, line2.start, line2.end, out factor1, out factor2))
                        {
                            if (factor1 < 0 || factor2 < 0 || (!line.inf && factor1 > 1) || (!line2.inf && factor2 > 1))
                            {
                                continue;
                            }

                            Vector3 p      = line.start + (line.end - line.start) * factor1;
                            bool    inside = line.wrongSide || line2.wrongSide;
                            if (!inside)
                            {
                                for (int q = 0; q < vos.Count; q++)
                                {
                                    if (vos[q] != line.vo && vos[q] != line2.vo)
                                    {
                                        if (vos[q].Contains(p))
                                        {
                                            inside = true;
                                            break;
                                        }
                                    }
                                }
                            }

                            line.vo.AddInt(factor1, inside, line.id);
                            line2.vo.AddInt(factor2, inside, line2.id);

                            //ints.Add (new VOIntersection (line.vo,line2.vo, factor1, factor2,inside));
                            if (drawGizmos)
                            {
                                Debug.DrawRay(line.start + (line.end - line.start) * factor1, Vector3.up, inside ? Color.magenta : Color.green);
                            }
                        }
                    }
                }

                for (int i = 0; i < vos.Count; i++)
                {
                    Vector3 segmClosest;
                    if (vos[i].FinalInts(targetPoint, transform.position + velocity, drawGizmos, out segmClosest))
                    {
                        float dist = (segmClosest - targetPoint).sqrMagnitude;
                        if (dist < bestPointDist)
                        {
                            bestPoint     = segmClosest;
                            bestPointDist = dist;
                            if (drawGizmos)
                            {
                                Debug.DrawLine(targetPoint + Vector3.up, bestPoint + Vector3.up, Color.red);
                            }
                        }
                    }
                }
                //}


                if (drawGizmos)
                {
                    Debug.DrawLine(targetPoint + Vector3.up, bestPoint + Vector3.up, Color.red);
                }

                return(Vector3.ClampMagnitude(bestPoint - transform.position, targetDir.magnitude * maxSpeedScale));
            }
            else if (resType == ResolutionType.Sampled)
            {
                /*Sampling Solution
                 * ================= */
                Vector3 forward     = targetDir;
                Vector3 normForward = forward.normalized;
                Vector3 right       = Vector3.Cross(normForward, Vector3.up);

                int circleSamples = 10;
                for (int i = 0; i < 10; i++, circleSamples += 2)
                {
                    float radPerSamples = (float)(Math.PI * circlePoint / circleSamples);
                    float offset        = (float)(Math.PI - circlePoint * Math.PI) * 0.5F;

                    for (int j = 0; j < circleSamples; j++)
                    {
                        float   a      = radPerSamples * j;
                        Vector3 sample = transform.position + targetDir - (forward * (float)Math.Sin(a + offset) * i * circleScale + right * (float)Math.Cos(a + offset) * i * circleScale);

                        if (CheckSample(sample, vos))
                        {
                            return(sample - transform.position);
                        }
                    }
                }

                for (int i = 0; i < samples.Length; i++)
                {
                    Vector3 sample = transform.position + samples[i].x * right + samples[i].z * normForward + samples[i].y * forward;

                    if (CheckSample(sample, vos))
                    {
                        return(sample - transform.position);
                    }
                }

                return(Vector3.zero);

                /* End of Sampling Solution
                 * ========================
                 */
            }


            return(Vector3.zero);

            //if (drawGizmos) {


            /*HalfPlane[] hps = new HalfPlane[vos.Count];
             * for (int i=0;i<vos.Count;i++) {
             *      HalfPlane hp = (HalfPlane)vos[i];
             *      hps[i] = hp;
             * }
             *
             * /*HalfPlane hp_top = new HalfPlane ();
             * hp_top.point = transform.position+Vector3.forward*speed;
             * hp_top.normal = -new Vector3 (0.001F,0,1F).normalized;
             * hps[vos.Count+0] = hp_top;
             *
             * HalfPlane hp_bot = new HalfPlane ();
             * hp_bot.point = transform.position-Vector3.forward*speed;
             * hp_bot.normal = new Vector3 (0.001F,0,1F).normalized;
             * hps[vos.Count+1] = hp_bot;
             *
             * HalfPlane hp_left = new HalfPlane ();
             * hp_left.point = transform.position-Vector3.right*speed;
             * hp_left.normal = new Vector3 (1F,0,0.001F).normalized;
             * hps[vos.Count+2] = hp_left;
             *
             * HalfPlane hp_right = new HalfPlane ();
             * hp_right.point = transform.position+Vector3.right*speed;
             * hp_right.normal = -new Vector3 (1F,0,0.001F).normalized;
             * hps[vos.Count+3] = hp_right;*
             *
             * for (int i=0;i<hps.Length;i++) {
             *      if (drawGizmos) { hps[i].Draw (); }
             * }
             *
             * for (int i=0;i<hps.Length;i++) {
             *      HalfPlane hp = hps[i];
             *      if (hp.Contains	(bestPoint)) {
             *              if (drawGizmos) {
             *                      Debug.DrawLine (bestPoint,hp.point,Color.green);
             *              }
             *              continue;
             *      }
             *
             *
             *      Vector3 tangent = Vector3.Cross (hp.normal,Vector3.up);
             *
             *      float leftBound = -100;
             *      float rightBound = 100;
             *
             *      if (tangent.x < 0) {
             *              tangent = -tangent;
             *      }
             *
             *      for (int j=0;j<i;j++) {
             *              HalfPlane hp2 = hps[j];
             *              Vector3 intersection = hp.Intersection (hp2);
             *
             *              float dot = Vector3.Dot (tangent,hp2.normal);
             *              if (dot > 0) {
             *                      leftBound = Mathf.Max (leftBound,intersection.x);
             *              } else if (dot < 0) {
             *                      rightBound = Mathf.Min (rightBound,intersection.x);
             *              } else {
             *                      //Parallel
             *                      if (Vector3.Dot (hp.normal,hp2.normal) < 0) {
             *                              if (drawGizmos) {
             *                                      Debug.DrawLine (bestPoint,hp.point,Color.red);
             *                              }
             *                              return Vector3.zero;
             *                      }
             *              }
             *              /*if (hp.normal.x > hp2.normal.x) {
             *                      if (hp2.normal.x < 0) {
             *                              rightBound = Mathf.Min (intersection.x, rightBound);
             *                      } else {
             *                              leftBound = Mathf.Max (leftBound,intersection.x);
             *                      }
             *              } else if (hp.normal.x < hp2.normal.x) {
             *                      if (hp2.normal.x < 0) {
             *                              leftBound = Mathf.Max (leftBound,intersection.x);
             *                      } else {
             *                              rightBound = Mathf.Min (rightBound,intersection.x);
             *                      }
             *              }*
             *      }
             *
             *      if (drawGizmos) {
             *              hp.DrawBounds (leftBound,rightBound);
             *      }
             *      if (leftBound > rightBound) {
             *              if (drawGizmos) {
             *                      Debug.DrawRay (bestPoint,Vector3.up,Color.red);
             *                      Debug.DrawLine (bestPoint,hp.point,Color.red);
             *              }
             *              return Vector3.zero;
             *      }
             *
             *      Vector3 closest = hp.ClosestPoint (targetPoint,leftBound,rightBound);
             *      if (drawGizmos) {
             *              Debug.DrawLine (bestPoint,closest,Color.red);
             *      }
             *      bestPoint = closest;
             * }
             *
             * return bestPoint-transform.position;*/
        }
Esempio n. 23
0
        /** Traces the vector field constructed out of the velocity obstacles.
         * Returns the position which gives the minimum score (approximately).
          */
        Vector2 Trace(VO[] vos, int voCount, Vector2 p, float cutoff, out float score)
        {

            score = 0;
            float stepScale = simulator.stepScale;

            float bestScore = float.PositiveInfinity;
            Vector2 bestP = p;

            for (int s = 0; s < 50; s++)
            {


                float step = 1.0f - (s / 50.0f);
                step *= stepScale;

                Vector2 dir = Vector2.zero;
                float mx = 0;
                for (int i = 0; i < voCount; i++)
                {
                    float w;
                    Vector2 d = vos[i].Sample(p, out w);
                    dir += d;

                    if (w > mx) mx = w;
                    //mx = System.Math.Max (mx, d.sqrMagnitude);
                }


                // This didn't work out as well as I though
                // Code left here because I might reenable it later
                //Vector2 bonusForDesiredSpeed = p.normalized *  new Vector2(desiredVelocity.x,desiredVelocity.z).magnitude - p;

                Vector2 bonusForDesiredVelocity = (new Vector2(desiredVelocity.x, desiredVelocity.z) - p);

                float weight = bonusForDesiredVelocity.magnitude * DesiredVelocityWeight;// + bonusForDesiredSpeed.magnitude*DesiredSpeedScale;
                dir += bonusForDesiredVelocity * DesiredVelocityScale;// + bonusForDesiredSpeed*DesiredSpeedScale;
                mx = System.Math.Max(mx, weight);


                score = mx;



                if (score < bestScore)
                {
                    bestScore = score;
                }

                bestP = p;
                if (score <= cutoff && s > 10) break;

                float sq = dir.sqrMagnitude;
                if (sq > 0) dir *= mx / Mathf.Sqrt(sq);

                dir *= step;
                Vector2 prev = p;
                p += dir;
                if (DebugDraw) Debug.DrawLine(To3D(prev) + position, To3D(p) + position, Rainbow(0.1f / score) * new Color(1, 1, 1, 0.2f));
            }


            score = bestScore;
            return bestP;
        }
 public void insertRowsEnqueue(VO.TableList tablesList)
 {
     this.dao = getDataBaseDAODB();
     if (tablesList != null && tablesList.Tables != null && tablesList.Tables.Count > 0)
     {
        foreach(VO.Table t in tablesList.Tables)
         {
             String insert = SQLGenerator.getInsertStart(t);
                                
             foreach(VO.Row r in t.Rows)
             {
                 try
                 {
                     RowsInsert.Enqueue(insert + SQLGenerator.insertRow(t.getListColumnsExcluded(), r));
                 }
                 catch(Exception e)
                 {
                     Console.Write(e.Message);
                 }
              }  
         }
        initialSize = RowsInsert.Count;
     }
 }
Esempio n. 25
0
 public static void Play(VO vo)
 {
     instance.Play((int)vo);
 }
Esempio n. 26
0
    /**
     * 基本数据类型  int float double long
     * @param varName
     * @param typeName
     * */
    private void writePrimitive(VO entity, string varName, string typeName)
    {
        byte identity = entity.getVarId(varName);

        if (typeName == "Int32")
        {
            int value = entity.getVarValue <int> (varName);
            if (value == 0)
            {
                return;
            }
            //			writeInt (entity.getVarValue<int> (varName), entity.getVarId (varName));
            if (value >= 0)
            {
                if (value < 256)
                {
                    writeUInt8(value, identity);
                }
                else if (value < 65536)
                {
                    writeUInt16(value, identity);
                }
                else
                {
                    writeInt(value, identity);
                }
            }
            else
            {
                if (value >= -32768)
                {
                    writeInt16(value, identity);
                }
                else
                {
                    writeInt(value, identity);
                }
            }
        }
        else if (typeName == "Double")
        {
            double value = entity.getVarValue <double> (varName);
            if (value == 0)
            {
                return;
            }
            writeDouble(value, identity);
        }
        else if (typeName == "Boolean")
        {
            bool value = entity.getVarValue <bool> (varName);
            writeBoolean(value, identity);
        }
        else if (typeName == "UInt16")
        {
            ushort value = entity.getVarValue <ushort> (varName);
            if (value == 0)
            {
                return;
            }
            writeUInt16(value, identity);
        }
        else if (typeName == "Int16")
        {
            short value = entity.getVarValue <short> (varName);
            if (value == 0)
            {
                return;
            }
            writeInt16(value, identity);
        }
        else if (typeName == "UInt32")
        {
            uint value = entity.getVarValue <uint> (varName);
            if (value == 0)
            {
                return;
            }
            writeUInt(value, identity);
        }
        else if (typeName == "Long")
        {
            long value = entity.getVarValue <long> (varName);
            if (value == 0)
            {
                return;
            }
            writeLong(value, identity);
        }
        else if (typeName == "Int64")
        {
            long value = entity.getVarValue <long> (varName);
            if (value == 0)
            {
                return;
            }
            writeLong(value, identity);
        }
        else if (typeName == "Float")
        {
            float value = entity.getVarValue <float>(varName);
            if (value == 0)
            {
                return;
            }
            writeFloat(value, identity);
        }
    }
Esempio n. 27
0
        /// <summary>
        /// 新增1筆自訂欄資料
        /// </summary>
        /// <param name="myCustomFieldVO">自訂欄資料型別物件</param>
        /// <returns>新增1筆自訂欄資料</returns>
        public int INSERT(VO.CustomFieldVO myCustomFieldVO)
        {
            //field_id欄位自動識別遞增
            SqlParameter[] sqlParams = new SqlParameter[3];

            sqlParams[0] = new SqlParameter("@activity_id", SqlDbType.UniqueIdentifier);
            sqlParams[0].Value = myCustomFieldVO.activity_id;
            sqlParams[1] = new SqlParameter("@field_name", SqlDbType.NText);
            sqlParams[1].Value = myCustomFieldVO.field_name;
            sqlParams[2] = new SqlParameter("@field_control", SqlDbType.NText);
            sqlParams[2].Value = myCustomFieldVO.field_control;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT CustomField ");
            sb.AppendLine("([activity_id],[field_name],[field_control]) ");
            sb.AppendLine("VALUES ");
            sb.AppendLine("(@activity_id,@field_name,@field_control); ");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 28
0
		internal void CalculateVelocity ( Pathfinding.RVO.Simulator.WorkerContext context ) {

			if ( locked ) {
				newVelocity = Vector2.zero;
				return;
			}

			if ( context.vos.Length < neighbours.Count ) {
				context.vos = new VO[Mathf.Max(context.vos.Length*2, neighbours.Count)];
			}

			Vector2 position2D = new Vector2(position.x,position.z);

			var vos = context.vos;
			var voCount = 0;

			Vector2 optimalVelocity = new Vector2(velocity.x, velocity.z);

			float inverseAgentTimeHorizon = 1.0f/agentTimeHorizon;

			for ( int o = 0; o < neighbours.Count; o++ ) {

				Agent other = neighbours[o];

				if ( other == this ) continue;

				float maxY = System.Math.Min (position.y+height,other.position.y+other.height);
				float minY = System.Math.Max (position.y,other.position.y);
				
				//The agents cannot collide since they
				//are on different y-levels
				if (maxY - minY < 0) {
					continue;
				}

				Vector2 otherOptimalVelocity = new Vector2(other.Velocity.x, other.velocity.z);


				float totalRadius = radius + other.radius;

				// Describes a circle on the border of the VO
				//float boundingRadius = totalRadius * inverseAgentTimeHorizon;
				Vector2 voBoundingOrigin = new Vector2(other.position.x,other.position.z) - position2D;

				//float boundingDist = voBoundingOrigin.magnitude;

				Vector2 relativeVelocity = optimalVelocity - otherOptimalVelocity;

				{
					//voBoundingOrigin *= inverseAgentTimeHorizon;
					//boundingDist *= inverseAgentTimeHorizon;
					
					// Common case, no collision
					
					vos[voCount] = new VO( voBoundingOrigin, (optimalVelocity + otherOptimalVelocity)*0.5f, totalRadius, relativeVelocity, inverseAgentTimeHorizon);
					voCount++;
				}

	#if OLD
				//Debug.Log (boundingDist + " " + total
				if ( boundingDist < totalRadius ) {
					// Collision

					// We want the collision to end this frame, so ignore the inverseAgentTimeHorizon and
					// instead use the frame's delta time instead. The closest point will not always be 
					// on the circle, but the velocity will have to be really
					// high for it not to be, so just assume the velocity is low
					// (if not, the agents will jump through each other)

					voBoundingOrigin *= (1.0f/simulator.DeltaTime);
					boundingDist *= (1.0f/simulator.DeltaTime);

					Vector2 d = relativeVelocity - voBoundingOrigin;
					float dm = d.magnitude;

					// Normalize
					d /= dm;

					float resMagn = (totalRadius*(1.0f/simulator.DeltaTime) - dm);
					maxRelVelMagn = System.Math.Max ( resMagn, maxRelVelMagn );

					Vector2 closestOnCircleDelta = d*resMagn;//d*(boundingDist-dm);
					Vector2 closestOnCircleVector = d;

					halfPlanes.Add ( new HalfPlane ( closestOnCircleDelta*0.5f + optimalVelocity, closestOnCircleVector ) );
					if (debug) halfPlanes[halfPlanes.Count-1].Draw ( Color.blue );
				} else {
					voBoundingOrigin *= inverseAgentTimeHorizon;
					boundingDist *= inverseAgentTimeHorizon;

					// Common case, no collision

					VO vo = new VO( voBoundingOrigin + (optimalVelocity + otherOptimalVelocity)*0.5f, voBoundingOrigin.normalized, totalRadius*inverseAgentTimeHorizon);

					maxRelVelMagn = System.Math.Max ( maxRelVelMagn, relativeVelocity.magnitude );
					// Optimized: float factor = Vector3.Dot ( optimalVelocity, voBoundingOrigin ) < (boundingDist^2);

					if (debug) DrawVO ( voBoundingOrigin, boundingRadius, Vector2.zero);

					if ( debug ) {
						//Debug.DrawLine ( To3D(position), To3D ( relativeVelocity ), Color.blue );
						DrawCross ( relativeVelocity, Color.white, 0.5f);

					}

					//DrawCross ( voBoundingOrigin );

					float alpha = Mathf.Atan2 ( -voBoundingOrigin.y, -voBoundingOrigin.x );

					float delta = Mathf.Abs(Mathf.Acos (boundingRadius/(voBoundingOrigin).magnitude));

					float actualDot = Vector2.Dot ( -voBoundingOrigin.normalized, (relativeVelocity-voBoundingOrigin).normalized );
					float dot = Mathf.Abs ( Mathf.Acos ( Mathf.Clamp01(actualDot) ) );

					bool closestIsCircle = dot < delta;
					/*DrawCircle ( circleCenter, radius, alpha-delta, alpha+delta, Color.black );
					Vector2 p1 = circleCenter + new Vector2 ( Mathf.Cos (alpha-delta), Mathf.Sin (alpha-delta) ) * boundingRadius;
					Vector2 p2 = circleCenter + new Vector2 ( Mathf.Cos (alpha+delta), Mathf.Sin (alpha+delta) ) * boundingRadius;*/

					if ( debug ) Debug.Log (" <= 1 && " + dot + " < " + delta + " ( " +actualDot + ")");
					if ( closestIsCircle ) {
						// The cutoff circle is the closest 
						// part of the VO
						// Find the closest point on the VO

						Vector2 closestOnCircleVector = (relativeVelocity - voBoundingOrigin);
						float magn = closestOnCircleVector.magnitude;
						closestOnCircleVector = closestOnCircleVector/magn;//(closestOnCircleVector/magn)*boundingRadius*(1-(magn/boundingRadius));
						Vector2 closestOnCircle = closestOnCircleVector*boundingRadius + voBoundingOrigin;

						//if ( magn > boundingRadius ) closestOnCircleVector = -closestOnCircleVector;
						if ( debug ) DrawCross ( closestOnCircle, 1);
						halfPlanes.Add ( new HalfPlane ( (closestOnCircle - relativeVelocity)*0.5f + optimalVelocity, closestOnCircleVector.normalized ) );
						if (debug) halfPlanes[halfPlanes.Count-1].Draw ( closestIsCircle ? Color.blue : Color.red );

					} else {
						// One of the legs of the VO is the closest part
						// find the closest point on the VO

						bool left = Polygon.Left ( Vector2.zero, voBoundingOrigin, relativeVelocity );
						float gamma = alpha + (left ? delta : -delta);

						// Point on circle
						Vector2 line = new Vector2 ( Mathf.Cos (gamma), Mathf.Sin (gamma) ) * boundingRadius;
						// Vector tangent to circle which is the correct line tangent
						Vector2 dir = new Vector2(line.y,-line.x).normalized;

						// Point in space
						line += voBoundingOrigin;

						Vector2 onLine = line + dir * Vector2.Dot ( dir, relativeVelocity - line);
						if (debug) {
							DrawCross ( onLine, Color.red, 1 );
							Debug.DrawRay ( To3D(line), To3D(dir*10), Color.red );
							Debug.Log (line + " " + dir + " " + gamma + " " + relativeVelocity);
						}

						if ( !left ) dir = -dir;

						halfPlanes.Add ( new HalfPlane ( (onLine - relativeVelocity)*0.5f + optimalVelocity, (line-voBoundingOrigin).normalized ) );
						if (debug) halfPlanes[halfPlanes.Count-1].Draw ( Color.blue );
					}
				}
	#endif
			}

			if ( this.DebugDraw ) {
				/*for ( int x = 0; x < simulator.tex.width; x++ ) {
					for ( int y = 0; y < simulator.tex.height; y++ ) {
						Vector2 p = new Vector2 (x*simulator.textureSize / simulator.tex.width, y*simulator.textureSize / simulator.tex.height);

						Vector2 dir = Vector2.zero;
						float weight = 0;
						for ( int i = 0; i < voCount; i++ ) {
							float w = 0;
							dir += vos[i].Sample (p-position, out w);
							if ( w > weight ) weight = w;
						}
						Vector2 d2 = (desiredVelocity - (p-position));
						dir += d2*DesiredVelocityScale;

						if ( d2.magnitude * DesiredVelocityWeight > weight ) weight = d2.magnitude * DesiredVelocityWeight;

						if ( weight > 0 ) dir /= weight;

						Vector2 d3 = simulator.SampleDensity (p+position);
						Debug.DrawRay ( To3D(p), To3D(d3*1f), Color.blue );
						simulator.Plot (p, Rainbow(weight*simulator.colorScale));
					}
				}*/
			}

			//if ( debug ) {
			float best = float.PositiveInfinity;
			Vector2 result = Vector2.zero;

			float cutoff = new Vector2(velocity.x,velocity.z).magnitude*simulator.qualityCutoff;

			//for ( int i = 0; i < 10; i++ ) {
			{
				result = Trace ( vos, voCount, new Vector2(desiredVelocity.x, desiredVelocity.z), cutoff, out best );
			}

			// Can be uncommented for higher quality local avoidance
			/*for ( int i = 0; i < 3; i++ ) {
				Vector2 p = desiredVelocity + new Vector2(Mathf.Cos(Mathf.PI*2*(i/3.0f)), Mathf.Sin(Mathf.PI*2*(i/3.0f)));
				float score;
				Vector2 res = Trace ( vos, voCount, p, velocity.magnitude*simulator.qualityCutoff, out score );
				
				if ( score < best ) {
					//if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
					result = res;
					best = score;
				}
			}*/

			{
				Vector2 p = Vector2.zero;
				float score;
				Vector2 res = Trace ( vos, voCount, p, cutoff, out score );
				
				if ( score < best ) {
					//if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
					result = res;
					best = score;
				}
			}
			//}
				

			if (DebugDraw) DrawCross (result+position2D);


			newVelocity = To3D(Vector2.ClampMagnitude (result, maxSpeed));
		}
Esempio n. 29
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          25/06/2014      Add
 /// </modified>
 public int Insert(VO.KNOWLEDGE obj)
 {
     return new DAO.KNOWLEDGE().Insert(obj.KNOWLEDGE_NAME);
 }
Esempio n. 30
0
        //新增報名或更新報名資訊
        /// <summary>
        /// 新增報名或更新報名資訊
        /// </summary>
        /// <param name="myActivityRegistVO">報名人員資料型別物件</param>
        /// <param name="myCustomFieldValueVOList">自訂欄位型別物</param>
        /// <param name="myActivityTeamMemberVOList">團隊報名隊員型別物件</param>
        /// <param name="type">insert=新增,else修改</param>
        /// <param name="activity_type">活動類別</param>
        /// <param name="webPath">網址到根目錄</param>
        /// <param name="path">附加檔案目錄</param>
        /// <returns>新增報名或更新報名資訊</returns>
        public int UpdateActivityRegist(VO.ActivityRegistVO myActivityRegistVO, List<ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList, List<ACMS.VO.ActivityTeamMemberVO> myActivityTeamMemberVOList, string type, string activity_type, string webPath,string path )
        {
            string empidnew="" ;
            SqlParameter[] sqlParams = new SqlParameter[8];

            sqlParams[0] = new SqlParameter("@id", SqlDbType.Int);
            sqlParams[0].Value = myActivityRegistVO.id;
            sqlParams[1] = new SqlParameter("@activity_id", SqlDbType.UniqueIdentifier);
            sqlParams[1].Value = myActivityRegistVO.activity_id;
            sqlParams[2] = new SqlParameter("@emp_id", SqlDbType.NVarChar, -1);
            sqlParams[2].Value = myActivityRegistVO.emp_id;
            sqlParams[3] = new SqlParameter("@regist_by", SqlDbType.NVarChar, 100);
            sqlParams[3].Value = myActivityRegistVO.regist_by;
            sqlParams[4] = new SqlParameter("@idno_type", SqlDbType.Int);
            sqlParams[4].Value = myActivityRegistVO.idno_type;
            sqlParams[5] = new SqlParameter("@idno", SqlDbType.NVarChar, 20);
            sqlParams[5].Value = myActivityRegistVO.idno;
            sqlParams[6] = new SqlParameter("@team_name", SqlDbType.NVarChar, 100);
            sqlParams[6].Value = myActivityRegistVO.team_name;
            sqlParams[7] = new SqlParameter("@ext_people", SqlDbType.Int);
            sqlParams[7].Value = myActivityRegistVO.ext_people;
               // sqlParams[8] = new SqlParameter("@idno_ext", SqlDbType.NVarChar, myActivityRegistVO.idno_ext.Length);
            //sqlParams[8].Value = myActivityRegistVO.idno_ext;

            StringBuilder sb = new StringBuilder();

            List<string> ListOriginMembers = new List<string>();
            string strNewEmp_idList = "";

            //團隊時報名者是多人
            if (myActivityTeamMemberVOList != null)
            {
                //傳入團長取得團隊所有成員(List<string>)
                ListOriginMembers = AllTeamMemberByBoss(myActivityRegistVO.activity_id, myActivityRegistVO.regist_by);

                foreach (ACMS.VO.ActivityTeamMemberVO myActivityTeamMemberVO in myActivityTeamMemberVOList)
                {
                    strNewEmp_idList += string.Format("{0},", myActivityTeamMemberVO.emp_id);
                }

                if (strNewEmp_idList.EndsWith(","))
                {
                    strNewEmp_idList = strNewEmp_idList.Substring(0, strNewEmp_idList.Length - 1);
                }
            }

            if (type == "insert")
            {
                sb.AppendLine("declare @SeqNo int  select @SeqNo=MAX(SeqNo) from ActivityRegist  where activity_id =@activity_id  INSERT ActivityRegist ");
                sb.AppendLine("([activity_id],[emp_id],[regist_by],[idno_type],[idno],[team_name],[ext_people],[createat],[check_status],[SeqNo]) ");//,idno_ext
                sb.AppendLine("SELECT ");
                sb.AppendLine("@activity_id,@emp_id,@regist_by,@idno_type,@idno,@team_name,@ext_people,getdate(),0,isNull(@SeqNo+1,1)");//,@idno_ext
                sb.AppendLine("where 1=1 ");

                //沒有重複報名
                if (activity_type == "1")
                {
                    //個人
                    sb.AppendLine("and not exists(SELECt * FROM ActivityRegist where activity_id=@activity_id and emp_id=@emp_id) ");
                }
                else
                {
                    //團隊
                    sb.AppendLine("and not exists( ");
                    sb.AppendLine("SELECT * ");
                    sb.AppendLine("FROM ActivityTeamMember A ");
                    sb.AppendLine("left join V_ACSM_USER2 B on A.emp_id=B.ID ");
                    sb.AppendLine("WHERE 1=1 ");
                    sb.AppendLine("AND A.activity_id=@activity_id ");
                    sb.AppendLine(string.Format("AND A.emp_id in (SELECT * FROM dbo.UTILfn_Split('{0}',',')) ", strNewEmp_idList));
                    sb.AppendLine("AND A.boss_id<>@regist_by ");
                    sb.AppendLine(") ");
                }

                //沒有額滿
                sb.AppendLine("and  exists( ");
                sb.AppendLine("SELECT A.id ");
                sb.AppendLine("FROM Activity A ");
                sb.AppendLine("left join ActivityRegist B on A.id=B.activity_id");
                sb.AppendLine("WHERE 1=1 ");
                sb.AppendLine("and A.id=@activity_id ");
                sb.AppendLine("and ISNULL(B.check_status,0)>=0 ");
                sb.AppendLine("group by A.id,ISNULL(A.limit_count,0),ISNULL(A.limit2_count,0) ");
                sb.AppendLine("having (ISNULL(A.limit_count,0)+ISNULL(A.limit2_count,0)) - COUNT(B.id)>0 ");
                sb.AppendLine(") ");

            }
            else
            {
                //編輯資料

                //團員只異動ActivityTeamMember裡的個人資料
                if (myActivityRegistVO.emp_id != myActivityRegistVO.regist_by && myActivityTeamMemberVOList != null )
                {
                    ACMS.VO.ActivityTeamMemberVO MyObj = myActivityTeamMemberVOList.Find(delegate(ACMS.VO.ActivityTeamMemberVO e) { return e.emp_id == myActivityRegistVO.emp_id; });

                    sb.Length = 0;
                    sb.AppendLine("UPDATE ActivityTeamMember ");
                    sb.AppendLine(string.Format("set idno_type={0} ", MyObj.idno_type));
                    sb.AppendLine(string.Format(",idno='{0}' ", MyObj.idno));
                    sb.AppendLine(string.Format(",remark='{0}' ", MyObj.remark));
                    sb.AppendLine(string.Format("WHERE activity_id='{0}' and emp_id='{1}' ", myActivityRegistVO.activity_id, myActivityRegistVO.emp_id));

                    SqlCommand cmd = new SqlCommand();

                    cmd.Connection = MyConn();
                    cmd.Connection.Open();
                    cmd.CommandText = sb.ToString();
                    cmd.Parameters.Clear();

                    return cmd.ExecuteNonQuery();

                }

                //以下是團長的異動
                sb.Length = 0;
                sb.AppendLine("UPDATE ActivityRegist ");
                //sb.AppendLine("set activity_id=@activity_id ");
                //sb.AppendLine(",emp_id=@emp_id ");
                //sb.AppendLine(",regist_by=@regist_by ");
                sb.AppendLine("set idno_type=@idno_type ");
                sb.AppendLine(",idno=@idno ");
                sb.AppendLine(",team_name=@team_name ");
                sb.AppendLine(",ext_people=@ext_people");// ,idno_ext=@idno_ext
                sb.AppendLine("WHERE activity_id=@activity_id and emp_id=@emp_id ");

                //沒有重複報名
                if (activity_type == "2")
                {
                    sb.AppendLine("and not exists( ");
                    sb.AppendLine("SELECT * ");
                    sb.AppendLine("FROM ActivityTeamMember A ");
                    sb.AppendLine("left join V_ACSM_USER2 B on A.emp_id=B.ID ");
                    sb.AppendLine("WHERE 1=1 ");
                    sb.AppendLine("AND A.activity_id=@activity_id ");
                    sb.AppendLine(string.Format("AND A.emp_id in (SELECT * FROM dbo.UTILfn_Split('{0}',',')) ", strNewEmp_idList));
                    sb.AppendLine("AND A.boss_id<>@regist_by ");
                    sb.AppendLine(") ");
                }
            }

            //using (System.Transactions.TransactionScope trans = new System.Transactions.TransactionScope())
            //{

            using (SqlConnection myConn = MyConn())
            {
                myConn.Open();

                try
                {
                    SqlCommand cmd = new SqlCommand();

                    cmd.Connection = myConn;
                    cmd.CommandText = sb.ToString();
                    cmd.Parameters.AddRange(sqlParams);

                    int intResult = cmd.ExecuteNonQuery();

                    //變更成功就 1.改自訂欄位 2.重製ActivityTeamMember(團隊)
                    if (intResult > 0)
                    {
                        //改自訂欄位:先全刪再新增
                        sb.Length = 0;
                        sb.AppendLine("DELETE A ");
                        sb.AppendLine("FROM CustomFieldValue A ");

                        if (activity_type == "1")
                        {
                            sb.AppendLine(string.Format("inner join CustomField B on A.field_id=B.field_id and A.emp_id='{0}' and B.activity_id='{1}'; ", myActivityRegistVO.emp_id, myActivityRegistVO.activity_id));
                        }
                        else
                        {
                            //團隊報名時自訂欄位用團長的ID當代表
                            sb.AppendLine(string.Format("inner join CustomField B on A.field_id=B.field_id and A.emp_id='{0}' and B.activity_id='{1}'; ", myActivityRegistVO.regist_by, myActivityRegistVO.activity_id));
                        }

                        cmd.CommandText = sb.ToString();
                        cmd.Parameters.Clear();
                        cmd.ExecuteNonQuery();

                        foreach (ACMS.VO.CustomFieldValueVO myCustomFieldValueVO in myCustomFieldValueVOList)
                        {
                            SqlParameter[] sqlParams2 = new SqlParameter[4];

                            sqlParams2[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
                            sqlParams2[0].Value = myCustomFieldValueVO.id;
                            sqlParams2[1] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 100);
                            sqlParams2[1].Value = myCustomFieldValueVO.emp_id;
                            sqlParams2[2] = new SqlParameter("@field_id", SqlDbType.Int);
                            sqlParams2[2].Value = myCustomFieldValueVO.field_id;
                            sqlParams2[3] = new SqlParameter("@field_value", SqlDbType.NVarChar, 200);
                            sqlParams2[3].Value = myCustomFieldValueVO.field_value;

                            StringBuilder sb2 = new StringBuilder();

                            sb2.AppendLine("INSERT CustomFieldValue ");
                            sb2.AppendLine("VALUES ");
                            sb2.AppendLine("(@id,@emp_id,@field_id,@field_value) ");

                            cmd.CommandText = sb2.ToString();
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddRange(sqlParams2);
                            cmd.ExecuteNonQuery();

                        }

                        //重製ActivityTeamMember
                        if (myActivityTeamMemberVOList != null)
                        {
                            List<string> ListNewEmp_id;

                            ListNewEmp_id = new List<string>(strNewEmp_idList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));

                            //===========================================
                            //新成員若不在原始成員資料表就要寄報名成功信
                            //===========================================
                            ListNewEmp_id = new List<string>(strNewEmp_idList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                            ListNewEmp_id.RemoveAll(delegate(string e) { return ListOriginMembers.Contains(e); });
                            //andy-報名成功寄信
                           // clsMyObj.RegistSuccess_Team(myActivityRegistVO.activity_id.ToString(), string.Join(",", ListNewEmp_id.ToArray()), myActivityRegistVO.regist_by, webPath,path );

                            //===========================================
                            //舊成員若不在原始成員名單就要寄取消報名信
                            //===========================================
                            //ListNewEmp_id有改變,所以要重讀一次
                            ListNewEmp_id = new List<string>(strNewEmp_idList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
                            ListOriginMembers.RemoveAll(delegate(string e) { return ListNewEmp_id.Contains(e); });

                            //andy-取消報名寄信
                            //clsMyObj.CancelRegist(myActivityRegistVO.activity_id.ToString(), string.Join(",", ListOriginMembers.ToArray()), myActivityRegistVO.regist_by,webPath);
                            //2011/3/28 日 add 取消人需發信及加到取消人員清冊中
                            foreach (ACMS.VO.ActivityTeamMemberVO myActivityTeamMemberVO in myActivityTeamMemberVOList)
                            {
                                empidnew +=myActivityTeamMemberVO.emp_id+  ",";
                            }
                            empidnew = empidnew.Substring(0, empidnew.Length - 1);
                            InsertActivityRegistCancelTeamMember(myActivityTeamMemberVOList[0].activity_id ,empidnew,clsAuth.ID );
                            //=======================================================================================

                            sb.Length = 0;
                            sb.AppendLine("DELETE A ");
                            sb.AppendLine("FROM ActivityTeamMember A ");
                            sb.AppendLine(string.Format("WHERE A.boss_id='{0}' and A.activity_id='{1}'; ", myActivityRegistVO.regist_by, myActivityRegistVO.activity_id));

                            cmd.CommandText = sb.ToString();
                            cmd.Parameters.Clear();
                            cmd.ExecuteNonQuery();

                            foreach (ACMS.VO.ActivityTeamMemberVO myActivityTeamMemberVO in myActivityTeamMemberVOList)
                            {
                                SqlParameter[] sqlParams3 = new SqlParameter[7];

                                sqlParams3[0] = new SqlParameter("@activity_id", SqlDbType.UniqueIdentifier);
                                sqlParams3[0].Value = myActivityTeamMemberVO.activity_id;
                                sqlParams3[1] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 100);
                                sqlParams3[1].Value = myActivityTeamMemberVO.emp_id;
                                sqlParams3[2] = new SqlParameter("@boss_id", SqlDbType.NVarChar, 100);
                                sqlParams3[2].Value = myActivityTeamMemberVO.boss_id;
                                sqlParams3[3] = new SqlParameter("@idno_type", SqlDbType.SmallInt);
                                sqlParams3[3].Value = myActivityTeamMemberVO.idno_type;
                                sqlParams3[4] = new SqlParameter("@idno", SqlDbType.NVarChar, 20);
                                sqlParams3[4].Value = myActivityTeamMemberVO.idno;
                                sqlParams3[5] = new SqlParameter("@remark", SqlDbType.NVarChar, 500);
                                sqlParams3[5].Value = myActivityTeamMemberVO.remark;
                                sqlParams3[6] = new SqlParameter("@check_status", SqlDbType.Int);
                                sqlParams3[6].Value = myActivityTeamMemberVO.check_status;

                                StringBuilder sb3 = new StringBuilder();

                                sb3.AppendLine("INSERT ActivityTeamMember ");
                                sb3.AppendLine("VALUES ");
                                sb3.AppendLine("(@activity_id,@emp_id,@boss_id,@idno_type,@idno,@remark,@check_status) ");

                                cmd.CommandText = sb3.ToString();
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddRange(sqlParams3);
                                cmd.ExecuteNonQuery();

                            }
                        }
                    }
                    else
                    {
                        return 0;
                    }

                }
                catch
                {
                    return 0;
                }

                //}

                //trans.Complete();
            }

            return 1;
        }
Esempio n. 31
0
        /// <summary>
        /// 新增一個報名人員的資料
        /// </summary>
        /// <param name="myActivityRegistVO">報名人員型別物件</param>
        /// <returns>ExecuteNonQuery</returns>
        public int INSERT_NewOne(VO.ActivityRegistVO myActivityRegistVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[4];

            sqlParams[0] = new SqlParameter("@id", SqlDbType.Int);
            sqlParams[0].Value = myActivityRegistVO.id;
            sqlParams[1] = new SqlParameter("@activity_id", SqlDbType.UniqueIdentifier);
            sqlParams[1].Value = myActivityRegistVO.activity_id;
            sqlParams[2] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 50);
            sqlParams[2].Value = myActivityRegistVO.emp_id;
            sqlParams[3] = new SqlParameter("@regist_by", SqlDbType.NVarChar, 50);
            sqlParams[3].Value = myActivityRegistVO.regist_by;
               // sqlParams[4] = new SqlParameter("@idno_ext", SqlDbType.NVarChar, 50);
               // sqlParams[4].Value = myActivityRegistVO.idno_ext;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT ActivityRegist ");
            sb.AppendLine("([id],[activity_id],[emp_id],[regist_by],[ticket_id],[idno],[ext_people],[createat],[check_status]) ");//,idno_exrt
            sb.AppendLine("VALUES ");
            sb.AppendLine("(@id,@activity_id,@emp_id,@regist_by,null,'',null,getdate(),0) ");//,@idno_ext

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
 public void ModificarEspecificaDeGasto(VO.EspecificoDeGasto_BUS espec)
 {
     DAEspecificoDeGasto espDAL = new DAEspecificoDeGasto();
     espDAL.ModificarEspecificaDeGasto(espec);
 }
 public void AgregarEspecificaDeGasto(VO.EspecificoDeGasto_BUS espec)
 {
     DAEspecificoDeGasto espDAL = new DAEspecificoDeGasto();
     espDAL.AgregarEspecificaDeGasto(espec);
 }
Esempio n. 34
0
 public UIData() : base()
 {
     this.toastMessage = new VO <ReferenceData <ToastMessage> >(this, (byte)Property.toastMessage, new ReferenceData <ToastMessage>(null));
     this.state        = new VD <State>(this, (byte)Property.state, new ToastS.Hide());
 }
Esempio n. 35
0
 /// <summary>
 /// Update
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          14/06/2014      Add
 /// </modified>
 public int Update(VO.SCHOOL obj)
 {
     return new DAO.SCHOOL().Update(obj.ID, obj.SCHOOL_NAME, obj.ADDRESS, obj.TELEPHONE,
         obj.EMAIL, obj.WEBSITE, obj.CITY_ID);
 }
Esempio n. 36
0
		Vector2 Trace ( VO[] vos, int voCount, Vector2 p, float cutoff, out float score ) {

			score = 0;
			float stepScale = simulator.stepScale;

			//while ( true ) {
			for ( int s = 0; s < 50; s++ ) {


				float step = 1.0f - (s/50.0f);
				step *= stepScale;

				Vector2 dir = Vector2.zero;
				float mx = 0;
				for ( int i = 0; i < voCount; i++ ) {
					float w;
					Vector2 d = vos[i].Sample (p, out w);
					dir += d;

					if ( w > mx ) mx = w;
					//mx = System.Math.Max (mx, d.sqrMagnitude);
				}

				Vector2 d2 = (new Vector2(desiredVelocity.x,desiredVelocity.z) - p);
				float weight = d2.magnitude*DesiredVelocityWeight;
				dir += d2*DesiredVelocityScale;
				mx = System.Math.Max (mx, weight);

				/*if ( simulator.densityScale > 0 ) {
					d2 = simulator.SampleDensity (p+position);
					dir += d2;
					mx = System.Math.Max (mx, d2.magnitude);
				}*/

				score = mx;//dir.sqrMagnitude;

				float sq = dir.sqrMagnitude;
				if ( sq > 0 ) dir *= mx/Mathf.Sqrt(sq); // +1 to avoid division by zero
					//Vector2.ClampMagnitude (dir, Mathf.Sqrt(mx));
				//dir /= vos.Count+1;

				dir *= step;

				//Vector2 prev = p;
				p += dir;

				if ( score < cutoff ) break;
				//if (debug) Debug.DrawLine ( To3D(prev+position), To3D(p+position), Color.green);
			}

			return p;
		}
Esempio n. 37
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          26/06/2014      Add
 /// </modified>
 public bool Insert(VO.CLASS_KNOWLEDGE obj)
 {
     return new DAO.CLASS_KNOWLEDGE().Insert(obj.CLASS_ID, obj.KNOWLEDGE_ID);
 }
Esempio n. 38
0
            /** Creates a VO for avoiding another agent.
             * Note that the segment is directed, the agent will want to be on the left side of the segment.
             */
            public static VO SegmentObstacle(TSVector2 segmentStart, TSVector2 segmentEnd, TSVector2 offset, FP radius, FP inverseDt, FP inverseDeltaTime)
            {
                var vo = new VO();

                // Adjusted so that a parameter weightFactor of 1 will be the default ("natural") weight factor
                vo.weightFactor = 1;
                // Just higher than anything else
                vo.weightBonus = TSMath.Max(radius, 1) * 40;

                var closestOnSegment = CustomMath.ClosestPointOnSegment(segmentStart, segmentEnd, TSVector2.zero);

                // Collision?
                if (closestOnSegment.magnitude <= radius)
                {
                    vo.colliding = true;

                    vo.line1  = closestOnSegment.normalized * (closestOnSegment.magnitude - radius) * 3 / 10 * inverseDeltaTime;
                    vo.dir1   = new TSVector2(vo.line1.y, -vo.line1.x).normalized;
                    vo.line1 += offset;

                    vo.cutoffDir  = TSVector2.zero;
                    vo.cutoffLine = TSVector2.zero;
                    vo.dir2       = TSVector2.zero;
                    vo.line2      = TSVector2.zero;
                    vo.radius     = 0;

                    vo.segmentStart = TSVector2.zero;
                    vo.segmentEnd   = TSVector2.zero;
                    vo.segment      = false;
                }
                else
                {
                    vo.colliding = false;

                    segmentStart *= inverseDt;
                    segmentEnd   *= inverseDt;
                    radius       *= inverseDt;

                    var cutoffTangent = (segmentEnd - segmentStart).normalized;
                    vo.cutoffDir   = cutoffTangent;
                    vo.cutoffLine  = segmentStart + new TSVector2(-cutoffTangent.y, cutoffTangent.x) * radius;
                    vo.cutoffLine += offset;

                    // See documentation for details
                    // The call to Max is just to prevent floating point errors causing NaNs to appear
                    var startSqrMagnitude = segmentStart.LengthSquared();
                    var normal1           = -ComplexMultiply(segmentStart, new TSVector2(radius, TSMath.Sqrt(TSMath.Max(0, startSqrMagnitude - radius * radius)))) / startSqrMagnitude;
                    var endSqrMagnitude   = segmentEnd.LengthSquared();
                    var normal2           = -ComplexMultiply(segmentEnd, new TSVector2(radius, -TSMath.Sqrt(TSMath.Max(0, endSqrMagnitude - radius * radius)))) / endSqrMagnitude;

                    vo.line1 = segmentStart + normal1 * radius + offset;
                    vo.line2 = segmentEnd + normal2 * radius + offset;

                    // Note that the normals are already normalized
                    vo.dir1 = new TSVector2(normal1.y, -normal1.x);
                    vo.dir2 = new TSVector2(normal2.y, -normal2.x);

                    vo.segmentStart = segmentStart;
                    vo.segmentEnd   = segmentEnd;
                    vo.radius       = radius;
                    vo.segment      = true;
                }

                return(vo);
            }
Esempio n. 39
0
 /// <summary>
 /// Update
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          25/06/2014      Add
 /// </modified>
 public bool Update(VO.KNOWLEDGE obj)
 {
     return new DAO.KNOWLEDGE().Update(obj.ID, obj.KNOWLEDGE_NAME);
 }
Esempio n. 40
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          25/06/2014      Add
 /// </modified>
 public Nullable<decimal> Insert(VO.CLASS obj)
 {
     return new DAO.CLASS().Insert(obj.CLASS_NAME, obj.SCHOOL_ID, obj.CLASS_TYPE);
 }
Esempio n. 41
0
 protected abstract double Validate(VO record);
Esempio n. 42
0
 /// <summary>
 /// Update
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          25/06/2014      Add
 /// </modified>
 public bool Update(VO.CLASS obj)
 {
     return false;
 }
Esempio n. 43
0
        internal void CalculateVelocity(Pathfinding.RVO.Simulator.WorkerContext context)
        {
            if (locked)
            {
                newVelocity = Vector2.zero;
                return;
            }

            if (context.vos.Length < neighbours.Count)
            {
                context.vos = new VO[Mathf.Max(context.vos.Length * 2, neighbours.Count)];
            }

            Vector2 position2D = new Vector2(position.x, position.z);

            var vos     = context.vos;
            var voCount = 0;

            Vector2 optimalVelocity = new Vector2(velocity.x, velocity.z);

            float inverseAgentTimeHorizon = 1.0f / agentTimeHorizon;

            for (int o = 0; o < neighbours.Count; o++)
            {
                Agent other = neighbours[o];

                if (other == this)
                {
                    continue;
                }

                float maxY = System.Math.Min(position.y + height, other.position.y + other.height);
                float minY = System.Math.Max(position.y, other.position.y);

                //The agents cannot collide since they
                //are on different y-levels
                if (maxY - minY < 0)
                {
                    continue;
                }

                Vector2 otherOptimalVelocity = new Vector2(other.Velocity.x, other.velocity.z);


                float totalRadius = radius + other.radius;

                // Describes a circle on the border of the VO
                //float boundingRadius = totalRadius * inverseAgentTimeHorizon;
                Vector2 voBoundingOrigin = new Vector2(other.position.x, other.position.z) - position2D;

                //float boundingDist = voBoundingOrigin.magnitude;

                Vector2 relativeVelocity = optimalVelocity - otherOptimalVelocity;

                {
                    //voBoundingOrigin *= inverseAgentTimeHorizon;
                    //boundingDist *= inverseAgentTimeHorizon;

                    // Common case, no collision

                    vos[voCount] = new VO(voBoundingOrigin, (optimalVelocity + otherOptimalVelocity) * 0.5f, totalRadius, relativeVelocity, inverseAgentTimeHorizon);
                    voCount++;
                }

        #if OLD
                //Debug.Log (boundingDist + " " + total
                if (boundingDist < totalRadius)
                {
                    // Collision

                    // We want the collision to end this frame, so ignore the inverseAgentTimeHorizon and
                    // instead use the frame's delta time instead. The closest point will not always be
                    // on the circle, but the velocity will have to be really
                    // high for it not to be, so just assume the velocity is low
                    // (if not, the agents will jump through each other)

                    voBoundingOrigin *= (1.0f / simulator.DeltaTime);
                    boundingDist     *= (1.0f / simulator.DeltaTime);

                    Vector2 d  = relativeVelocity - voBoundingOrigin;
                    float   dm = d.magnitude;

                    // Normalize
                    d /= dm;

                    float resMagn = (totalRadius * (1.0f / simulator.DeltaTime) - dm);
                    maxRelVelMagn = System.Math.Max(resMagn, maxRelVelMagn);

                    Vector2 closestOnCircleDelta  = d * resMagn;                 //d*(boundingDist-dm);
                    Vector2 closestOnCircleVector = d;

                    halfPlanes.Add(new HalfPlane(closestOnCircleDelta * 0.5f + optimalVelocity, closestOnCircleVector));
                    if (debug)
                    {
                        halfPlanes[halfPlanes.Count - 1].Draw(Color.blue);
                    }
                }
                else
                {
                    voBoundingOrigin *= inverseAgentTimeHorizon;
                    boundingDist     *= inverseAgentTimeHorizon;

                    // Common case, no collision

                    VO vo = new VO(voBoundingOrigin + (optimalVelocity + otherOptimalVelocity) * 0.5f, voBoundingOrigin.normalized, totalRadius * inverseAgentTimeHorizon);

                    maxRelVelMagn = System.Math.Max(maxRelVelMagn, relativeVelocity.magnitude);
                    // Optimized: float factor = Vector3.Dot ( optimalVelocity, voBoundingOrigin ) < (boundingDist^2);

                    if (debug)
                    {
                        DrawVO(voBoundingOrigin, boundingRadius, Vector2.zero);
                    }

                    if (debug)
                    {
                        //Debug.DrawLine ( To3D(position), To3D ( relativeVelocity ), Color.blue );
                        DrawCross(relativeVelocity, Color.white, 0.5f);
                    }

                    //DrawCross ( voBoundingOrigin );

                    float alpha = Mathf.Atan2(-voBoundingOrigin.y, -voBoundingOrigin.x);

                    float delta = Mathf.Abs(Mathf.Acos(boundingRadius / (voBoundingOrigin).magnitude));

                    float actualDot = Vector2.Dot(-voBoundingOrigin.normalized, (relativeVelocity - voBoundingOrigin).normalized);
                    float dot       = Mathf.Abs(Mathf.Acos(Mathf.Clamp01(actualDot)));

                    bool closestIsCircle = dot < delta;

                    /*DrawCircle ( circleCenter, radius, alpha-delta, alpha+delta, Color.black );
                     * Vector2 p1 = circleCenter + new Vector2 ( Mathf.Cos (alpha-delta), Mathf.Sin (alpha-delta) ) * boundingRadius;
                     * Vector2 p2 = circleCenter + new Vector2 ( Mathf.Cos (alpha+delta), Mathf.Sin (alpha+delta) ) * boundingRadius;*/

                    if (debug)
                    {
                        Debug.Log(" <= 1 && " + dot + " < " + delta + " ( " + actualDot + ")");
                    }
                    if (closestIsCircle)
                    {
                        // The cutoff circle is the closest
                        // part of the VO
                        // Find the closest point on the VO

                        Vector2 closestOnCircleVector = (relativeVelocity - voBoundingOrigin);
                        float   magn = closestOnCircleVector.magnitude;
                        closestOnCircleVector = closestOnCircleVector / magn;                      //(closestOnCircleVector/magn)*boundingRadius*(1-(magn/boundingRadius));
                        Vector2 closestOnCircle = closestOnCircleVector * boundingRadius + voBoundingOrigin;

                        //if ( magn > boundingRadius ) closestOnCircleVector = -closestOnCircleVector;
                        if (debug)
                        {
                            DrawCross(closestOnCircle, 1);
                        }
                        halfPlanes.Add(new HalfPlane((closestOnCircle - relativeVelocity) * 0.5f + optimalVelocity, closestOnCircleVector.normalized));
                        if (debug)
                        {
                            halfPlanes[halfPlanes.Count - 1].Draw(closestIsCircle ? Color.blue : Color.red);
                        }
                    }
                    else
                    {
                        // One of the legs of the VO is the closest part
                        // find the closest point on the VO

                        bool  left  = Polygon.Left(Vector2.zero, voBoundingOrigin, relativeVelocity);
                        float gamma = alpha + (left ? delta : -delta);

                        // Point on circle
                        Vector2 line = new Vector2(Mathf.Cos(gamma), Mathf.Sin(gamma)) * boundingRadius;
                        // Vector tangent to circle which is the correct line tangent
                        Vector2 dir = new Vector2(line.y, -line.x).normalized;

                        // Point in space
                        line += voBoundingOrigin;

                        Vector2 onLine = line + dir * Vector2.Dot(dir, relativeVelocity - line);
                        if (debug)
                        {
                            DrawCross(onLine, Color.red, 1);
                            Debug.DrawRay(To3D(line), To3D(dir * 10), Color.red);
                            Debug.Log(line + " " + dir + " " + gamma + " " + relativeVelocity);
                        }

                        if (!left)
                        {
                            dir = -dir;
                        }

                        halfPlanes.Add(new HalfPlane((onLine - relativeVelocity) * 0.5f + optimalVelocity, (line - voBoundingOrigin).normalized));
                        if (debug)
                        {
                            halfPlanes[halfPlanes.Count - 1].Draw(Color.blue);
                        }
                    }
                }
        #endif
            }

            if (this.DebugDraw)
            {
                /*for ( int x = 0; x < simulator.tex.width; x++ ) {
                 *      for ( int y = 0; y < simulator.tex.height; y++ ) {
                 *              Vector2 p = new Vector2 (x*simulator.textureSize / simulator.tex.width, y*simulator.textureSize / simulator.tex.height);
                 *
                 *              Vector2 dir = Vector2.zero;
                 *              float weight = 0;
                 *              for ( int i = 0; i < voCount; i++ ) {
                 *                      float w = 0;
                 *                      dir += vos[i].Sample (p-position, out w);
                 *                      if ( w > weight ) weight = w;
                 *              }
                 *              Vector2 d2 = (desiredVelocity - (p-position));
                 *              dir += d2*DesiredVelocityScale;
                 *
                 *              if ( d2.magnitude * DesiredVelocityWeight > weight ) weight = d2.magnitude * DesiredVelocityWeight;
                 *
                 *              if ( weight > 0 ) dir /= weight;
                 *
                 *              Vector2 d3 = simulator.SampleDensity (p+position);
                 *              Debug.DrawRay ( To3D(p), To3D(d3*1f), Color.blue );
                 *              simulator.Plot (p, Rainbow(weight*simulator.colorScale));
                 *      }
                 * }*/
            }

            //if ( debug ) {
            float   best   = float.PositiveInfinity;
            Vector2 result = Vector2.zero;

            float cutoff = new Vector2(velocity.x, velocity.z).magnitude *simulator.qualityCutoff;

            //for ( int i = 0; i < 10; i++ ) {
            {
                result = Trace(vos, voCount, new Vector2(desiredVelocity.x, desiredVelocity.z), cutoff, out best);
            }

            // Can be uncommented for higher quality local avoidance

            /*for ( int i = 0; i < 3; i++ ) {
             *      Vector2 p = desiredVelocity + new Vector2(Mathf.Cos(Mathf.PI*2*(i/3.0f)), Mathf.Sin(Mathf.PI*2*(i/3.0f)));
             *      float score;
             *      Vector2 res = Trace ( vos, voCount, p, velocity.magnitude*simulator.qualityCutoff, out score );
             *
             *      if ( score < best ) {
             *              //if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
             *              result = res;
             *              best = score;
             *      }
             * }*/

            {
                Vector2 p = Vector2.zero;
                float   score;
                Vector2 res = Trace(vos, voCount, p, cutoff, out score);

                if (score < best)
                {
                    //if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
                    result = res;
                    best   = score;
                }
            }
            //}


            if (DebugDraw)
            {
                DrawCross(result + position2D);
            }


            newVelocity = To3D(Vector2.ClampMagnitude(result, maxSpeed));
        }
Esempio n. 44
0
        internal void CalculateVelocity(Pathfinding.RVO.Simulator.WorkerContext context)
        {
            if (locked)
            {
                newVelocity = Vector2.zero;
                return;
            }

            if (context.vos.Length < neighbours.Count + simulator.obstacles.Count)
            {
                context.vos = new VO[Mathf.Max(context.vos.Length * 2, neighbours.Count + simulator.obstacles.Count)];
            }

            Vector2 position2D = new Vector2(position.x, position.z);

            var vos     = context.vos;
            var voCount = 0;

            Vector2 optimalVelocity = new Vector2(velocity.x, velocity.z);

            float inverseAgentTimeHorizon = 1.0f / agentTimeHorizon;

            //#if !BNICKSON_UPDATED
            float wallThickness = simulator.WallThickness;

            float wallWeight = simulator.algorithm == Simulator.SamplingAlgorithm.GradientDecent ? 1 : WallWeight;

            for (int i = 0; i < simulator.obstacles.Count; i++)
            {
                var obstacle = simulator.obstacles[i];
                var vertex   = obstacle;

                do
                {
                    if (vertex.ignore || position.y > vertex.position.y + vertex.height || position.y + height < vertex.position.y || (vertex.layer & collidesWith) == 0)
                    {
                        vertex = vertex.next;
                        continue;
                    }

                    float cross = VO.Det(new Vector2(vertex.position.x, vertex.position.z), vertex.dir, position2D);// vertex.dir.x * ( vertex.position.z - position.z ) - vertex.dir.y * ( vertex.position.x - position.x );
                    // Signed distance from the line (not segment), lines are infinite
                    // Usually divided by vertex.dir.magnitude, but that is known to be 1
                    float signedDist = cross;

                    if (Mathf.Abs(signedDist) < neighbourDist)
                    {
#if BNICKSON_UPDATED
                        //from up move to there  less call  NearestPoint  ---lzt
                        Vector3 lineToAgent = position - VectorMath.ClosestPointOnLine(obstacle.position, vertex.position, position);
                        lineToAgent.y = 0f;
                        if (Vector3.Dot(lineToAgent, obstacle.pushAwayDir) < 0f) // if the agent is behind the obstacle
                        {
                            continue;                                            // we don't want this obstacle to stop the agent from getting back onto the nav mesh, alternately
                                                                                 // we could consider the agent to be in front of the obstacle for the orca calculations, the agent will then be pushed away from the obstacle
                                                                                 // which is probably desirable
                        }
#endif
                        //from up move to there  less call  ---lzt
                        float dotFactor = Vector2.Dot(vertex.dir, position2D - new Vector2(vertex.position.x, vertex.position.z));

                        // It is closest to the segment
                        // if the dotFactor is <= 0 or >= length of the segment
                        // WallThickness*0.1 is added as a margin to avoid false positives when moving along the edges of square obstacles
                        bool closestIsEndpoints = dotFactor <= wallThickness * 0.05f || dotFactor >= (new Vector2(vertex.position.x, vertex.position.z) - new Vector2(vertex.next.position.x, vertex.next.position.z)).magnitude - wallThickness * 0.05f;

                        if (signedDist <= 0 && !closestIsEndpoints && signedDist > -wallThickness)
                        {
                            // Inside the wall on the "wrong" side
                            vos[voCount] = new VO(position2D, new Vector2(vertex.position.x, vertex.position.z) - position2D, vertex.dir, wallWeight * 2);
                            voCount++;
                        }
                        else if (signedDist > 0)
                        {
                            //Debug.DrawLine (position, (vertex.position+vertex.next.position)*0.5f, Color.yellow);
                            Vector2 p1    = new Vector2(vertex.position.x, vertex.position.z) - position2D;
                            Vector2 p2    = new Vector2(vertex.next.position.x, vertex.next.position.z) - position2D;
                            Vector2 tang1 = (p1).normalized;
                            Vector2 tang2 = (p2).normalized;
                            vos[voCount] = new VO(position2D, p1, p2, tang1, tang2, wallWeight);
                            voCount++;
                        }
                    }
                    vertex = vertex.next;
                } while (vertex != obstacle);
            }
            //#endif
            for (int o = 0; o < neighbours.Count; o++)
            {
                Agent other = neighbours[o];

                if (other == this)
                {
                    continue;
                }

                float maxY = System.Math.Min(position.y + height, other.position.y + other.height);
                float minY = System.Math.Max(position.y, other.position.y);

                //The agents cannot collide since they
                //are on different y-levels
                if (maxY - minY < 0)
                {
                    continue;
                }

                Vector2 otherOptimalVelocity = new Vector2(other.Velocity.x, other.velocity.z);


                float totalRadius = radius + other.radius;

                // Describes a circle on the border of the VO
                //float boundingRadius = totalRadius * inverseAgentTimeHorizon;
                Vector2 voBoundingOrigin = new Vector2(other.position.x, other.position.z) - position2D;

                //float boundingDist = voBoundingOrigin.magnitude;

                Vector2 relativeVelocity = optimalVelocity - otherOptimalVelocity;

                {
                    //voBoundingOrigin *= inverseAgentTimeHorizon;
                    //boundingDist *= inverseAgentTimeHorizon;

                    // Common case, no collision

                    Vector2 voCenter;
                    if (other.locked)
                    {
                        voCenter = otherOptimalVelocity;
                    }
                    else
                    {
                        voCenter = (optimalVelocity + otherOptimalVelocity) * 0.5f;
                    }

                    vos[voCount] = new VO(voBoundingOrigin, voCenter, totalRadius, relativeVelocity, inverseAgentTimeHorizon, 1);
                    voCount++;
                    if (DebugDraw)
                    {
                        DrawVO(position2D + voBoundingOrigin * inverseAgentTimeHorizon + voCenter, totalRadius * inverseAgentTimeHorizon, position2D + voCenter);
                    }
                }
            }


            Vector2 result = Vector2.zero;

            if (simulator.algorithm == Simulator.SamplingAlgorithm.GradientDecent)
            {
                if (DebugDraw)
                {
                    const int   PlotWidth      = 40;
                    const float WorldPlotWidth = 15;

                    for (int x = 0; x < PlotWidth; x++)
                    {
                        for (int y = 0; y < PlotWidth; y++)
                        {
                            Vector2 p = new Vector2(x * WorldPlotWidth / PlotWidth, y * WorldPlotWidth / PlotWidth);

                            Vector2 dir    = Vector2.zero;
                            float   weight = 0;
                            for (int i = 0; i < voCount; i++)
                            {
                                float w;
                                dir += vos[i].Sample(p - position2D, out w);
                                if (w > weight)
                                {
                                    weight = w;
                                }
                            }
                            Vector2 d2 = (new Vector2(desiredVelocity.x, desiredVelocity.z) - (p - position2D));
                            dir += d2 * DesiredVelocityScale;

                            if (d2.magnitude * DesiredVelocityWeight > weight)
                            {
                                weight = d2.magnitude * DesiredVelocityWeight;
                            }

                            if (weight > 0)
                            {
                                dir /= weight;
                            }

                            //Vector2 d3 = simulator.SampleDensity (p+position2D);
                            Debug.DrawRay(To3D(p), To3D(d2 * 0.00f), Color.blue);
                            //simulator.Plot (p, Rainbow(weight*simulator.colorScale));

                            float   sc = 0;
                            Vector2 p0 = p - Vector2.one * WorldPlotWidth * 0.5f;
                            Vector2 p1 = Trace(vos, voCount, p0, 0.01f, out sc);
                            if ((p0 - p1).sqrMagnitude < Sqr(WorldPlotWidth / PlotWidth) * 2.6f)
                            {
                                Debug.DrawRay(To3D(p1 + position2D), Vector3.up * 1, Color.red);
                            }
                        }
                    }
                }

                //if ( debug ) {
                float best = float.PositiveInfinity;

                float cutoff = new Vector2(velocity.x, velocity.z).magnitude *simulator.qualityCutoff;

                //for ( int i = 0; i < 10; i++ ) {
                {
                    result = Trace(vos, voCount, new Vector2(desiredVelocity.x, desiredVelocity.z), cutoff, out best);
                    if (DebugDraw)
                    {
                        DrawCross(result + position2D, Color.yellow, 0.5f);
                    }
                }

                // Can be uncommented for higher quality local avoidance

                /*for ( int i = 0; i < 3; i++ ) {
                 *  Vector2 p = desiredVelocity + new Vector2(Mathf.Cos(Mathf.PI*2*(i/3.0f)), Mathf.Sin(Mathf.PI*2*(i/3.0f)));
                 *  float score;
                 *  Vector2 res = Trace ( vos, voCount, p, velocity.magnitude*simulator.qualityCutoff, out score );
                 *
                 *  if ( score < best ) {
                 *      //if ( score < best*0.9f )EB.Debug.Log ("Better " + score + " < " + best);
                 *      result = res;
                 *      best = score;
                 *  }
                 * }*/

                {
                    Vector2 p = Velocity;
                    float   score;
                    Vector2 res = Trace(vos, voCount, p, cutoff, out score);

                    if (score < best)
                    {
                        //if ( score < best*0.9f )EB.Debug.Log ("Better " + score + " < " + best);
                        result = res;
                        best   = score;
                    }
                    if (DebugDraw)
                    {
                        DrawCross(res + position2D, Color.magenta, 0.5f);
                    }
                }
            }
            else
            {
                // Adaptive sampling

                Vector2[] samplePos      = context.samplePos;
                float[]   sampleSize     = context.sampleSize;
                int       samplePosCount = 0;


                Vector2 desired2D   = new Vector2(desiredVelocity.x, desiredVelocity.z);
                float   sampleScale = Mathf.Max(radius, Mathf.Max(desired2D.magnitude, Velocity.magnitude));
                samplePos[samplePosCount]  = desired2D;
                sampleSize[samplePosCount] = sampleScale * 0.3f;
                samplePosCount++;

                const float GridScale = 0.3f;

                // Initial 9 samples
                samplePos[samplePosCount]  = optimalVelocity;
                sampleSize[samplePosCount] = sampleScale * GridScale;
                samplePosCount++;

                {
                    Vector2 fw = optimalVelocity * 0.5f;
                    Vector2 rw = new Vector2(fw.y, -fw.x);

                    const int Steps = 8;
                    for (int i = 0; i < Steps; i++)
                    {
                        samplePos[samplePosCount]  = rw * Mathf.Sin(i * Mathf.PI * 2 / Steps) + fw * (1 + Mathf.Cos(i * Mathf.PI * 2 / Steps));
                        sampleSize[samplePosCount] = (1.0f - (Mathf.Abs(i - Steps * 0.5f) / Steps)) * sampleScale * 0.5f;
                        samplePosCount++;
                    }

                    const float InnerScale = 0.6f;
                    fw *= InnerScale;
                    rw *= InnerScale;

                    const int Steps2 = 6;
                    for (int i = 0; i < Steps2; i++)
                    {
                        samplePos[samplePosCount]  = rw * Mathf.Cos((i + 0.5f) * Mathf.PI * 2 / Steps2) + fw * ((1.0f / InnerScale) + Mathf.Sin((i + 0.5f) * Mathf.PI * 2 / Steps2));
                        sampleSize[samplePosCount] = sampleScale * 0.3f;
                        samplePosCount++;
                    }

                    const float TargetScale = 0.2f;

                    const int Steps3 = 6;
                    for (int i = 0; i < Steps3; i++)
                    {
                        samplePos[samplePosCount]  = optimalVelocity + new Vector2(sampleScale * TargetScale * Mathf.Cos((i + 0.5f) * Mathf.PI * 2 / Steps3), sampleScale * TargetScale * Mathf.Sin((i + 0.5f) * Mathf.PI * 2 / Steps3));
                        sampleSize[samplePosCount] = sampleScale * TargetScale * 2;
                        samplePosCount++;
                    }
                }

                samplePos[samplePosCount]  = optimalVelocity * 0.5f;
                sampleSize[samplePosCount] = sampleScale * 0.4f;
                samplePosCount++;

                const int KeepCount  = Simulator.WorkerContext.KeepCount;
                Vector2[] bestPos    = context.bestPos;
                float[]   bestSizes  = context.bestSizes;
                float[]   bestScores = context.bestScores;

                for (int i = 0; i < KeepCount; i++)
                {
                    bestScores[i] = float.PositiveInfinity;
                }
                bestScores[KeepCount] = float.NegativeInfinity;

                Vector2 bestEver      = optimalVelocity;
                float   bestEverScore = float.PositiveInfinity;

                for (int sub = 0; sub < 3; sub++)
                {
                    for (int i = 0; i < samplePosCount; i++)
                    {
                        float score = 0;
                        for (int vo = 0; vo < voCount; vo++)
                        {
                            score = System.Math.Max(score, vos[vo].ScalarSample(samplePos[i]));
                        }
                        // Note that velocity is a vector and speed is a scalar, not the same thing
                        float bonusForDesiredVelocity = (samplePos[i] - desired2D).magnitude;

                        // This didn't work out as well as I though
                        // Code left here because I might reenable it later
                        //float bonusForDesiredSpeed = Mathf.Abs (samplePos[i].magnitude - desired2D.magnitude);

                        float biasedScore = score + bonusForDesiredVelocity * DesiredVelocityWeight;// + bonusForDesiredSpeed*0;
                        score += bonusForDesiredVelocity * 0.001f;

                        if (DebugDraw)
                        {
                            DrawCross(position2D + samplePos[i], Rainbow(Mathf.Log(score + 1) * 5), sampleSize[i] * 0.5f);
                        }

                        if (biasedScore < bestScores[0])
                        {
                            for (int j = 0; j < KeepCount; j++)
                            {
                                if (biasedScore >= bestScores[j + 1])
                                {
                                    bestScores[j] = biasedScore;
                                    bestSizes[j]  = sampleSize[i];
                                    bestPos[j]    = samplePos[i];
                                    break;
                                }
                            }
                        }

                        if (score < bestEverScore)
                        {
                            bestEver      = samplePos[i];
                            bestEverScore = score;

                            if (score == 0)
                            {
                                sub = 100;
                                break;
                            }
                        }
                    }

                    samplePosCount = 0;

                    for (int i = 0; i < KeepCount; i++)
                    {
                        Vector2 p = bestPos[i];
                        float   s = bestSizes[i];
                        bestScores[i] = float.PositiveInfinity;

                        const float Half = 0.6f;

                        float offset = s * Half * 0.5f;

                        samplePos[samplePosCount + 0] = (p + new Vector2(+offset, +offset));
                        samplePos[samplePosCount + 1] = (p + new Vector2(-offset, +offset));
                        samplePos[samplePosCount + 2] = (p + new Vector2(-offset, -offset));
                        samplePos[samplePosCount + 3] = (p + new Vector2(+offset, -offset));

                        s *= s * Half;
                        sampleSize[samplePosCount + 0] = (s);
                        sampleSize[samplePosCount + 1] = (s);
                        sampleSize[samplePosCount + 2] = (s);
                        sampleSize[samplePosCount + 3] = (s);
                        samplePosCount += 4;
                    }
                }

                result = bestEver;
            }


            if (DebugDraw)
            {
                DrawCross(result + position2D);
            }


            newVelocity = To3D(Vector2.ClampMagnitude(result, maxSpeed));
        }
Esempio n. 45
0
        internal void CalculateVelocity(Pathfinding.RVO.Simulator.WorkerContext context)
        {

            if (locked)
            {
                newVelocity = Vector2.zero;
                return;
            }

            if (context.vos.Length < neighbours.Count + simulator.obstacles.Count)
            {
                context.vos = new VO[Mathf.Max(context.vos.Length * 2, neighbours.Count + simulator.obstacles.Count)];
            }

            Vector2 position2D = new Vector2(position.x, position.z);

            var vos = context.vos;
            var voCount = 0;

            Vector2 optimalVelocity = new Vector2(velocity.x, velocity.z);

            float inverseAgentTimeHorizon = 1.0f / agentTimeHorizon;

            float wallThickness = simulator.WallThickness;

            float wallWeight = simulator.algorithm == Simulator.SamplingAlgorithm.GradientDecent ? 1 : WallWeight;

            for (int i = 0; i < simulator.obstacles.Count; i++)
            {
                var obstacle = simulator.obstacles[i];
                var vertex = obstacle;
                do
                {

                    if (vertex.ignore || position.y > vertex.position.y + vertex.height || position.y + height < vertex.position.y || (vertex.layer & collidesWith) == 0)
                    {
                        vertex = vertex.next;
                        Debug.Log("continue");
                        continue;
                    }

                    float cross = VO.Det(new Vector2(vertex.position.x, vertex.position.z), vertex.dir, position2D);// vertex.dir.x * ( vertex.position.z - position.z ) - vertex.dir.y * ( vertex.position.x - position.x );

                    // Signed distance from the line (not segment), lines are infinite
                    // Usually divided by vertex.dir.magnitude, but that is known to be 1
                    float signedDist = cross;

                    float dotFactor = Vector2.Dot(vertex.dir, position2D - new Vector2(vertex.position.x, vertex.position.z));

                    // It is closest to the segment
                    // if the dotFactor is <= 0 or >= length of the segment
                    // WallThickness*0.1 is added as a margin to avoid false positives when moving along the edges of square obstacles
                    bool closestIsEndpoints = dotFactor <= wallThickness * 0.05f || dotFactor >= (new Vector2(vertex.position.x, vertex.position.z) - new Vector2(vertex.next.position.x, vertex.next.position.z)).magnitude - wallThickness * 0.05f;

                    if (Mathf.Abs(signedDist) < neighbourDist)
                    {
                        if (signedDist <= 0 && !closestIsEndpoints && signedDist > -wallThickness)
                        {
                            // Inside the wall on the "wrong" side
                            vos[voCount] = new VO(position2D, new Vector2(vertex.position.x, vertex.position.z) - position2D, vertex.dir, wallWeight * 2);
                            voCount++;
                        }
                        else if (signedDist > 0)
                        {
                            //Debug.DrawLine (position, (vertex.position+vertex.next.position)*0.5f, Color.yellow);
                            Vector2 p1 = new Vector2(vertex.position.x, vertex.position.z) - position2D;
                            Vector2 p2 = new Vector2(vertex.next.position.x, vertex.next.position.z) - position2D;
                            Vector2 tang1 = (p1).normalized;
                            Vector2 tang2 = (p2).normalized;
                            vos[voCount] = new VO(position2D, p1, p2, tang1, tang2, wallWeight);
                            voCount++;

                        }
                    }
                    vertex = vertex.next;
                } while (vertex != obstacle);
            }

            for (int o = 0; o < neighbours.Count; o++)
            {

                Agent other = neighbours[o];

                if (other == this) continue;

                float maxY = System.Math.Min(position.y + height, other.position.y + other.height);
                float minY = System.Math.Max(position.y, other.position.y);

                //The agents cannot collide since they
                //are on different y-levels
                if (maxY - minY < 0)
                {
                    continue;
                }

                Vector2 otherOptimalVelocity = new Vector2(other.Velocity.x, other.velocity.z);


                float totalRadius = radius + other.radius;

                // Describes a circle on the border of the VO
                //float boundingRadius = totalRadius * inverseAgentTimeHorizon;
                Vector2 voBoundingOrigin = new Vector2(other.position.x, other.position.z) - position2D;

                //float boundingDist = voBoundingOrigin.magnitude;

                Vector2 relativeVelocity = optimalVelocity - otherOptimalVelocity;

                {
                    //voBoundingOrigin *= inverseAgentTimeHorizon;
                    //boundingDist *= inverseAgentTimeHorizon;

                    // Common case, no collision

                    Vector2 voCenter;
                    if (other.locked)
                    {
                        voCenter = otherOptimalVelocity;
                    }
                    else
                    {
                        voCenter = (optimalVelocity + otherOptimalVelocity) * 0.5f;
                    }

                    vos[voCount] = new VO(voBoundingOrigin, voCenter, totalRadius, relativeVelocity, inverseAgentTimeHorizon, 1);
                    voCount++;
                    if (DebugDraw) DrawVO(position2D + voBoundingOrigin * inverseAgentTimeHorizon + voCenter, totalRadius * inverseAgentTimeHorizon, position2D + voCenter);
                }


            }


            Vector2 result = Vector2.zero;

            if (simulator.algorithm == Simulator.SamplingAlgorithm.GradientDecent)
            {
                if (this.DebugDraw)
                {
                    const int PlotWidth = 40;
                    const float WorldPlotWidth = 15;

                    for (int x = 0; x < PlotWidth; x++)
                    {
                        for (int y = 0; y < PlotWidth; y++)
                        {
                            Vector2 p = new Vector2(x * WorldPlotWidth / PlotWidth, y * WorldPlotWidth / PlotWidth);

                            Vector2 dir = Vector2.zero;
                            float weight = 0;
                            for (int i = 0; i < voCount; i++)
                            {
                                float w = 0;
                                dir += vos[i].Sample(p - position2D, out w);
                                if (w > weight) weight = w;
                            }
                            Vector2 d2 = (new Vector2(desiredVelocity.x, desiredVelocity.z) - (p - position2D));
                            dir += d2 * DesiredVelocityScale;

                            if (d2.magnitude * DesiredVelocityWeight > weight) weight = d2.magnitude * DesiredVelocityWeight;

                            if (weight > 0) dir /= weight;

                            //Vector2 d3 = simulator.SampleDensity (p+position2D);
                            Debug.DrawRay(To3D(p), To3D(d2 * 0.00f), Color.blue);
                            //simulator.Plot (p, Rainbow(weight*simulator.colorScale));

                            float sc = 0;
                            Vector2 p0 = p - Vector2.one * WorldPlotWidth * 0.5f;
                            Vector2 p1 = Trace(vos, voCount, p0, 0.01f, out sc);
                            if ((p0 - p1).sqrMagnitude < Sqr(WorldPlotWidth / PlotWidth) * 2.6f)
                            {
                                Debug.DrawRay(To3D(p1 + position2D), Vector3.up * 1, Color.red);
                            }
                        }
                    }
                }

                //if ( debug ) {
                float best = float.PositiveInfinity;

                float cutoff = new Vector2(velocity.x, velocity.z).magnitude * simulator.qualityCutoff;

                //for ( int i = 0; i < 10; i++ ) {
                {
                    result = Trace(vos, voCount, new Vector2(desiredVelocity.x, desiredVelocity.z), cutoff, out best);
                    if (DebugDraw) DrawCross(result + position2D, Color.yellow, 0.5f);
                }

                // Can be uncommented for higher quality local avoidance
                /*for ( int i = 0; i < 3; i++ ) {
                    Vector2 p = desiredVelocity + new Vector2(Mathf.Cos(Mathf.PI*2*(i/3.0f)), Mathf.Sin(Mathf.PI*2*(i/3.0f)));
                    float score;
                    Vector2 res = Trace ( vos, voCount, p, velocity.magnitude*simulator.qualityCutoff, out score );
					
                    if ( score < best ) {
                        //if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
                        result = res;
                        best = score;
                    }
                }*/

                {
                    Vector2 p = this.Velocity;
                    float score;
                    Vector2 res = Trace(vos, voCount, p, cutoff, out score);

                    if (score < best)
                    {
                        //if ( score < best*0.9f ) Debug.Log ("Better " + score + " < " + best);
                        result = res;
                        best = score;
                    }
                    if (DebugDraw) DrawCross(res + position2D, Color.magenta, 0.5f);
                }
            }
            else
            {
                // Adaptive sampling

                Vector2[] samplePos = context.samplePos;
                float[] sampleSize = context.sampleSize;
                int samplePosCount = 0;


                Vector2 desired2D = new Vector2(desiredVelocity.x, desiredVelocity.z);
                float sampleScale = Mathf.Max(radius, Mathf.Max(desired2D.magnitude, Velocity.magnitude));
                samplePos[samplePosCount] = desired2D;
                sampleSize[samplePosCount] = sampleScale * 0.3f;
                samplePosCount++;

                const float GridScale = 0.3f;

                // Initial 9 samples
                samplePos[samplePosCount] = optimalVelocity;
                sampleSize[samplePosCount] = sampleScale * GridScale;
                samplePosCount++;

                {
                    Vector2 fw = optimalVelocity * 0.5f;
                    Vector2 rw = new Vector2(fw.y, -fw.x);

                    const int Steps = 8;
                    for (int i = 0; i < Steps; i++)
                    {
                        samplePos[samplePosCount] = rw * Mathf.Sin(i * Mathf.PI * 2 / Steps) + fw * (1 + Mathf.Cos(i * Mathf.PI * 2 / Steps));
                        sampleSize[samplePosCount] = (1.0f - (Mathf.Abs(i - Steps * 0.5f) / Steps)) * sampleScale * 0.5f;
                        samplePosCount++;
                    }

                    const float InnerScale = 0.6f;
                    fw *= InnerScale;
                    rw *= InnerScale;

                    const int Steps2 = 6;
                    for (int i = 0; i < Steps2; i++)
                    {
                        samplePos[samplePosCount] = rw * Mathf.Cos((i + 0.5f) * Mathf.PI * 2 / Steps2) + fw * ((1.0f / InnerScale) + Mathf.Sin((i + 0.5f) * Mathf.PI * 2 / Steps2));
                        sampleSize[samplePosCount] = sampleScale * 0.3f;
                        samplePosCount++;
                    }

                    const float TargetScale = 0.2f;

                    const int Steps3 = 6;
                    for (int i = 0; i < Steps3; i++)
                    {
                        samplePos[samplePosCount] = optimalVelocity + new Vector2(sampleScale * TargetScale * Mathf.Cos((i + 0.5f) * Mathf.PI * 2 / Steps3), sampleScale * TargetScale * Mathf.Sin((i + 0.5f) * Mathf.PI * 2 / Steps3));
                        sampleSize[samplePosCount] = sampleScale * TargetScale * 2;
                        samplePosCount++;
                    }
                }

                samplePos[samplePosCount] = optimalVelocity * 0.5f;
                sampleSize[samplePosCount] = sampleScale * 0.4f;
                samplePosCount++;

                const int KeepCount = Simulator.WorkerContext.KeepCount;
                Vector2[] bestPos = context.bestPos;
                float[] bestSizes = context.bestSizes;
                float[] bestScores = context.bestScores;

                for (int i = 0; i < KeepCount; i++)
                {
                    bestScores[i] = float.PositiveInfinity;
                }
                bestScores[KeepCount] = float.NegativeInfinity;

                Vector2 bestEver = optimalVelocity;
                float bestEverScore = float.PositiveInfinity;

                for (int sub = 0; sub < 3; sub++)
                {

                    for (int i = 0; i < samplePosCount; i++)
                    {

                        float score = 0;
                        for (int vo = 0; vo < voCount; vo++)
                        {
                            score = System.Math.Max(score, vos[vo].ScalarSample(samplePos[i]));
                        }
                        // Note that velocity is a vector and speed is a scalar, not the same thing
                        float bonusForDesiredVelocity = (samplePos[i] - desired2D).magnitude;

                        // This didn't work out as well as I though
                        // Code left here because I might reenable it later
                        //float bonusForDesiredSpeed = Mathf.Abs (samplePos[i].magnitude - desired2D.magnitude);

                        float biasedScore = score + bonusForDesiredVelocity * DesiredVelocityWeight;// + bonusForDesiredSpeed*0;
                        score += bonusForDesiredVelocity * 0.001f;

                        if (DebugDraw)
                        {
                            DrawCross(position2D + samplePos[i], Rainbow(Mathf.Log(score + 1) * 5), sampleSize[i] * 0.5f);
                        }

                        if (biasedScore < bestScores[0])
                        {
                            for (int j = 0; j < KeepCount; j++)
                            {
                                if (biasedScore >= bestScores[j + 1])
                                {
                                    bestScores[j] = biasedScore;
                                    bestSizes[j] = sampleSize[i];
                                    bestPos[j] = samplePos[i];
                                    break;
                                }
                            }
                        }

                        if (score < bestEverScore)
                        {
                            bestEver = samplePos[i];
                            bestEverScore = score;

                            if (score == 0)
                            {
                                sub = 100;
                                break;
                            }
                        }
                    }

                    samplePosCount = 0;

                    for (int i = 0; i < KeepCount; i++)
                    {
                        Vector2 p = bestPos[i];
                        float s = bestSizes[i];
                        bestScores[i] = float.PositiveInfinity;

                        const float Half = 0.6f;

                        float offset = s * Half * 0.5f;

                        samplePos[samplePosCount + 0] = (p + new Vector2(+offset, +offset));
                        samplePos[samplePosCount + 1] = (p + new Vector2(-offset, +offset));
                        samplePos[samplePosCount + 2] = (p + new Vector2(-offset, -offset));
                        samplePos[samplePosCount + 3] = (p + new Vector2(+offset, -offset));

                        s *= s * Half;
                        sampleSize[samplePosCount + 0] = (s);
                        sampleSize[samplePosCount + 1] = (s);
                        sampleSize[samplePosCount + 2] = (s);
                        sampleSize[samplePosCount + 3] = (s);
                        samplePosCount += 4;
                    }
                }

                result = bestEver;
            }


            if (DebugDraw) DrawCross(result + position2D);


            newVelocity = To3D(Vector2.ClampMagnitude(result, maxSpeed));
            if (newVelocity != Vector3.zero)
            {
                float angle = Vector3.Angle(DesiredVelocity, newVelocity);
                //:限制新速度方向
                //如果计算出来的新速度是与设计速度的夹角大于angleMax
                //则新速度旋转到最大夹角
                float angleMax = 45;
                if (angle > angleMax)
                {
                    Vector2 firstObject = new Vector2(DesiredVelocity.x, DesiredVelocity.z);
                    Vector2 secondObject = new Vector2(newVelocity.x, newVelocity.z);
                    float det = firstObject.x * secondObject.y - firstObject.y * secondObject.x;
                    if (det > 0)//param2 is unclockwise
                    {
                        Vector2 verticalObject = secondObject.Rotate(-(angle - angleMax));
                        newVelocity.x = verticalObject.x;
                        newVelocity.z = verticalObject.y;

                        if (newVelocity.magnitude < minSpeed)
                        {
                            newVelocity = newVelocity.normalized * minSpeed;
                        }
                    }
                    else if (det < 0)
                    {
                        Vector2 verticalObject = secondObject.Rotate((angle - angleMax));
                        newVelocity.x = verticalObject.x;
                        newVelocity.z = verticalObject.y;
                        if (newVelocity.magnitude < minSpeed)
                        {
                            newVelocity = newVelocity.normalized * minSpeed;
                        }
                    }
                    else
                    {
                        newVelocity = Vector3.zero;
                    }
                }
                if (printVelocity)
                {
                    Debug.Log("vel " + velocity + "newVelocity " + newVelocity);
                }
            }



        }
Esempio n. 46
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          20/06/2014      Add
 /// </modified>
 public int Insert(VO.CITY obj)
 {
     return new DAO.CITY().Insert(obj.CITY_NAME);
 }
        /// <summary>
        /// 新增限制人員清單
        /// </summary>
        /// <param name="myActivityGroupLimitVO">限制人員清單</param>
        /// <param name="trans">資料庫交易物件</param>
        /// <returns>新增限制人員清單</returns>
        public int INSERT(VO.ActivityGroupLimitVO myActivityGroupLimitVO, SqlTransaction trans)
        {
            SqlParameter[] sqlParams = new SqlParameter[2];

            sqlParams[0] = new SqlParameter("@activity_id", SqlDbType.UniqueIdentifier);
            sqlParams[0].Value = myActivityGroupLimitVO.activity_id;
            sqlParams[1] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 50);
            sqlParams[1].Value = myActivityGroupLimitVO.emp_id;

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("INSERT ActivityGroupLimit ");
            sb.AppendLine("([activity_id],[emp_id]) ");
            sb.AppendLine("VALUES ");
            sb.AppendLine("(@activity_id,@emp_id); ");

            return SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 48
0
 public ToastData() : base()
 {
     this.messages = new LD <ToastMessage>(this, (byte)Property.messages);
     this.maxIndex = new VO <int>(this, (byte)Property.maxIndex, 0);
     this.state    = new VO <State>(this, (byte)Property.state, State.Normal);
 }
Esempio n. 49
0
 public int InsertRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO)
 {
     DAO.RoleUserMappingDAO myRoleUserMappingDAO = new ACMS.DAO.RoleUserMappingDAO();
     return myRoleUserMappingDAO.InsertRoleUserMapping(myRoleUserMappingVO);
 }
Esempio n. 50
0
        /// <summary>
        /// 修改一筆活動資料
        /// </summary>
        /// <param name="myActivatyVO">活動資料型別物件</param>
        /// <returns>修改一筆活動資料</returns>
        public int UpdateActivaty(VO.ActivatyVO myActivatyVO)
        {
            SqlParameter[] sqlParams = new SqlParameter[34];

            sqlParams[0] = new SqlParameter("@id", SqlDbType.UniqueIdentifier);
            sqlParams[0].Value = myActivatyVO.id;
            sqlParams[1] = new SqlParameter("@activity_type", SqlDbType.NChar, 1);
            sqlParams[1].Value = myActivatyVO.activity_type;
            sqlParams[2] = new SqlParameter("@activity_info", SqlDbType.NText);
            sqlParams[2].Value = myActivatyVO.activity_info;
            sqlParams[3] = new SqlParameter("@org_id", SqlDbType.NVarChar, 50);
            sqlParams[3].Value = myActivatyVO.org_id;
            sqlParams[4] = new SqlParameter("@activity_name", SqlDbType.NVarChar, 50);
            sqlParams[4].Value = myActivatyVO.activity_name;
            sqlParams[5] = new SqlParameter("@people_type", SqlDbType.NVarChar, 50);
            sqlParams[5].Value = myActivatyVO.people_type;
            sqlParams[6] = new SqlParameter("@activity_startdate", SqlDbType.DateTime);
            if (myActivatyVO.activity_startdate == null || myActivatyVO.activity_startdate==DateTime.Today )
            {
                sqlParams[6].Value = DBNull.Value;
            }
            else
            {
                sqlParams[6].Value = myActivatyVO.activity_startdate;
            }
            sqlParams[7] = new SqlParameter("@activity_enddate", SqlDbType.DateTime);

            if (myActivatyVO.activity_enddate == null || myActivatyVO.activity_enddate == DateTime.Today)
            {
                sqlParams[7].Value = DBNull.Value;
            }
            else
            {
                sqlParams[7].Value = myActivatyVO.activity_enddate;
            }

            sqlParams[8] = new SqlParameter("@limit_count", SqlDbType.Int);
            if (myActivatyVO.activity_startdate == DateTime.Today)
            {
                sqlParams[8].Value = DBNull.Value;
            }
            else
            {
                sqlParams[8].Value = myActivatyVO.limit_count;
            }
            sqlParams[9] = new SqlParameter("@limit2_count", SqlDbType.Int);
            if (myActivatyVO.activity_startdate == DateTime.Today)
            {
                sqlParams[9].Value = DBNull.Value;
            }
            else
            {
                sqlParams[9].Value = myActivatyVO.limit2_count;
            }
            sqlParams[10] = new SqlParameter("@team_member_max", SqlDbType.Int);
            sqlParams[10].Value = myActivatyVO.team_member_max;
            sqlParams[11] = new SqlParameter("@team_member_min", SqlDbType.Int);
            sqlParams[11].Value = myActivatyVO.team_member_min;
            sqlParams[12] = new SqlParameter("@regist_startdate", SqlDbType.DateTime);

            if (myActivatyVO.regist_startdate == null)
            {
                sqlParams[12].Value = DBNull.Value;
            }
            else
            {
                sqlParams[12].Value = myActivatyVO.regist_startdate;
            }

            sqlParams[13] = new SqlParameter("@regist_deadline", SqlDbType.DateTime);

            if (myActivatyVO.regist_deadline == null)
            {
                sqlParams[13].Value = DBNull.Value;
            }
            else
            {
                sqlParams[13].Value = myActivatyVO.regist_deadline;
            }

            sqlParams[14] = new SqlParameter("@cancelregist_deadline", SqlDbType.DateTime);

            if (myActivatyVO.cancelregist_deadline == null)
            {
                sqlParams[14].Value = DBNull.Value;
            }
            else
            {
                sqlParams[14].Value = myActivatyVO.cancelregist_deadline;
            }

            sqlParams[15] = new SqlParameter("@is_showfile", SqlDbType.NChar, 1);
            sqlParams[15].Value = myActivatyVO.is_showfile;
            sqlParams[16] = new SqlParameter("@is_showprogress", SqlDbType.NChar, 1);
            sqlParams[16].Value = myActivatyVO.is_showprogress;
            sqlParams[17] = new SqlParameter("@is_showperson_fix1", SqlDbType.NChar, 1);
            sqlParams[17].Value = myActivatyVO.is_showperson_fix1;
            sqlParams[18] = new SqlParameter("@is_showperson_fix2", SqlDbType.NChar, 1);
            sqlParams[18].Value = myActivatyVO.is_showperson_fix2;
            sqlParams[19] = new SqlParameter("@personextcount_max", SqlDbType.Int);
            sqlParams[19].Value = myActivatyVO.personextcount_max;
            sqlParams[20] = new SqlParameter("@personextcount_min", SqlDbType.Int);
            sqlParams[20].Value = myActivatyVO.personextcount_min;
            sqlParams[21] = new SqlParameter("@is_showidno", SqlDbType.NChar, 1);
            sqlParams[21].Value = myActivatyVO.is_showidno;
            sqlParams[22] = new SqlParameter("@is_showremark", SqlDbType.NChar, 1);
            sqlParams[22].Value = myActivatyVO.is_showremark;
            sqlParams[23] = new SqlParameter("@remark_name", SqlDbType.NVarChar,50);
            sqlParams[23].Value = myActivatyVO.remark_name;
            sqlParams[24] = new SqlParameter("@is_showteam_fix1", SqlDbType.NChar, 1);
            sqlParams[24].Value = myActivatyVO.is_showteam_fix1;
            sqlParams[25] = new SqlParameter("@is_showteam_fix2", SqlDbType.NChar, 1);
            sqlParams[25].Value = myActivatyVO.is_showteam_fix2;
            sqlParams[26] = new SqlParameter("@teamextcount_max", SqlDbType.Int);
            sqlParams[26].Value = myActivatyVO.teamextcount_max;
            sqlParams[27] = new SqlParameter("@teamextcount_min", SqlDbType.Int);
            sqlParams[27].Value = myActivatyVO.teamextcount_min;
            sqlParams[28] = new SqlParameter("@is_grouplimit", SqlDbType.NChar, 1);
            sqlParams[28].Value = myActivatyVO.is_grouplimit;
            sqlParams[29] = new SqlParameter("@notice", SqlDbType.NText);
            sqlParams[29].Value = myActivatyVO.notice;
            sqlParams[30] = new SqlParameter("@active", SqlDbType.NChar, 1);
            if (myActivatyVO.active == "Y")
            {
                sqlParams[30].Value = myActivatyVO.active;
            }
            else
            {
                sqlParams[30].Value = DBNull.Value;
            }
            if (myActivatyVO.Send3DayMail)
            {
                sqlParams[31] = new SqlParameter("@Send3DayMail", true);
            }
            else
            {
                sqlParams[31] = new SqlParameter("@Send3DayMail",false );
            }

            if (myActivatyVO.Send1DayMail)
            {
                sqlParams[32] = new SqlParameter("@Send1DayMail",true);
            }
            else
            {
                sqlParams[32] = new SqlParameter("@Send1DayMail",false);
            }

            if (myActivatyVO.SendUnregist)
            {
                sqlParams[33] = new SqlParameter("@SendUnregist", true);
            }
            else
            {
                sqlParams[33] = new SqlParameter("@SendUnregist", false);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("UPDATE Activity ");
            sb.AppendLine("SET id=@id ");
            sb.AppendLine(",activity_type=@activity_type ");
            sb.AppendLine(",activity_info=@activity_info ");
            sb.AppendLine(",org_id=@org_id ");
            sb.AppendLine(",activity_name=@activity_name ");
            sb.AppendLine(",people_type=@people_type ");
            sb.AppendLine(",activity_startdate=@activity_startdate ");
            sb.AppendLine(",activity_enddate=@activity_enddate ");
            sb.AppendLine(",limit_count=@limit_count ");
            sb.AppendLine(",limit2_count=@limit2_count ");
            sb.AppendLine(",team_member_max=@team_member_max ");
            sb.AppendLine(",team_member_min=@team_member_min ");
            sb.AppendLine(",regist_startdate=@regist_startdate ");
            sb.AppendLine(",regist_deadline=@regist_deadline ");
            sb.AppendLine(",cancelregist_deadline=@cancelregist_deadline ");
            sb.AppendLine(",is_showfile=@is_showfile ");
            sb.AppendLine(",is_showprogress=@is_showprogress ");
            sb.AppendLine(",is_showperson_fix1=@is_showperson_fix1 ");
            sb.AppendLine(",is_showperson_fix2=@is_showperson_fix2 ");
            sb.AppendLine(",personextcount_max=@personextcount_max ");
            sb.AppendLine(",personextcount_min=@personextcount_min ");
            sb.AppendLine(",is_showidno=@is_showidno ");
            sb.AppendLine(",is_showremark=@is_showremark ");
            sb.AppendLine(",remark_name=@remark_name ");
            sb.AppendLine(",is_showteam_fix1=@is_showteam_fix1 ");
            sb.AppendLine(",is_showteam_fix2=@is_showteam_fix2 ");
            sb.AppendLine(",teamextcount_max=@teamextcount_max ");
            sb.AppendLine(",teamextcount_min=@teamextcount_min ");
            sb.AppendLine(",is_grouplimit=@is_grouplimit ");
            sb.AppendLine(",notice=@notice ");
            sb.AppendLine(",active=@active ");
            sb.AppendLine(",Send3DayMail=@Send3DayMail ");
            sb.AppendLine(",Send1DayMail=@Send1DayMail ");
            sb.AppendLine(",SendUnregist=@SendUnregist ");
            sb.AppendLine("WHERE 1=1 ");
            sb.AppendLine("AND id=@id ");

            return SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams);
        }
Esempio n. 51
0
 /// <summary>
 /// Update
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          20/06/2014      Add
 /// </modified>
 public int Update(VO.CITY obj)
 {
     return new DAO.CITY().Update(obj.ID, obj.CITY_NAME);
 }
Esempio n. 52
0
 public int UpdateUnit(VO.UnitVO myUnitVO)
 {
     DAO.UnitDAO myUnitDAO = new ACMS.DAO.UnitDAO();
     return myUnitDAO.UpdateUnit(myUnitVO);
 }
Esempio n. 53
0
 public UIData() : base()
 {
     this.state  = new VD <State>(this, (byte)Property.state, new Normal());
     this.onHide = new VO <OnHide>(this, (byte)Property.onHide, null);
 }
Esempio n. 54
0
 public Hide() : base()
 {
     this.time     = new VO <float>(this, (byte)Property.time, 0);
     this.duration = new VO <float>(this, (byte)Property.duration, ShowDuration);
 }
Esempio n. 55
0
 public Appear() : base()
 {
     this.toastMessage = new VO <ReferenceData <ToastMessage> >(this, (byte)Property.toastMessage, new ReferenceData <ToastMessage>(null));
 }
Esempio n. 56
0
 /// <summary>
 /// Check exist
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          14/06/2014      Add
 /// </modified>
 public int Insert(VO.SCHOOL obj)
 {
     return new DAO.SCHOOL().Insert(obj.SCHOOL_NAME, obj.ADDRESS, obj.TELEPHONE, obj.EMAIL,
         obj.WEBSITE, obj.CITY_ID);
 }
Esempio n. 57
0
 /// <summary>
 /// Delete
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          25/06/2014      Add
 /// </modified>
 public bool Delete(VO.CLASS obj)
 {
     return false;
 }
 public SortableSearchItem(double normalizedDistance, VO record)
 {
     DistanceFromCriteria = normalizedDistance;
     Record = record;
 }