Esempio n. 1
0
        public GameService(IWebSocketConnection connection, IComponents components)
        {
            this.connection = connection;

            connection.OnOpen    += OnConnectionEstablished;
            connection.OnClose   += OnConnectionClosed;
            connection.OnError   += OnErrorOccurred;
            connection.OnMessage += OnMessageReceived;

            id = components.Get <IIdGenerator>().GenerateId();
            sessionCollection   = components.Get <IWebSocketSessionCollection>();
            gameSceneCollection = components.Get <IGameSceneCollection>();

            jsonSerializer    = new NativeJsonSerializer();
            handlerCollection = new MessageHandlerCollection(jsonSerializer);
            player            = new PlayerGameObject(id, new IComponent[]
            {
                new AnimationData(),
                new CharacterData(),
                new PresenceMapProvider(),
                new MessageSender(jsonSerializer),
                new PositionChangedMessageSender(),
                new AnimationStateChangedMessageSender(),
                new PlayerAttackedMessageSender(),
                new BubbleNotificationMessageSender()
            });
        }
Esempio n. 2
0
        protected override void OnAwake()
        {
            idGenerator         = Components.Get <IIdGenerator>();
            gameSceneCollection = Components.Get <IGameSceneCollection>();

            gameSceneCollection.Add(Map.Lobby, CreateLobby());
            gameSceneCollection.Add(Map.TheDarkForest, CreateTheDarkForest());
        }
Esempio n. 3
0
        public ChangeSceneMessageHandler(IGameObject player, IGameSceneCollection gameSceneCollection)
        {
            this.gameSceneCollection = gameSceneCollection;

            proximityChecker    = player.Components.Get <IProximityChecker>();
            presenceMapProvider = player.Components.Get <IPresenceMapProvider>();
            messageSender       = player.Components.Get <IMessageSender>();
        }
Esempio n. 4
0
        public EnterSceneMessageHandler(IGameObject player, IGameSceneCollection gameSceneCollection)
        {
            this.player = player;
            this.gameSceneCollection = gameSceneCollection;

            characterData       = player.Components.Get <ICharacterData>();
            presenceMapProvider = player.Components.Get <IPresenceMapProvider>();
            messageSender       = player.Components.Get <IMessageSender>();
        }