void OnMouseDown()
 {
     if (Input.GetKey(KeyCode.Space))
     {
         RaycastHit hit;
         Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(ray, out hit))
         {
             GameObject objKe = Instantiate(CreateObjOnMap.kePrefabSta, hit.point, new Quaternion(0, 0, 0, 0));
             objKe.GetComponent <BoxCollider>().enabled = true;
             Ke ke = new Ke();
             ke.Id      = NextID(CreateObjOnMap.listKe[CreateObjOnMap.listKe.Count - 1].Id, "K");
             ke.X       = 0;
             ke.DayKeID = "";
             objKe.name = ke.Id;
             ke.Obj     = objKe;
             objKe.GetComponent <Drag>().ke = ke;
             CreateObjOnMap.listKe.Add(ke);
         }
     }
 }
Beispiel #2
0
        private void GenerateKe()
        {
            foreach (var triangle in _triangles)
            {
                var b = GetTriangleSquare(triangle) * 2;

                var vi = triangle.GetVertex(0);
                var vj = triangle.GetVertex(1);
                var vm = triangle.GetVertex(2);

                var pjmCoeffs = GetCoefficients(vj, vm);
                var ipmCoeffs = GetCoefficients(vm, vi);
                var ijpCoeffs = GetCoefficients(vi, vj);

                var coefsMatrix = new[]
                {
                    pjmCoeffs,
                    ipmCoeffs,
                    ijpCoeffs
                };

                var A = new double[3, 3];
                for (var i = 0; i < 3; i++)
                {
                    for (var j = 0; j < 3; j++)
                    {
                        var beforeDivide = Math.Pow(_a[0], 2) * coefsMatrix[i][1] * coefsMatrix[j][1] +
                                           Math.Pow(_a[1], 2) * coefsMatrix[i][2] * coefsMatrix[j][2];
                        A[i, j] = beforeDivide / (2 * b);// : (-1)*beforeDivide/(2*b);
                    }
                }


                var matrixToAdd = DenseMatrix.OfArray(A);
                Ke.Add(matrixToAdd);
            }
        }
Beispiel #3
0
        private KeViewModel GetKe(Ke x)
        {
            var model = new KeViewModel
            {
                Id           = x.Id,
                Ten          = x.Ten,
                SoHopToiDa   = x.SoHopToiDa,
                SoHopHienTai = x.SoHopHienTai,
                NamBatDau    = x.NamBatDau,
                NamKetThuc   = x.NamKetThuc,
                SoThuTu      = x.SoThuTu,
                TinhTrang    = x.TinhTrang,
                NgayTao      = x.NgayTao,
                NgayCapNhat  = x.NgayCapNhat,
                TrangThai    = x.TrangThai,
                UserId       = x.UserId,
                Tuid         = x.Tuid,
                Hops         = x.Hops,
                User         = x.User,
                Tu           = x.Tu
            };

            return(model);
        }
Beispiel #4
0
        public string T_End()
        {
            double max = 0;

            for (int i = 0; i < WorkList.Count; i++)
            {
                if (WorkList[i].end_x > max)
                {
                    max = WorkList[i].end_x;
                }
            }

            double T = (max - 50) / interval_vertical;
            int    sum_node_weight = 0;

            for (int i = 0; i < TopListNew.Count; i++)
            {
                sum_node_weight += TopListNew[i].weight;
            }

            Kp   = sum_node_weight / T;
            Ke   = Kp / TopListCSNew.Count;
            Keap = Tkr / T;

            return("Tкрг = " + Tkr + "\nT = " + T + "\nKпр = " + Kp.ToString("N2") + "\nКе = " + Ke.ToString("N2") + "\nКеап = "
                   + Keap.ToString("N2") + "\n");
        }
