Exemplo n.º 1
0
        public bool StartBattle(BattleData battle)
        {
            BattleSession battleSession = BattleSession.New(battle);

            battleSession.Start();
            return(true);
        }
Exemplo n.º 2
0
        public override async Task DoPipeline(BattleSession session, BaseProtocol requestInfo)
        {
            var req = requestInfo as ProtoTest;

            session.Send(req.Msg, MessagePackSerializer.Serialize(new ProtoTest
            {
                Msg = MessageType.Test,
                Num = 20
            }));
        }
Exemplo n.º 3
0
        private GameMode(BattleSession session)
        {
            this.m_session              = session;
            this.m_logicWatch           = new Stopwatch();
            this.m_logicGameMode        = new LogicGameMode();
            this.m_serverCommandStorage = new ServerCommandStorage(this, this.m_logicGameMode);
            this.m_gameListener         = new GameListener(this);

            this.m_logicGameMode.GetLevel().SetGameListener(this.m_gameListener);
            this.m_logicGameMode.GetCommandManager().SetListener(this.m_serverCommandStorage);
        }
Exemplo n.º 4
0
        public void Connect(BattleSession battleSession)
        {
            Protocol.Init(battleSession.session, battleSession.secret);

            _connector = new Transporter(this);

            var endpoint = battleSession.host + ":" + battleSession.port;

            SkynetLogger.Info(Channel.Udp, "Udp Client URL " + endpoint);
            _connector.Connect(battleSession.host, battleSession.port);
        }
Exemplo n.º 5
0
    public void OnEnterBattle(BattleSession session)
    {
        _curSession = session;

        int width  = BattleProcedure.CurSessionVO.MapVO.Width;
        int length = BattleProcedure.CurSessionVO.MapVO.Length;

        SetCameraRotation(new Vector3(50, 0, 0));
        SetCameraFocusPosition(new Vector2(width / 2 * BattleConst.MAP_GRID_SIDE_LENGTH, length / 2 * BattleConst.MAP_GRID_SIDE_LENGTH));

        GestureManager.Instance.SwipeAction += OnSwipe;
    }
Exemplo n.º 6
0
        public static GameMode LoadChallengeAttackState(BattleSession session, GameChallengeAttackState state)
        {
            LogicClientHome   home            = state.Home;
            LogicClientAvatar homeOwnerAvatar = GameUtil.LoadHomeOwnerAvatarFromHome(home);
            LogicClientAvatar playerAvatar    = state.PlayerAvatar;

            int currentTimestamp            = TimeUtil.GetTimestamp();
            int secondsSinceLastSave        = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0;
            int secondsSinceLastMaintenance = 0;

            EnemyHomeDataMessage enemyHomeDataMessage = new EnemyHomeDataMessage();

            enemyHomeDataMessage.SetCurrentTimestamp(currentTimestamp);
            enemyHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave);
            enemyHomeDataMessage.SetSecondsSinceLastMaintenance(secondsSinceLastMaintenance);
            enemyHomeDataMessage.SetLogicClientHome(home);
            enemyHomeDataMessage.SetLogicClientAvatar(homeOwnerAvatar);
            enemyHomeDataMessage.SetAttackerLogicClientAvatar(playerAvatar);
            enemyHomeDataMessage.SetAttackSource(5);
            enemyHomeDataMessage.SetMapId(state.MapId);
            enemyHomeDataMessage.Encode();

            CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON());
            CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON());
            CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON());

            try
            {
                GameMode gameMode = new GameMode(session);

                gameMode.m_logicGameMode.LoadDirectAttackState(home, homeOwnerAvatar, playerAvatar, secondsSinceLastSave, state.MapId == 1, false, currentTimestamp);
                gameMode.m_challengeAllianceId = state.AllianceId;
                gameMode.m_challengeStreamId   = state.StreamId;
                gameMode.m_liveReplayId        = state.LiveReplayId;

                ZLibHelper.CompressInZLibFormat(LogicStringUtil.GetBytes(LogicJSONParser.CreateJSONString(gameMode.m_logicGameMode.GetReplay().GetJson())), out byte[] streamJSON);
                ServerMessageManager.SendMessage(new InitializeLiveReplayMessage
                {
                    AccountId  = gameMode.m_liveReplayId,
                    StreamData = streamJSON
                }, 9);

                session.SendPiranhaMessage(enemyHomeDataMessage, 1);
                return(gameMode);
            }
            catch (Exception exception)
            {
                Logging.Error("GameMode.loadChallengeAttackState: exception while the loading of attack state: " + exception);
            }

            return(null);
        }
