Пример #1
0
        //---------------------------------------------------------------------
        // Cell->Cell的请求
        async Task ICellPlayer.s2sBotEnterWorld(string player_etguid)
        {
            NewPlayerInfo new_player_info = new NewPlayerInfo();

            new_player_info.account_id     = "";
            new_player_info.account_name   = "";
            new_player_info.gender         = true;
            new_player_info.is_bot         = true;
            new_player_info.et_player_guid = player_etguid;

            var grain = GF.GetGrain <ICellPlayer>(new Guid(player_etguid));
            await grain.c2sEnterWorld(new_player_info);
        }
Пример #2
0
        //---------------------------------------------------------------------
        // Client->Cell的请求
        async Task <EntityData> ICellPlayer.c2sEnterWorld(NewPlayerInfo new_player_info)
        {
            Logger.Info("c2sEnterWorld() GrainId={0}", this.GetPrimaryKey().ToString());

            // 新建角色
            if (EtPlayer == null)
            {
                if (AsyncStream == null)
                {
                    IStreamProvider stream_provider = GetStreamProvider(StringDef.SMSProvider);
                    AsyncStream = stream_provider.GetStream <StreamData>(this.GetPrimaryKey(), "Friend");
                }

                bool  exist     = true;
                ulong player_id = 100;
                //do
                //{
                //    player_id = (ulong)CellApp.Instance.Rd.next(1000000, 9999999);
                //    var grain_playerservice = GF.GetGrain<ICellPlayerService>(0);
                //    exist = await grain_playerservice.playerIdExist(player_id);
                //} while (exist);

                EbLog.Note("-------------------------------");
                EbLog.Note("新创建玩家");
                EbLog.Note("AccountName=" + new_player_info.account_name);
                EbLog.Note("PlayerId=" + player_id);
                EbLog.Note("-------------------------------");

                var et_player_data = new EntityData();
                et_player_data.entity_type                 = typeof(EtPlayer).Name;
                et_player_data.entity_guid                 = new_player_info.et_player_guid;
                et_player_data.list_component              = new List <ComponentData>();
                et_player_data.cache_data                  = new Dictionary <string, object>();
                et_player_data.cache_data["NewPlayer"]     = true;
                et_player_data.cache_data["NewPlayerInfo"] = new_player_info;
                et_player_data.cache_data["NewPlayerId"]   = player_id;
                EtPlayer = EntityMgr.Instance.genEntity <EtPlayer, GrainCellPlayer>(et_player_data, this);
                State    = EtPlayer.genEntityData4SaveDb();
                await WriteStateAsync();
            }

            return(EtPlayer.genEntityData4NetSync((byte)NodeType.Client));
        }