Пример #1
0
    public void RecveviceBuyCharacter(SyncSession session, PlayerBuyCharacter_s msg)
    {
        for (int i = 0; i < session.player.OwnCharacter.Count; i++)
        {
            if (session.player.OwnCharacter[i] == msg.characterID)
            {
                PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
                result.code = ServiceErrorCode.c_HasOwnCharacter;

                ProtocolAnalysisService.SendMsg(session, result);
                return;
            }
        }
        ShopDataGenerate data = DataGenerateManager <ShopDataGenerate> .GetData(msg.characterID);

        if (data.m_cost <= session.player.Diamond)
        {
            session.player.Diamond -= (int)data.m_cost;
            session.player.OwnCharacter.Add(data.m_item_id.ToString());

            PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
            result.code = ServiceErrorCode.c_Success;

            ProtocolAnalysisService.SendMsg(session, result);
        }
        else
        {
            PlayerBuyCharacter_c result = new PlayerBuyCharacter_c();
            result.code = ServiceErrorCode.c_NotEnoughDiamond;

            ProtocolAnalysisService.SendMsg(session, result);
        }
    }
Пример #2
0
    static void SendPlayerBuyCharacter_c(SyncSession session, PlayerBuyCharacter_c msg)
    {
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("code", msg.code);
        session.SendMsg("playerbuycharacter", data);
    }