コード例 #1
0
    public IEnumerator Movement(GameObject TileInMove, bool start)
    {
        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;

        if (start && PhotonNetwork.LocalPlayer == PhotonNetwork.MasterClient)
        {
            classMatch.ChangeTurn();
        }
    }
コード例 #2
0
    public IEnumerator Move(GameObject ficha, int a, float mov)
    {
        FichaDosJugadoresOnline tile = ficha.GetComponent <FichaDosJugadoresOnline>();

        if (classMatch.PlayerInTurn == 1 && PhotonNetwork.LocalPlayer == PhotonNetwork.MasterClient ||
            classMatch.PlayerInTurn == 2 && PhotonNetwork.LocalPlayer != PhotonNetwork.MasterClient)

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

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

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

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

            var angles = ficha.transform.rotation.eulerAngles;
            angles.y = a;
            angles.x = 90;
            ficha.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(ficha);
                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(ficha, a));
                yield break;
            }

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

                tile.nocollider = true;

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

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

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

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

            yield return(new WaitForSeconds(1f));

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