コード例 #1
0
ファイル: PVPPanel.cs プロジェクト: 37Sir/WarChess
    public void OpenView(object intent)
    {
        int firstId = m_pvpProxy.GetFirstId();
        int userId  = m_proxy.GetPlayerId();

        if (firstId == userId)
        {
            isTurn    = true;
            selfColor = Config.PieceColor.WHITE;
        }
        else
        {
            isTurn    = false;
            selfColor = Config.PieceColor.BLACK;
            m_globalLight.transform.localRotation = Quaternion.Euler(145, 30, 0);
        }
        m_pvpProxy.SetSelfColor(selfColor);
        m_userImage.GetComponentInChildren <Text>().text  = m_proxy.GetPlayerName();
        m_enemyImage.GetComponentInChildren <Text>().text = m_pvpProxy.GetEnemyName();
        InitTimer();
        App.SoundManager.PlaySoundClip(Config.Sound.InGameStart);
        var fixedK = App.EffectManager.ScreenFixedK;

        m_worldCamera.fieldOfView = m_worldCamera.fieldOfView * fixedK;
    }
コード例 #2
0
ファイル: PieceItem02.cs プロジェクト: 37Sir/WarChess
    /// <summary>
    /// 拖动结束
    /// </summary>
    public void OnDragEnd()
    {
        if (canMove == false || m_type == Config.PieceType.K)
        {
            return;
        }
        m_isTipsShow = false;
        var     px     = m_target.transform.position.x - m_beginPos.x;
        var     pz     = m_target.transform.position.z - m_beginPos.z;
        var     d      = Math.Sqrt(px * px + pz * pz);
        var     dx     = Math.Abs(px);
        var     dz     = Math.Abs(pz);
        int     xblock = (int)Math.Round(dx / Config.PieceWidth, 0);
        int     zblock = (int)Math.Round(dz / Config.PieceWidth, 0);
        var     dir    = GetDirectByDeltaXZ(px, pz);
        Vector2 to     = new Vector2(m_X + xblock * dir.x, m_Z + zblock * dir.y);

        if (d >= Config.MoveDistance && to.x <= 8 && to.x >= 1 && to.y >= 1 && to.y <= 8)//todo 不能直接套用
        {
            var tempEat = App.ChessLogic02.GetPiece(to.x - 1, to.y - 1);
            m_body = new object[] { m_X, m_Z, m_mediator.pieceData.color, to, tempEat };
            if (App.ChessLogic02.DoMove(new Vector2(m_X - 1, m_Z - 1), new Vector2(to.x - 1, to.y - 1)))
            {
                var piece     = App.ChessLogic02.GetPiece((int)to.x - 1, (int)to.y - 1);//移动后的棋子
                var indexFrom = CoorToIndex((int)m_X, (int)m_Z);
                var indexTo   = CoorToIndex((int)to.x, (int)to.y);

                ActiveInfo.Builder activeInfo = ActiveInfo.CreateBuilder();
                MoveInfo.Builder   moveInfo   = MoveInfo.CreateBuilder();
                moveInfo.SetFrom(indexFrom);
                moveInfo.SetTo(indexTo);
                moveInfo.SetUserId(m_UserProxy.GetPlayerId());
                activeInfo.SetIsCall(false);
                activeInfo.SetMoveInfo(moveInfo);
                m_mediator.NotityDragEnd(activeInfo);
                object[] args = new object[] { new Vector2(m_X, m_Z), to, new Vector2(-1, tempEat) };//0:from, 1:to, 2.x:兵生变类型 -1为没有, 2.y:吃棋信息
                ShowMove(args);
                StopFlash();
                App.SoundManager.PlaySoundClip(Config.Sound.DragSuccess);
            }
            else
            {
                SetPiecePos(m_X, m_Z);
                m_mediator.NotityDragEnd(null);//不能移动
                App.SoundManager.PlaySoundClip(Config.Sound.DragFail);
            }
        }
        else
        {
            SetPiecePos(m_X, m_Z);
            m_mediator.NotityDragEnd(null);//距离不够 驳回
        }
        m_target.SetActive(false);
    }
コード例 #3
0
ファイル: PVEPanel.cs プロジェクト: 37Sir/WarChess
    public void OpenView(object intent)
    {
        int userId = m_proxy.GetPlayerId();

        isTurn = true;
        m_pveProxy.SetSelfColor(Config.PieceColor.WHITE);
        m_mode = m_pveProxy.GetMode();
        m_userImage.GetComponentInChildren <Text>().text  = m_proxy.GetPlayerName();
        m_enemyImage.GetComponentInChildren <Text>().text = m_pveProxy.GetEnemyName();

        App.SoundManager.PlaySoundClip(Config.Sound.InGameStart);
        var fixedK = App.EffectManager.ScreenFixedK;

        m_worldCamera.fieldOfView = m_worldCamera.fieldOfView * fixedK;
    }
