Exemplo n.º 1
0
 public PointV2 OtherPoint(PointV2 currentPoint)
 {
     if (currentPoint != PointA)
     {
         return(PointA);
     }
     return(PointB);
 }
Exemplo n.º 2
0
        public ChosenStep FindTheBestStep(RequestHalfStep requestHalfStep, DataTable table)
        {
            // if (ValidationArrangementFigures(requestHalfStep.)) {
            byte[,] tmp_ArrangementFigures;
            System.Collections.Generic.List <MementoItemAssessment> ListItemAssessment =
                new System.Collections.Generic.List <MementoItemAssessment>();
            float oneProcent = 100 / 64;
            float procent    = 0;

            for (int indexRow = 0; indexRow < table.Rows.Count; indexRow++)
            {
                byte[] array = (byte[])table.Rows[indexRow]["ArrangementFigures"];
                tmp_ArrangementFigures = (byte[, ])SerealizationManager.Deserealize(array);

                for (int i = 0; i < tmp_ArrangementFigures.GetLength(0); i++)
                {
                    for (int j = 0; j < tmp_ArrangementFigures.GetLength(1); j++)
                    {
                        if (tmp_ArrangementFigures[i, j] == requestHalfStep.ArrangementFigures[i, j])
                        {
                            procent += oneProcent;
                        }
                    }
                }
                ListItemAssessment.Add(new MementoItemAssessment(indexRow, procent));
            }

            ListItemAssessment.Sort((a, b) => a.procent.CompareTo(b.procent));
            ListItemAssessment.Reverse();
            foreach (var item in ListItemAssessment)
            {
                byte[] array = (byte[])table.Rows[item.indexRow]["ArrangementFigures"];
                tmp_ArrangementFigures = (byte[, ])SerealizationManager.Deserealize(array);
                array = (byte[])table.Rows[item.indexRow]["Position"];
                PointV2 pos = (PointV2)SerealizationManager.Deserealize(array);
                array = (byte[])table.Rows[item.indexRow]["Direction"];
                PointV2 dir = (PointV2)SerealizationManager.Deserealize(array);
                if (requestHalfStep.ArrangementFigures[pos.x, pos.y] == tmp_ArrangementFigures[pos.x, pos.y])
                {
                    return(new ChosenStep(pos, dir));
                }
            }
            throw new System.ArgumentException("На данный момент в базе нет подходящих значений");
        }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (point == null)
        {
            point = target as PointV2;
        }

        if (GUILayout.Button("Create New Point"))
        {
            createPoint();
        }

        if (Selection.gameObjects.Length == 2)
        {
            if (GUILayout.Button("Connect Selected Points with Path"))
            {
                createPath();
            }
        }
    }
Exemplo n.º 4
0
 public Queen(CellStatus side, PointV2 position) : base(side, position)
 {
 }
Exemplo n.º 5
0
 public Bishop(CellStatus side, PointV2 position) : base(side, position)
 {
 }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        PointV2    p = new PointV2(1, 1);
        GameObject tmp;
        bool       istest = true;

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                tmp = GameObject.Instantiate(cellObj, new Vector2((float)p.x, (float)p.y), Quaternion.identity) as GameObject;
                tmp.GetComponent <TestCell>().position = p;
                CellsObjList[i, j] = tmp;
                if (istest)
                {
                    if (j % 2 != 0)
                    {
                        CellsObjList[i, j].renderer.material.color = Color.white;
                    }

                    else
                    {
                        CellsObjList[i, j].renderer.material.color = Color.black;
                    }
                }
                else if (!istest)
                {
                    if (j % 2 != 0)
                    {
                        CellsObjList[i, j].renderer.material.color = Color.black;
                    }

                    else
                    {
                        Debug.Log("false, i % 2 == 0");
                        CellsObjList[i, j].renderer.material.color = Color.white;
                    }
                }



                p += PointV2.right;
            }
            istest = !istest;
            p      = new PointV2(1, p.y + 1);
        }

        // test(new Queen(CellStatus.Player1, new PointV2(1, 1)));

        Figure f1 = new Queen(CellStatus.Player1, new PointV2(1, 1));

        Figure f2 = new Queen(CellStatus.Player2, new PointV2(4, 4));


        GameBoard.Instance.Figures.Add(f1); GameBoard.Instance.Figures.Add(f2);
        f2.DeathEvent += f2_DeathEvent;
        test(f1);
        f1.Walk(new PointV2(4, 4));

        /// test new alhoritm diagonales =============
    }
Exemplo n.º 7
0
 public float DistanceFromStartAStar(PointV2 endPoint)
 {
     return(DistanceFromStart + Vector3.Distance(transform.position, endPoint.transform.position));
 }
Exemplo n.º 8
0
        PointV2 randPoint()
        {
            PointV2 p = new PointV2(rnd.Next(0, 7), rnd.Next(0, 7));

            return(p);
        }