示例#1
0
        public void TestWhen1()
        {
            List <Drilling> drillings = new Drillings(1, 10, 0).AllDrillingsRounded;

            Assert.AreEqual(1, drillings.Count);
            Drilling d = drillings[0];

            Assert.AreEqual(0, d.Angle);
            Assert.AreEqual(0, d.Coord.X);
            Assert.AreEqual(5, d.Coord.Y);
        }
    public void DisplayDrillings(Drillings drillings)
    {
        Debug.Log("Drillings (Visu)" + drillings.ToString());


        for (int i = VisuPanel.childCount - 1; i >= 0; i--)
        {
            GameObject de = VisuPanel.GetChild(i).gameObject;
            if (de.name == "SubTitle")
            {
                continue;
            }
            Destroy(de);
            if (de == null)
            {
                de = null;
            }
        }

        gridParentList = new List <GameObject>();

        for (int j = 0; j < drillings.AllDrillingsRounded.Count / (NB_COLUMNS * NB_ROWS) + 1; j++)
        {
            int maxIndex = NB_COLUMNS * NB_ROWS;
            if (drillings.AllDrillingsRounded.Count < (j + 1) * maxIndex)
            {
                maxIndex = drillings.AllDrillingsRounded.Count - j * maxIndex;
            }

            if (maxIndex == 0)
            {
                continue;
            }
            GridLayoutGroup gridParent = Instantiate <GridLayoutGroup>(prefabVisuGridLayout);
            gridParent.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
            gridParent.constraintCount = NB_COLUMNS;

            gridParent.transform.SetParent(VisuPanel, false);
            gridParentList.Add(gridParent.gameObject);

            for (int i = 0; i < maxIndex; i++)
            {
                Drilling        d = drillings.AllDrillingsRounded[i + j * maxIndex];
                DrillingElement drillingElement = Instantiate <DrillingElement>(prefabDrillingElement);
                drillingElement.UpdateFields(i + (j * NB_COLUMNS * NB_ROWS) + 1, d.Coord);
                drillingElement.transform.SetParent(gridParent.transform, false);
            }
        }
        UpdateIndex(0);
    }
示例#3
0
        public void TestWhen4FromCoord()
        {
            List <Drilling> drillings = Drillings.DrillingsFromExistingHole(4, new Vector2(-5, 0)).AllDrillingsRounded;

            Assert.AreEqual(4, drillings.Count);
            Drilling d = drillings[0];

            Assert.AreEqual(0, d.Angle);
            Assert.AreEqual(0, d.Coord.X);
            Assert.AreEqual(5, d.Coord.Y);

            d = drillings[1];
            Assert.AreEqual(90, d.Angle);
            Assert.AreEqual(5, d.Coord.X);
            Assert.AreEqual(0, d.Coord.Y);
        }
示例#4
0
        public void TestWhen2Tilted()
        {
            List <Drilling> drillings = new Drillings(2, 10, 90).AllDrillingsRounded;

            Assert.AreEqual(2, drillings.Count);
            Drilling d = drillings[0];

            Assert.AreEqual(90, d.Angle);
            Assert.AreEqual(5, d.Coord.X);
            Assert.AreEqual(0, d.Coord.Y);

            d = drillings[1];
            Assert.AreEqual(270, d.Angle);
            Assert.AreEqual(-5, d.Coord.X);
            Assert.AreEqual(0, d.Coord.Y);
        }
示例#5
0
    private void DisplayDrillings(Drillings drillings)
    {
        for (int i = parent.childCount - 1; i >= 0; i--)
        {
            Destroy(parent.GetChild(i).gameObject);
        }

        for (int i = 0; i < drillings.AllDrillingsRounded.Count; i++)
        {
            Drilling     d     = drillings.AllDrillingsRounded[i];
            PointCreator point = Instantiate <PointCreator>(prefabPoint);
            point.CreatePointIndex(i + 1);

            float x = (float)(d.Coord.X * 2 * NORMA_RADIUS / drillings.Diameter);
            float y = (float)(d.Coord.Y * 2 * NORMA_RADIUS / drillings.Diameter);

            point.transform.SetParent(parent);
            point.transform.localPosition = new Vector3(x, y, -20);
            point.transform.localScale    = new Vector3(0.1f, 0.1f, 0);
        }
    }
 public void Data_DataChanged(object sender, DataChangedArgs args)
 {
     drillings = args.Drillings;
     Debug.Log("Data has received");
 }