Beispiel #5
0
    void Start()
    {
        dayKePrefabSta    = dayKePrefab;
        kePrefabSta       = kePrefab;
        item1xSta         = item1x;
        item2xSta         = item2x;
        listDayKe         = new List <DayKe>();
        listKe            = new List <Ke>();
        listItemAll       = new List <SanPham>();
        listItem          = new List <SanPham>();
        listItemWareHouse = new List <SanPham>();
        listType          = new List <LoaiSanPham>();
        listNameType      = new List <string>();
        conn = "URI=file:" + Application.dataPath + "/dbSM.s3db";
        try
        {
            dbconn = new SqliteConnection(conn);
            dbconn.Open();
            dbcmd = dbconn.CreateCommand();
            string sqlQuery = "SELECT * FROM DayKe";
            dbcmd.CommandText = sqlQuery;
            reader            = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                string keID  = reader.GetString(0);
                string name  = reader.GetString(1);
                float  X     = reader.GetFloat(2);
                float  Z     = reader.GetFloat(3);
                int    rotY  = reader.GetInt32(4);
                DayKe  dayKe = new DayKe();
                dayKe.Id   = keID;
                dayKe.X    = X;
                dayKe.Z    = Z;
                dayKe.RotY = rotY;
                dayKe.Name = name;
                GameObject objDK = Instantiate(dayKePrefab, new Vector3(dayKe.X, 0, dayKe.Z), new Quaternion(0, 0, 0, 0));
                objDK.transform.eulerAngles = new Vector3(0, dayKe.RotY, 0);
                objDK.name = dayKe.Id;
                dayKe.Obj  = objDK;
                objDK.GetComponent <DragDayKe>().dayKe = dayKe;
                objDK.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = dayKe.Name;
                listDayKe.Add(dayKe);
            }

            sqlQuery          = "SELECT * FROM Ke";
            dbcmd             = dbconn.CreateCommand();
            dbcmd.CommandText = sqlQuery;
            reader            = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                string keID    = reader.GetString(0);
                string daykeID = reader.GetString(1);
                float  X       = reader.GetFloat(2);
                Ke     ke      = new Ke();
                ke.Id      = keID;
                ke.X       = X;
                ke.DayKeID = daykeID;
                GameObject objKe = Instantiate(kePrefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0));
                objKe.name = ke.Id;
                objKe.transform.SetParent(FindParent(ke.DayKeID).transform);
                objKe.transform.localPosition    = new Vector3(ke.X, 0, 0);
                objKe.transform.localEulerAngles = new Vector3(0, 0, 0);
                ke.Obj = objKe;
                objKe.GetComponent <Drag>().ke = ke;
                listKe.Add(ke);
            }

            sqlQuery          = "SELECT * FROM SanPham";
            dbcmd             = dbconn.CreateCommand();
            dbcmd.CommandText = sqlQuery;
            reader            = dbcmd.ExecuteReader();
            while (reader.Read())
            {
                if (reader.GetString(9) == "N")
                {
                    GameObject ke1Found = FindKe(reader.GetString(3));
                    if (ke1Found != null)
                    {
                        GameObject ke2Found = FindKe(reader.GetString(4));
                        if ((int)reader.GetFloat(5) == 1 || ((int)reader.GetFloat(5) == 2 && ke2Found != null && ((ke1Found = ke2Found) || (ke1Found.transform.parent == ke2Found.transform.parent && ke1Found.transform.GetSiblingIndex() == ke2Found.transform.GetSiblingIndex() - 1))))
                        {
                            SanPham sanPham = new SanPham();
                            sanPham.Id          = reader.GetString(0);
                            sanPham.Name        = reader.GetString(1);
                            sanPham.Type        = reader.GetString(2);
                            sanPham.KeID1       = reader.GetString(3);
                            sanPham.KeID2       = reader.GetString(4);
                            sanPham.Size        = (int)reader.GetFloat(5);
                            sanPham.Price       = reader.GetInt32(6);
                            sanPham.Pos1        = reader.GetInt32(7);
                            sanPham.Pos2        = reader.GetInt32(8);
                            sanPham.Status      = false;
                            sanPham.Description = reader.GetString(10);
                            //sanPham.Description = "Đang đợi nhập liệu...";
                            sanPham.Exp      = reader.GetString(11);
                            sanPham.Weight   = reader.GetInt32(12);
                            sanPham.Quantity = reader.GetInt32(13);
                            sanPham.Image    = reader.GetString(14);
                            GameObject item;

                            if (sanPham.Size == 1)
                            {
                                item = Instantiate(item1x, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                            }
                            else
                            {
                                int y = (int)FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).eulerAngles.y;
                                switch (y)
                                {
                                case 0:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x + 0.5f, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                case 180:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x - 0.5f, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                case 90:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z - 0.5f), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                case 270:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z + 0.5f), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                case 44:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x + 0.3535f, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z - 0.3535f), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                case 224:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x - 0.3535f, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z + 0.3535f), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;

                                default:
                                    item = Instantiate(item2x, new Vector3(FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.x + 0.5f, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.y, FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).position.z), FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).rotation);
                                    break;
                                }
                            }
                            item.transform.eulerAngles = new Vector3(item.transform.eulerAngles.x, item.transform.eulerAngles.y, 180f);
                            FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1).GetComponent <BoxCollider>().enabled = false;
                            item.GetComponent <DragItem>().posObj = FindKe(sanPham.KeID1).transform.Search("Position " + sanPham.Pos1);
                            item.GetComponent <DragItem>().posObj.GetComponent <DropItem>().allowDrop = false;

                            FindKe(sanPham.KeID2).transform.Search("Position " + sanPham.Pos2).GetComponent <BoxCollider>().enabled = false;
                            item.GetComponent <DragItem>().posObj2 = FindKe(sanPham.KeID2).transform.Search("Position " + sanPham.Pos2);
                            item.GetComponent <DragItem>().posObj2.GetComponent <DropItem>().allowDrop = false;
                            sanPham.Obj = item;
                            item.GetComponent <DragItem>().sanPham = sanPham;
                            item.GetComponent <MeshRenderer>().material.mainTexture = LoadTexture(Application.dataPath + "/Images/Products/" + sanPham.Image);
                            listItem.Add(sanPham);
                            listItemAll.Add(sanPham);
                        }
                        else
                        {
                            SanPham sanPham = new SanPham();
                            sanPham.Id          = reader.GetString(0);
                            sanPham.Name        = reader.GetString(1);
                            sanPham.Type        = reader.GetString(2);
                            sanPham.KeID1       = "";
                            sanPham.KeID2       = "";
                            sanPham.Size        = (int)reader.GetFloat(5);
                            sanPham.Price       = reader.GetInt32(6);
                            sanPham.Pos1        = 0;
                            sanPham.Pos2        = 0;
                            sanPham.Status      = true;
                            sanPham.Description = reader.GetString(10);
                            //sanPham.Description = "Đang đợi nhập liệu...";
                            sanPham.Exp      = reader.GetString(11);
                            sanPham.Weight   = reader.GetInt32(12);
                            sanPham.Quantity = reader.GetInt32(13);
                            sanPham.Image    = reader.GetString(14);
                            sanPham.Obj      = null;
                            listItemWareHouse.Add(sanPham);
                            listItemAll.Add(sanPham);
                            Warehouse.AddWarehouse(sanPham);
                        }
                    }
                    else
                    {
                        SanPham sanPham = new SanPham();
                        sanPham.Id          = reader.GetString(0);
                        sanPham.Name        = reader.GetString(1);
                        sanPham.Type        = reader.GetString(2);
                        sanPham.KeID1       = "";
                        sanPham.KeID2       = "";
                        sanPham.Size        = (int)reader.GetFloat(5);
                        sanPham.Price       = reader.GetInt32(6);
                        sanPham.Pos1        = 0;
                        sanPham.Pos2        = 0;
                        sanPham.Status      = true;
                        sanPham.Description = reader.GetString(10);
                        //sanPham.Description = "Đang đợi nhập liệu...";
                        sanPham.Exp      = reader.GetString(11);
                        sanPham.Weight   = reader.GetInt32(12);
                        sanPham.Quantity = reader.GetInt32(13);
                        sanPham.Image    = reader.GetString(14);
                        sanPham.Obj      = null;
                        listItemWareHouse.Add(sanPham);
                        listItemAll.Add(sanPham);
                        Warehouse.AddWarehouse(sanPham);
                    }
                }
                else
                {
                    SanPham sanPham = new SanPham();
                    sanPham.Id          = reader.GetString(0);
                    sanPham.Name        = reader.GetString(1);
                    sanPham.Type        = reader.GetString(2);
                    sanPham.KeID1       = "";
                    sanPham.KeID2       = "";
                    sanPham.Size        = (int)reader.GetFloat(5);
                    sanPham.Price       = reader.GetInt32(6);
                    sanPham.Pos1        = 0;
                    sanPham.Pos2        = 0;
                    sanPham.Status      = true;
                    sanPham.Description = reader.GetString(10);
                    //sanPham.Description = "Đang đợi nhập liệu...";
                    sanPham.Exp      = reader.GetString(11);
                    sanPham.Weight   = reader.GetInt32(12);
                    sanPham.Quantity = reader.GetInt32(13);
                    sanPham.Image    = reader.GetString(14);
                    sanPham.Obj      = null;
                    listItemWareHouse.Add(sanPham);
                    listItemAll.Add(sanPham);
                    Warehouse.AddWarehouse(sanPham);
                }
            }

            reader.Close();
            reader = null;
            dbcmd.Dispose();
            dbcmd = null;
            dbconn.Close();
            dbconn = null;
        }
        catch (Exception ex)
        {
            Debug.Log(ex);
        }
    }