Example #1
0
        protected override async void Run(Session session, C2G_EnterMap message, Action <G2C_EnterMap> reply)
        {
            G2C_EnterMap response = new G2C_EnterMap();

            try
            {
                Log.Debug(MongoHelper.ToJson(message));
                Player player = session.GetComponent <SessionPlayerComponent>().Player;
                // 在map服务器上创建战斗Unit
                string         mapAddress = Game.Scene.GetComponent <StartConfigComponent>().Get(8).GetComponent <InnerConfig>().Address;
                Session        mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress);
                M2G_CreateUnit createUnit = await mapSession.Call <M2G_CreateUnit>(new G2M_CreateUnit()
                {
                    UnitId = player.UnitId, PlayerId = player.Id, GateSessionId = session.Id
                });

                player.UnitId   = createUnit.UnitId;
                response.UnitId = createUnit.UnitId;
                response.Count  = createUnit.Count;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
        protected override async void Run(Session session, C2G_EnterMap message, Action <G2C_EnterMap> reply)
        {
            G2C_EnterMap response = new G2C_EnterMap();

            try
            {
                Player player = session.GetComponent <SessionPlayerComponent>().Player;
                // 在map服务器上创建战斗Unit
                IPEndPoint     mapAddress = Game.Scene.GetComponent <StartConfigComponent>().MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint;
                Session        mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress);
                M2G_CreateUnit createUnit = (M2G_CreateUnit)await mapSession.Call(new G2M_CreateUnit()
                {
                    PlayerId = player.Id, GateSessionId = session.Id
                });

                player.UnitId   = createUnit.UnitId;
                response.UnitId = createUnit.UnitId;
                response.Count  = createUnit.Count;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
        protected override async void Run(Session session, C2G_CreateLandlordRoom message)
        {
            G2C_EnterMap response = new G2C_EnterMap();

            try
            {
                Log.Debug(MongoHelper.ToJson(message));
                Player player = session.GetComponent <SessionPlayerComponent>().Player;
                StartConfigComponent       startConfigComponet = Game.Scene.GetComponent <StartConfigComponent>();
                IPEndPoint                 matchAddress        = startConfigComponet.MatchConfig.GetComponent <InnerConfig>().IPEndPoint;
                Match2G_CreateRoomResponse matchRoomRes        = await Game.Scene.GetComponent <NetInnerComponent>().Get(matchAddress).Call <Match2G_CreateRoomResponse>(new G2Match_CreateRoomRequest());

                long roomId = matchRoomRes.roomId;

                // 在map服务器上创建战斗Unit
                IPEndPoint     mapAddress = startConfigComponet.MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint;
                Session        mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress);
                M2G_CreateUnit createUnit = await mapSession.Call <M2G_CreateUnit>(new G2M_CreateUnit()
                {
                    PlayerId = player.Id, GateSessionId = session.Id
                });

                //player.UnitId = createUnit.UnitId;
                //response.UnitId = createUnit.UnitId;
                //response.Count = createUnit.Count;
                // reply(response);
            }
            catch (Exception e)
            {
                // ReplyError(response, e, reply);
            }
        }
Example #4
0
        protected override async void Run(Session session, C2G_LoginGate message, Action <G2C_LoginGate> reply)
        {
            G2C_LoginGate response = new G2C_LoginGate();

            try
            {
                string account = Game.Scene.GetComponent <GateSessionKeyComponent>().Get(message.Key);
                if (account == null)
                {
                    response.Error   = ErrorCode.ERR_ConnectGateKeyError;
                    response.Message = "Gate key验证失败!";
                    reply(response);
                    return;
                }
                Player player = EntityFactory.Create <Player, string>(account);
                Game.Scene.GetComponent <PlayerComponent>().Add(player);
                session.AddComponent <SessionPlayerComponent>().Player = player;
                await session.AddComponent <ActorComponent, IEntityActorHandler>(new GateSessionEntityActorHandler()).AddLocation();

                // 在map服务器上创建战斗Unit
                string         mapAddress = Game.Scene.GetComponent <StartConfigComponent>().MapConfigs[0].GetComponent <InnerConfig>().Address;
                Session        mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapAddress);
                M2G_CreateUnit createUnit = await mapSession.Call <M2G_CreateUnit>(new G2M_CreateUnit()
                {
                    PlayerId = player.Id, GateSessionId = session.Id
                });

                player.UnitId = createUnit.UnitId;

                response.PlayerId = player.Id;
                response.UnitId   = createUnit.UnitId;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }