Пример #1
0
    public IEnumerator Movement(GameObject TileInMove, bool start)
    {
        int player = currentTile.GetComponent <FichaVariosJugadoresOnline>().player;

        for (int i = 0; i < 3; i++)
        {
            if (classMatch.classPanels.panelsObjects[i].GetComponent <PanelPlayers>().posPlayer == player)
            {
                TileInMove.transform.position = classMatch.classPanels.panelsObjects[i].GetComponent <PanelPlayers>().bankTile.transform.position;
                classMatch.classPanels.panelsObjects[i].GetComponent <PanelPlayers>().ChangeCountTiles();
            }
        }

        float normalizedTime = 0.0f;

        classMatch.classGeneral.putTile.Play();

        while (normalizedTime < 1)
        {
            TileInMove.transform.position = Vector3.Lerp(TileInMove.transform.position, pos, normalizedTime);
            normalizedTime += Time.deltaTime / 1;
            yield return(null);
        }

        TileInMove.transform.position = pos;

        yield return(new WaitForSeconds(1f));

        classMatch.noPlay    = false;
        classMatch.countPase = 0;

        if (PhotonNetwork.LocalPlayer == PhotonNetwork.MasterClient && start) // Primera jugada
        {
            if (player == 1)
            {
                classMatch.countTilesPlayer1--;
            }
            if (player == 2)
            {
                classMatch.countTilesPlayer2--;
            }
            if (player == 3)
            {
                classMatch.countTilesPlayer3--;
            }
            if (player == 4)
            {
                classMatch.countTilesPlayer4--;
            }

            classMatch.ChangeTurn();
        }
    }
Пример #2
0
    public IEnumerator Move(GameObject nextTile, int a, float mov)
    {
        if (classMatch.PlayerInTurn == MatchDates.Instance.myPos + 1)

        {
            FichaVariosJugadoresOnline tile = nextTile.GetComponent <FichaVariosJugadoresOnline>();

            classMetodosOthers.PV.RPC("RPC_Move", RpcTarget.Others, tile.pointUp, tile.pointDown, pointUp, pointDown, a, mov, colliderWall1, colliderWall2);

            classMatch.CountTile(nextTile);

            if (a == 180)
            {
                tile.inverse = true;
            }

            tile.onTable         = true;
            classMatch.countPase = 0;

            nextTile.transform.SetParent(classMatch.table.transform);
            nextTile.transform.localScale = new Vector3(0.7f, 0.7f, 1);

            var angles = nextTile.transform.rotation.eulerAngles;
            angles.y = a;
            angles.x = 90;
            nextTile.transform.rotation = Quaternion.Euler(angles);

            pos = new Vector3(transform.position.x, transform.position.y, transform.position.z + mov);

            if (colliderWall1 && nocollider == false || colliderWall2 && nocollider == false)
            {
                tile.nocollider = true;
                tile.moved      = true;

                if (colliderWall1)
                {
                    tile.colliderWall1 = true;
                }
                if (colliderWall2)
                {
                    tile.colliderWall2 = true;
                }

                MovedTile(nextTile);
                yield break;
            }

            if (moved)
            {
                if (colliderWall1)
                {
                    tile.colliderWall1 = true;
                }
                if (colliderWall2)
                {
                    tile.colliderWall2 = true;
                }

                tile.nocollider = true;

                if (tile.doble)
                {
                    tile.movedDoble = true;
                }

                StartCoroutine(TurnTile(nextTile, a));
                yield break;
            }

            if (movedDoble)
            {
                if (colliderWall1)
                {
                    tile.colliderWall1 = true;
                }
                if (colliderWall2)
                {
                    tile.colliderWall2 = true;
                }

                tile.nocollider = true;

                StartCoroutine(MoveDoble(nextTile, a));
                yield break;
            }

            float normalizedTime = 0.0f;
            classMatch.classGeneral.putTile.Play();

            while (normalizedTime < 1)
            {
                nextTile.transform.position = Vector3.Lerp(nextTile.transform.position, pos, normalizedTime);
                normalizedTime += Time.deltaTime / duration;
                yield return(null);
            }

            nextTile.transform.position = pos;
            classMatch.ChangeTilesToNormal();

            yield return(new WaitForSeconds(1f));

            classMatch.noPlay = false;
            MatchDates.Instance.selectedFicha = null;
            classMatch.ValidateEnd();
            classMatch.ChangeTurn();
        }
    }