コード例 #4
0
    public void OnMatchSuccess(string name, List <byte[]> packet)
    {
        var push        = PlayerStartPush.ParseFrom(packet[0]);
        var selfId      = m_proxy.GetPlayerId();
        var playerMes1  = push.GetPlayerMes(0);
        var playerMes2  = push.GetPlayerMes(1);
        var firstHandId = push.UserId;

        StopMatchTimer();
        StopMatchBird();
        if (m_GameMode == Config.GameMode.PVP)
        {
            if (playerMes1.UserId == selfId)
            {
                m_pvpProxy.SetEnemyName(playerMes2.UserName);
            }
            else
            {
                m_pvpProxy.SetEnemyName(playerMes1.UserName);
            }
            m_pvpProxy.SetFirstId(firstHandId);
            App.NSceneManager.LoadScene("SGame");
        }
        else
        {
            if (playerMes1.UserId == selfId)
            {
                m_pvp02Proxy.SetEnemyName(playerMes2.UserName);
            }
            else
            {
                m_pvp02Proxy.SetEnemyName(playerMes1.UserName);
            }
            m_pvp02Proxy.SetFirstId(firstHandId);
            m_pvp02Proxy.SetTestMode(false);
            App.NSceneManager.LoadScene("SGame02");
        }

        Debug.Log("On Match Success");
    }
コード例 #5
0
ファイル: PVP02Panel.cs プロジェクト: 37Sir/WarChess
    public void OpenView(object intent)
    {
        isPause           = false;
        canNext           = true;
        m_needSendEndTurn = false;
        var rect = m_Bottom.GetComponent <RectTransform>();

        rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, rect.anchoredPosition.y - App.ScreenFixedHeight);
        m_EnergyText.text     = "0/0";
        int firstId = m_pvpProxy.GetFirstId();
        int userId  = m_proxy.GetPlayerId();

        //test
        m_isTest = m_pvpProxy.GetTestMode();
        if (m_isTest)
        {
            isTurn    = true;
            selfColor = Config.PieceColor.WHITE;
        }
        else
        {
            if (firstId == userId)
            {
                isTurn    = true;
                selfColor = Config.PieceColor.WHITE;
                App.ResourceManager.LoadResource <UnityEngine.Object>("ArtRes/Icon/CatBt", (UnityEngine.Object obj) =>
                {
                    if (obj != null)
                    {
                        var texture        = obj as Texture2D;
                        var sprite         = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                        m_userImage.sprite = sprite;
                    }
                });
                App.ResourceManager.LoadResource <UnityEngine.Object>("ArtRes/Icon/BunnyBt", (UnityEngine.Object obj) =>
                {
                    if (obj != null)
                    {
                        var texture         = obj as Texture2D;
                        var sprite          = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                        m_enemyImage.sprite = sprite;
                    }
                });
            }
            else
            {
                m_sunLight.transform.localRotation = Quaternion.Euler(145, -30, 0);
                isTurn    = false;
                selfColor = Config.PieceColor.BLACK;
                App.ResourceManager.LoadResource <UnityEngine.Object>("ArtRes/Icon/CatBt", (UnityEngine.Object obj) =>
                {
                    if (obj != null)
                    {
                        var texture         = obj as Texture2D;
                        var sprite          = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                        m_enemyImage.sprite = sprite;
                    }
                });
                App.ResourceManager.LoadResource <UnityEngine.Object>("ArtRes/Icon/BunnyBt", (UnityEngine.Object obj) =>
                {
                    if (obj != null)
                    {
                        var texture        = obj as Texture2D;
                        var sprite         = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                        m_userImage.sprite = sprite;
                    }
                });
            }
        }
        m_pvpProxy.SetSelfColor(selfColor);
        //m_userImage.GetComponentInChildren<Text>().text = m_proxy.GetPlayerName();
        m_enemyImage.GetComponentInChildren <Text>().text = m_pvpProxy.GetEnemyName();
        InitTimer();
        App.SoundManager.PlaySoundClip(Config.Sound.InGameStart);
        var fixedK = App.EffectManager.ScreenFixedK;

        m_worldCamera.fieldOfView = m_worldCamera.fieldOfView * fixedK;
    }