Exemplo n.º 1
0
    void SeekPawn(pawn target)
    {
        agent.SetDestination(target.tf.position);
        Vector3 desiredVelocity = agent.desiredVelocity;

        //desiredVelocity=Vector3.ClampMagnitude
        desiredVelocity = pawn.tf.InverseTransformDirection(desiredVelocity);
        pawn.Move(new Vector2(desiredVelocity.x, desiredVelocity.z));
        //desiredVelocity = tf.InverseTransformDirection (desiredVelocity);
        anim.SetFloat("Horizontal", desiredVelocity.x);
        anim.SetFloat("Vertical", desiredVelocity.z);
    }
Exemplo n.º 2
0
 public void TakeDamage(float amountOfDamage, pawn source, pawn instigator)
 {
     health -= amountOfDamage;
     if (health < 0)
     {
         Die();
     }
     if (health > maxHealth)
     {
         health = maxHealth;
     }
 }
Exemplo n.º 3
0
 public void reset()
 {
     for (int i = 0; i < pawns.Length; i++)
     {
         pawn pw = pawns[i].GetComponent <pawn> ();
         pawns [i].transform.position = pw.initial;
         pw.reset();
         name     = null;
         playerID = 0;
         human    = false;
         for (int j = 0; j < pawnActive.Length; j++)
         {
             pawnActive[j] = false;
         }
     }
 }
Exemplo n.º 4
0
    //runs when pickup
    public override void OnPickup(GameObject target)
    {
        Health tempHealth = target.GetComponent <Health> ();

        if (tempHealth != null)
        {
            //tempHealth.TakeDamage (-healAmount);
        }

        pawn tempPawn = target.GetComponent <pawn> ();

        if (tempPawn != null)
        {
            //run the parent version
            base.OnPickup(target);
        }
    }