Exemplo n.º 7
0
    void Join()
    {
        var joinRequest = new SpObject();

        joinRequest.Insert("session", 0);
        joinRequest.Insert("model", "fight");

        _client.Request("join", joinRequest, (SpObject obj) =>
        {
            var udpSession = new BattleSession
            {
                session = obj["session"].AsInt(),
                host    = obj["host"].AsString(),
                port    = obj["port"].AsInt(),
                secret  = obj["secret"].AsString()
            };

            Signals.Get <UdpSignal>().Dispatch(udpSession);
        });
    }
Exemplo n.º 8
0
        public static GameMode LoadFakeAttackState(BattleSession session, GameFakeAttackState state)
        {
            LogicClientHome   home            = state.Home;
            LogicClientAvatar homeOwnerAvatar = state.HomeOwnerAvatar;
            LogicClientAvatar playerAvatar    = state.PlayerAvatar;

            int currentTimestamp            = TimeUtil.GetTimestamp();
            int secondsSinceLastSave        = state.SaveTime != -1 ? currentTimestamp - state.SaveTime : 0;
            int secondsSinceLastMaintenance = state.MaintenanceTime != -1 ? currentTimestamp - state.MaintenanceTime : 0;

            EnemyHomeDataMessage enemyHomeDataMessage = new EnemyHomeDataMessage();

            enemyHomeDataMessage.SetCurrentTimestamp(currentTimestamp);
            enemyHomeDataMessage.SetSecondsSinceLastSave(secondsSinceLastSave);
            enemyHomeDataMessage.SetSecondsSinceLastMaintenance(secondsSinceLastMaintenance);
            enemyHomeDataMessage.SetLogicClientHome(home);
            enemyHomeDataMessage.SetLogicClientAvatar(homeOwnerAvatar);
            enemyHomeDataMessage.SetAttackerLogicClientAvatar(playerAvatar);
            enemyHomeDataMessage.SetAttackSource(1);
            enemyHomeDataMessage.Encode();

            CompressibleStringHelper.Uncompress(home.GetCompressibleHomeJSON());
            CompressibleStringHelper.Uncompress(home.GetCompressibleCalendarJSON());
            CompressibleStringHelper.Uncompress(home.GetCompressibleGlobalJSON());

            try
            {
                GameMode gameMode = new GameMode(session);
                gameMode.m_logicGameMode.LoadDirectAttackState(home, homeOwnerAvatar, playerAvatar, secondsSinceLastSave, false, false, currentTimestamp);
                session.SendPiranhaMessage(enemyHomeDataMessage, 1);
                return(gameMode);
            }
            catch (Exception exception)
            {
                Logging.Error("GameMode.loadFakeAttackState: exception while the loading of attack state: " + exception);
            }

            return(null);
        }
Exemplo n.º 9
0
    public void OnEnter()
    {
        _logger.Log("enter battle");

        ScenesManager
        .Instance
        .LoadScene("TestScene1",
                   () =>
        {
            // Init Presentation layer first
            _logger.Log("init session");
            _curSession = new BattleSession();
            _curSession.InitSession();

            // Init Data layer to drive session
            var luaSessionTable = LuaManager.Instance.LuaEnv.Global.Get <LuaTable>("BattleSession");
            var curSession      = luaSessionTable.Get <LuaFunction>("StartBattle").Call(CurSessionVO)[0] as LuaTable;
            _luaSession         = curSession.Cast <ILuaSession>();

            _luaSession.EnterGame();
            _curSession.InitBattleUI();
        });
        EventManager.Instance.On(EventConst.ON_SHOW_CARD_DETAIL, OnShowCardDetail);
    }
Exemplo n.º 10
0
 public BattleWindow(BattleSession session) : base(WindowType.Toplevel)
 {
     this.session = session;
     this.build();
     this.sbar.Push(0, "Ready");
 }
Exemplo n.º 11
0
 public abstract Task DoPipeline(BattleSession session, BaseProtocol requestInfo);
Exemplo n.º 12
0
 private void SignalUdp(BattleSession session)
 {
     _gateUdp = new TestGateUdp();
     _gateUdp.Run(session);
 }
 public LogicMessageManager(BattleSession session)
 {
     this.m_session = session;
 }