Ejemplo n.º 1
0
    public void OnGameNotifyPlayerGameSceneInfo(byte[] pBuf)
    {
        GameProto.GameNotifyPlayerGameSceneInfo oRet = GameProto.GameNotifyPlayerGameSceneInfo.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("OnGameNotifyPlayerGameSceneInfo error parse");
            return;
        }

        SampleDebuger.LogBlue("game scene state : " + oRet.State.ToString());

        for (int i = 0; i < oRet.Players.Count; i++)
        {
            if (oRet.Players[i].QwPlayerId != 0)
            {
                SampleDebuger.LogBlue(string.Format("game scene info : [{0}, {1}, {2}, {3}]",
                                                    oRet.Players[i].QwPlayerId.ToString(), oRet.Players[i].SzNickName, oRet.Players[i].SzAvatar, oRet.Players[i].DwSex.ToString()));

                GameData.Instance().SetSlotId((uint)i, oRet.Players[i].QwPlayerId);
                GameData.Instance().SetRoleDate(oRet.Players[i].QwPlayerId, oRet.Players[i]);

                TetrisDataManager.Instance().SetPlayer(oRet.Players[i].QwPlayerId);
            }
        }

        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != SysUtil.GetScesneNameBySceneState(oRet.State))
        {
            AssetBundleLoader.Instance().LoadLevelAsset(SysUtil.GetScesneNameBySceneState(oRet.State), delegate()
            {
                SampleDebuger.LogBlue("scene info load level : " + SysUtil.GetScesneNameBySceneState(oRet.State));
            }
                                                        );
        }
    }
Ejemplo n.º 2
0
 public void RightRotation()
 {
     if (TetrisData.proState != GameProto.EGameSceneState.EssGaming)
     {
         return;
     }
     TetrisDataManager.Instance().proUserTetrisData.TetrisOperator(GameProto.ERotationDirection.ErdRight);
 }
Ejemplo n.º 3
0
 public void LeftTetris()
 {
     if (TetrisData.proState != GameProto.EGameSceneState.EssGaming)
     {
         return;
     }
     TetrisDataManager.Instance().proUserTetrisData.TetrisOperator(GameProto.EMoveDirection.EmdLeft);
 }
Ejemplo n.º 4
0
    public void OnGameAckPlayerEnter(byte[] pBuf)
    {
        GameProto.GameAckPlayerEnter oRet = GameProto.GameAckPlayerEnter.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("OnGameAckPlayerEnter error parse");
            return;
        }
        SampleDebuger.Log("game enter : " + oRet.DwResult.ToString());

        TetrisDataManager.Instance().SetOwner(PlayerData.Instance().proPlayerId);
    }
Ejemplo n.º 5
0
    public void OnGameNotifyPlayerNextTetris(byte[] pBuf)
    {
        GameProto.GameNotifyPlayerNextTetris oRet = GameProto.GameNotifyPlayerNextTetris.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("GameNotifyPlayerNextTetris error parse");
            return;
        }
        TetrisData pTetrisData = TetrisDataManager.Instance().GetTetrisData(oRet.DwPlayerId);

        if (pTetrisData == null)
        {
            SampleDebuger.LogYellow("can't find tetris data player id : " + oRet.DwPlayerId.ToString());
            return;
        }
        pTetrisData.Sync(oRet);
    }
Ejemplo n.º 6
0
    public void OnGameNotifyPlayeRotation(byte[] pBuf)
    {
        GameProto.GameNotifyPlayeRotation oRet = GameProto.GameNotifyPlayeRotation.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("GameNotifyPlayeRotation error parse");
            return;
        }

        TetrisData pTetrisData = TetrisDataManager.Instance().GetTetrisData(oRet.DwPlayerId);

        if (pTetrisData == null)
        {
            SampleDebuger.LogYellow("can't find tetris data player id : " + oRet.DwPlayerId.ToString());
            return;
        }

        if (!pTetrisData.TetrisOperator(oRet.EDirection))
        {
            SampleDebuger.LogYellow("error rotation : " + oRet.EDirection.ToString());
        }
        SampleDebuger.LogBlue(string.Format("player : {0} rot dir {1}", oRet.DwPlayerId.ToString(), oRet.EDirection.ToString()));
    }
Ejemplo n.º 7
0
 public void ShowPlayer()
 {
     GameLogic.Instance().SetTetrisData(TetrisDataManager.Instance().GetTetrisData(proPlayerId), proPlayerId);
 }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (TetrisData.proState != GameProto.EGameSceneState.EssGaming)
        {
            return;
        }
        if (m_oData == null)
        {
            return;
        }

#if UNITY_STANDALONE_WIN || UNITY_EDITOR
        if (Input.GetKey(KeyCode.S))
        {
            SampleDebuger.Log("您按下了S键");
            DownTetris();
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            SampleDebuger.Log("您按下了A键");
            LeftTetris();
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            SampleDebuger.Log("您按下了D键");
            RightTetris();
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            SampleDebuger.Log("您按下了H键");
            LeftRotation();
        }

        if (Input.GetKeyDown(KeyCode.J))
        {
            SampleDebuger.Log("您按下了J键");
            RightRotation();
        }
#endif

        TetrisDataManager.Instance().proUserTetrisData.Update(Time.deltaTime);

        uint[,] dwBlockInfos = m_oData.GetTetrisInfo();
        if (dwBlockInfos == null)
        {
            return;
        }

        //刷新显示的方块
        Color32 c = new Color32(255, 255, 255, 35);
        for (int i = 0; i < TetrisData.s_dwRow; i++)
        {
            for (int j = 0; j < TetrisData.s_dwColumn; j++)
            {
                uint dwBlock = dwBlockInfos[i, j];
                if (dwBlock != 0)
                {
                    c.r = (byte)((dwBlock & 0xFF000000) >> 24);
                    c.g = (byte)((dwBlock & 0x00FF0000) >> 16);
                    c.b = (byte)((dwBlock & 0x0000FF00) >> 8);
                    c.a = 100;
                }
                else
                {
                    c.r = 255;
                    c.g = 255;
                    c.b = 255;
                    c.a = 35;
                }
                m_arrBlockInfos[i, j].color = c;
            }
        }

        if (m_oData.m_oNextTetris != null)
        {
            for (int i = 0; i < TetrisData.s_dwUnit; ++i)
            {
                for (int j = 0; j < TetrisData.s_dwUnit; ++j)
                {
                    uint dwBlockInfo = TetrisData.s_dwTetrisTable[m_oData.m_oNextTetris.m_dwTetrisShape, m_oData.m_oNextTetris.m_dwTetrisDirect, i, j];
                    if (dwBlockInfo != 0)
                    {
                        c.r = (byte)((m_oData.m_oNextTetris.m_dwTetrisColor & 0xFF000000) >> 24);
                        c.g = (byte)((m_oData.m_oNextTetris.m_dwTetrisColor & 0x00FF0000) >> 16);
                        c.b = (byte)((m_oData.m_oNextTetris.m_dwTetrisColor & 0x0000FF00) >> 8);
                        c.a = 100;
                    }
                    else
                    {
                        c.r = 255;
                        c.g = 255;
                        c.b = 255;
                        c.a = 35;
                    }
                    m_arrNextBlocks[i * TetrisData.s_dwUnit + j].color = c;
                }
            }
        }
    }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     m_oData = TetrisDataManager.Instance().proUserTetrisData;
 }