Exemplo n.º 5
0
 public void killPawns(Player[] player, int currentID)
 {
     for (int j = 0; j < player.Length; j++)
     {
         if (j != currentID)
         {
             GameObject[] p = player [j].pawns;
             for (int i = 0; i < p.Length; i++)
             {
                 pawn pwn = p [i].GetComponent <pawn> ();
                 if (pwn.distance < 56)
                 {
                     if (pwn.currentNode == selectedPawn.GetComponent <pawn> ().currentNode)
                     {
                         pwn.reset();
                         p[i].transform.position   = pwn.initial;
                         player [j].pawnActive [i] = false;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 TryAddMutationThought(pawn, mutation.mutationMemory);
Exemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     agent = GetComponent <NavMeshAgent> ();
     pawn  = GetComponent <pawn> ();
     anim  = GetComponent <Animator> ();
 }
Exemplo n.º 8
0
    /// <summary>
    /// вызывается если активны уже 2 фигуры и проверяется что с ними делать
    /// </summary>
    /// <param name="name"> Имя фигуры </param>
    /// <param name="color"> Цвет фигуры </param>
    public void isMoveCanBe(string name, int color)
    {
        if (State == 0)
        {
            if (name == "pawn")
            {
                // Debug.Log("nameCorrect");
                if (color == 0)
                {
                    //  Debug.Log("colorCorrect");
                    pawn pn = new pawn();
                    if (board[z, x].first_move == false)
                    {
                        pn.first_move = false;
                    }

                    pn.PossibleMoves(z, x);

                    for (int i = 0; i < pn.P_Moves.Count; i++)
                    {
                        if (pn.P_Moves[i].z == second_z & pn.P_Moves[i].x == second_x)
                        {
                            board[z, x].first_move = false;
                            MoveFigure();
                        }
                    }
                }
                else // color == 1
                {
                    pawn pn = new pawn();
                    pn.PossibleMoves(z, x);

                    for (int i = 0; i < pn.Attack_Moves.Count; i++)
                    {
                        if (pn.Attack_Moves[i].z == second_z & pn.Attack_Moves[i].x == second_x)
                        {
                            AttackFigure();
                        }
                    }
                }
            }


            if (name == "queen")
            {
                // Debug.Log("nameCorrect");


                //  Debug.Log("colorCorrect");
                queen q = new queen();

                q.PossibleMoves(z, x);

                for (int i = 0; i < q.P_Moves_Up.Count; i++)
                {
                    if (q.P_Moves_Up[i].z == second_z & q.P_Moves_Up[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_Down.Count; i++)
                {
                    if (q.P_Moves_Down[i].z == second_z & q.P_Moves_Down[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_Left.Count; i++)
                {
                    if (q.P_Moves_Left[i].z == second_z & q.P_Moves_Left[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_Right.Count; i++)
                {
                    if (q.P_Moves_Right[i].z == second_z & q.P_Moves_Right[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_LeftUp.Count; i++)
                {
                    if (q.P_Moves_LeftUp[i].z == second_z & q.P_Moves_LeftUp[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_RightUp.Count; i++)
                {
                    if (q.P_Moves_RightUp[i].z == second_z & q.P_Moves_RightUp[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }


                for (int i = 0; i < q.P_Moves_RightDown.Count; i++)
                {
                    if (q.P_Moves_RightDown[i].z == second_z & q.P_Moves_RightDown[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_LeftDown.Count; i++)
                {
                    if (q.P_Moves_LeftDown[i].z == second_z & q.P_Moves_LeftDown[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }
            }

            if (name == "king")
            {
                king k = new king();

                k.PossibleMoves(z, x);

                for (int i = 0; i < k.P_Moves.Count; i++)
                {
                    if (k.P_Moves[i].z == second_z & k.P_Moves[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < k.P_Moves_r.Count; i++)
                {
                    if (k.P_Moves_r[i].z == second_z & k.P_Moves_r[i].x == second_x)
                    {
                        RokirovkaMove();
                        MoveFigure();
                    }
                }
            }


            if (name == "rook")
            {
                rook rk = new rook();

                rk.PossibleMoves(z, x);

                for (int i = 0; i < rk.P_Moves_Up.Count; i++)
                {
                    if (rk.P_Moves_Up[i].z == second_z & rk.P_Moves_Up[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < rk.P_Moves_Down.Count; i++)
                {
                    if (rk.P_Moves_Down[i].z == second_z & rk.P_Moves_Down[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < rk.P_Moves_Left.Count; i++)
                {
                    if (rk.P_Moves_Left[i].z == second_z & rk.P_Moves_Left[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < rk.P_Moves_Right.Count; i++)
                {
                    if (rk.P_Moves_Right[i].z == second_z & rk.P_Moves_Right[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }
            }


            if (name == "bishop")
            {
                bishop q = new bishop();

                q.PossibleMoves(z, x);

                for (int i = 0; i < q.P_Moves_LeftUp.Count; i++)
                {
                    if (q.P_Moves_LeftUp[i].z == second_z & q.P_Moves_LeftUp[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_RightUp.Count; i++)
                {
                    if (q.P_Moves_RightUp[i].z == second_z & q.P_Moves_RightUp[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }


                for (int i = 0; i < q.P_Moves_RightDown.Count; i++)
                {
                    if (q.P_Moves_RightDown[i].z == second_z & q.P_Moves_RightDown[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }

                for (int i = 0; i < q.P_Moves_LeftDown.Count; i++)
                {
                    if (q.P_Moves_LeftDown[i].z == second_z & q.P_Moves_LeftDown[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            MoveFigure();
                        }
                        else
                        {
                            AttackFigure();
                        }
                    }
                }
            }


            if (name == "knight")
            {
                knight q = new knight();

                q.PossibleMoves(z, x);

                for (int i = 0; i < q.P_Moves.Count; i++)
                {
                    if (q.P_Moves[i].z == second_z & q.P_Moves[i].x == second_x)
                    {
                        if (color == 0)
                        {
                            if (color == 0)
                            {
                                MoveFigure();
                            }
                            else
                            {
                                AttackFigure();
                            }
                        }
                        else
                        {
                            if (color == 0)
                            {
                                MoveFigure();
                            }
                            else
                            {
                                AttackFigure();
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// заполняем доску
    /// </summary>
    void filing_table()
    {
        for (int i = 0; i < 8; i++) // заполнение всей доски пустыми значениями
        {
            for (int j = 0; j < 8; j++)
            {
                empty emp = new empty();
                emp.figure_name = emp.name;
                board[i, j]     = emp;
            }
        }

        for (int i = 0; i < 8; i++) // заполнение первой строки белыми пешками
        {
            pawn pn = new pawn();
            pn.colors_of_figure = 0;
            pn.figure_name      = pn.name;
            pn.direction        = false;
            board[1, i]         = pn;
        }


        rook rk = new rook();

        rk.colors_of_figure = 0;    // белые ладьи
        rk.figure_name      = rk.name;
        board[0, 0]         = rk;
        board[0, 7]         = rk;


        rook rk_black = new rook();

        rk_black.colors_of_figure = 1;    // чёрные ладьи
        rk_black.figure_name      = rk_black.name;
        board[7, 0] = rk_black;
        board[7, 7] = rk_black;



        knight kn = new knight();

        kn.colors_of_figure = 0;    // белые кони
        kn.figure_name      = kn.name;
        board[0, 1]         = kn;
        board[0, 6]         = kn;

        knight kn_black = new knight();

        kn_black.colors_of_figure = 1;    // черные кони
        kn_black.figure_name      = kn_black.name;
        board[7, 1] = kn_black;
        board[7, 6] = kn_black;



        bishop bs = new bishop();

        bs.colors_of_figure = 0;    // белые слоны
        bs.figure_name      = bs.name;
        board[0, 2]         = bs;
        board[0, 5]         = bs;

        bishop bs_black = new bishop();

        bs_black.colors_of_figure = 1;    // черные слоны
        bs_black.figure_name      = bs_black.name;
        board[7, 2] = bs_black;
        board[7, 5] = bs_black;

        queen q = new queen();   // белая королева

        q.colors_of_figure = 0;
        q.figure_name      = q.name;
        board[0, 3]        = q;

        queen q_black = new queen();     // черная королева

        q_black.colors_of_figure = 1;
        q_black.figure_name      = q_black.name;
        board[7, 3] = q_black;

        king kg = new king();

        kg.colors_of_figure = 0;    // белый король
        kg.figure_name      = kg.name;
        board[0, 4]         = kg;

        king kg_black = new king();

        kg_black.colors_of_figure = 1;    // черный король
        kg_black.figure_name      = kg_black.name;
        board[7, 4] = kg_black;


        for (int i = 0; i < 8; i++) // заполнение 7ой строки черными пешками
        {
            pawn pn = new pawn();
            pn.colors_of_figure = 1;
            pn.figure_name      = pn.name;
            pn.direction        = true;
            board[6, i]         = pn;
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// Сборка всех ходов
    /// </summary>
    public void checkForMovement()      // собирает все возможные ходы
    {
        Core scriptToAccess = Core_object.GetComponent <Core>();

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (scriptToAccess.board[i, j].figure_name == "bishop")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        bishop b = new bishop();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            Debug.Log("bishops");

                            All_mv.Add(b.All_moves[x]);
                        }
                    }
                    else // иначе мы смотрим ход для игрока
                    {
                        bishop b = new bishop();
                        b.colors_of_figure = 0;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            //    Debug.Log("bishops");

                            //       P_All_mv.Add(b.All_moves[x]);
                        }
                    }
                }

                if (scriptToAccess.board[i, j].figure_name == "king")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        king b = new king();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            Debug.Log("king");

                            All_mv.Add(b.P_Moves[x]);
                        }
                    }
                    else // иначе мы смотрим ход для игрока
                    {
                        king b = new king();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            //        P_All_mv.Add(b.P_Moves[x]);
                        }
                    }
                }

                if (scriptToAccess.board[i, j].figure_name == "knight")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        knight b = new knight();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            Debug.Log("knight");
                            Debug.Log(b.P_Moves[x].z);
                            Debug.Log(b.P_Moves[x].x);

                            All_mv.Add(b.P_Moves[x]);

                            //  Debug.Log(All_mv.Count);
                            //  Debug.Log(scriptToAccess.board[0, 6].colors_of_figure);
                        }
                    }
                    else
                    {
                        knight b = new knight();
                        b.colors_of_figure = 0;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            //       Debug.Log("knight");
                            //         P_All_mv.Add(b.P_Moves[x]);
                            //     //  Debug.Log(scriptToAccess.board[0, 6].colors_of_figure);
                        }
                    }
                }

                if (scriptToAccess.board[i, j].figure_name == "pawn")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        pawn b = new pawn();
                        b.colors_of_figure = 1;
                        b.PossibleMovesAI(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            Debug.Log("pawn");
                            All_mv.Add(b.P_Moves[x]);
                        }

                        for (int x = 0; x < b.Attack_Moves.Count; x++)
                        {
                            Debug.Log("pawn");
                            All_mv.Add(b.Attack_Moves[x]);
                        }
                    }
                    else
                    {
                        pawn b = new pawn();
                        b.colors_of_figure = 0;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.P_Moves.Count; x++)
                        {
                            //    P_All_mv.Add(b.P_Moves[x]);
                        }

                        for (int x = 0; x < b.Attack_Moves.Count; x++)
                        {
                            //     P_All_mv.Add(b.Attack_Moves[x]);
                        }
                    }
                }

                if (scriptToAccess.board[i, j].figure_name == "queen")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        queen b = new queen();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            Debug.Log("queen");

                            All_mv.Add(b.All_moves[x]);
                        }
                    }
                    else // иначе мы смотрим ход для игрока
                    {
                        queen b = new queen();
                        b.colors_of_figure = 0;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            //       Debug.Log("queen");

                            //    P_All_mv.Add(b.All_moves[x]);
                        }
                    }
                }


                if (scriptToAccess.board[i, j].figure_name == "rook")
                {
                    if (scriptToAccess.board[i, j].colors_of_figure == 1)
                    {
                        rook b = new rook();
                        b.colors_of_figure = 1;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            Debug.Log("rook");

                            All_mv.Add(b.All_moves[x]);
                        }
                    }
                    else // иначе мы смотрим ход для игрока
                    {
                        rook b = new rook();
                        b.colors_of_figure = 0;
                        b.PossibleMoves(i, j);
                        for (int x = 0; x < b.All_moves.Count; x++)
                        {
                            //       Debug.Log("rook");

                            //   P_All_mv.Add(b.All_moves[x]);
                        }
                    }
                }
            }
        }
    }