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 OnGameNotifyPlayeGameEnd(byte[] pBuf)
 {
     GameProto.GameNotifyPlayeGameEnd oRet = GameProto.GameNotifyPlayeGameEnd.Parser.ParseFrom(pBuf);
     if (oRet == null)
     {
         SampleDebuger.LogYellow("OnGameNotifyPlayeGameEnd error parse");
         return;
     }
     SampleDebuger.LogGreen("game end!!!!!!!!!");
 }
Ejemplo n.º 3
0
 public void OnGameNotifyPlayerDead(byte[] pBuf)
 {
     GameProto.GameNotifyPlayerDead oRet = GameProto.GameNotifyPlayerDead.Parser.ParseFrom(pBuf);
     if (oRet == null)
     {
         SampleDebuger.LogYellow("GameNotifyPlayerDead error parse");
         return;
     }
     SampleDebuger.LogGreen("player : " + oRet.DwPlayerId.ToString() + " dead");
 }
Ejemplo n.º 4
0
    public void OnGameNotifyPlayerGameConfig(byte[] pBuf)
    {
        GameProto.GameNotifyPlayerGameConfig oRet = GameProto.GameNotifyPlayerGameConfig.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("OnGameNotifyPlayerGameConfig error parse");
            return;
        }

        TetrisData.InitGameConfig(oRet);
    }
Ejemplo n.º 5
0
    public void OnGameNotifyPlayerGameReadyTime(byte[] pBuf)
    {
        GameProto.GameNotifyPlayerGameReadyTime oRet = GameProto.GameNotifyPlayerGameReadyTime.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("GameNotifyPlayerGameReadyTime error parse");
            return;
        }
        SampleDebuger.Log("game ready time left : " + oRet.DwLeftTime.ToString());

        ReadyTime.SetReadyTime(oRet.DwLeftTime);
    }
Ejemplo n.º 6
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.º 7
0
    public void OnGameNotifyPlayerGameState(byte[] pBuf)
    {
        GameProto.GameNotifyPlayerGameState oRet = GameProto.GameNotifyPlayerGameState.Parser.ParseFrom(pBuf);
        if (oRet == null)
        {
            SampleDebuger.LogYellow("OnGameNotifyPlayerGameState error parse");
            return;
        }
        SampleDebuger.LogBlue("game state : " + oRet.State.ToString());

        GameData.Instance().SetGameSceneState(oRet.State);

        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != SysUtil.GetScesneNameBySceneState(oRet.State))
        {
            AssetBundleLoader.Instance().LoadLevelAsset(SysUtil.GetScesneNameBySceneState(oRet.State), delegate()
            {
                SampleDebuger.LogBlue("game state load level : " + SysUtil.GetScesneNameBySceneState(oRet.State));
            }
                                                        );
        }

        switch (oRet.State)
        {
        case GameProto.EGameSceneState.EssNone:
            break;

        case GameProto.EGameSceneState.EssPrepare:
        case GameProto.EGameSceneState.EssGameReady:
        {
        }
        break;

        case GameProto.EGameSceneState.EssGaming:
        {
            ReadyTime.SetGameBegin();
        }
        break;

        case GameProto.EGameSceneState.EssTransact:
        {
        }
        break;

        default:
        {
            SampleDebuger.LogError("error game state : " + ((uint)(oRet.State)).ToString());
        }
        break;
        }

        TetrisData.SetGameSceneState(oRet.State);
    }
Ejemplo n.º 8
0
    public void OnPlayerRequestGameTest(byte[] pBuf)
    {
        GameProto.PlayerRequestGameTest oTest = GameProto.PlayerRequestGameTest.Parser.ParseFrom(pBuf);
        if (oTest == null)
        {
            SampleDebuger.LogYellow("OnTest error parse");
            return;
        }

        SampleDebuger.Log(oTest.SzTest.ToString());

        oTest.SzTest = String.Format("{0}, {1}, {2}, {3}, {4}, {5}",
                                     "sessionobject.cs", 106, "SessionObject::OnRecv", dw1++,
                                     ToString(), DateTime.Now.ToLocalTime().ToString());

        SysUtil.SendMessage(m_pSession, oTest, "GameProto.PlayerRequestGameTest");
    }
Ejemplo n.º 9
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.º 10
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()));
    }