Example #1
0
File: Agent.cs Project: Alword/Bost
        public Agent(string server, ushort port, string nickname, SharedGameState shared = null)
            : base(server, port, nickname)
        {
            Id                = Guid.NewGuid();
            SharedState       = shared ?? new SharedGameState();
            ConnectionListner = new ConnectionListner();
            OnRecive         += ConnectionListner.ReciveListner;
            OnSend           += ConnectionListner.SendListner;
            Reset            += (e, x) => ConnectionListner.Reset();

            // clientbound
            ConnectionListner.Subscribe(new SpawnPlayerHandler(this));
            ConnectionListner.Subscribe(new PlayerInfoHandler(this));
            ConnectionListner.Subscribe(new BlockChangeHandler(this));
            ConnectionListner.Subscribe(new ChunkDataHandler(this));
            ConnectionListner.Subscribe(new PlayerPositionAndLookHandler(this));
            ConnectionListner.Subscribe(new EntityTeleportHandler(this));
            ConnectionListner.Subscribe(new EntityPositionHandler(this));
            ConnectionListner.Subscribe(new EntityPositionAndRotationHandler(this));
            ConnectionListner.Subscribe(new MultiBlockChangeHandler(this));
            ConnectionListner.Subscribe(new UnloadChunkHandler(this));
            ConnectionListner.Subscribe(new UpdateHealthHandler(this));
            ConnectionListner.Subscribe(new KeepAliveHandler(this));
            ConnectionListner.Subscribe(new ChatMessageHandler(this));

            // serverbound
            ConnectionListner.Subscribe(new PlayerPositionPacketHandler(this));

            AcceptMissions();
        }
        public GameClientService(SharedGameState gameState, IConfiguration configuration)
        {
            int    port      = configuration.GetValue <int>("Port");
            string ipAddress = configuration.GetValue <string>("IpAddress");

            this.Client = new GameClient(ipAddress, port, gameState);
            this.Client.ConnectAsync();
        }
Example #3
0
        protected override void LoadContent()
        {
            // Global Content
            GlobalContent               = new LockingContentManager(Services);
            GlobalContent.Locked        = false;
            GlobalContent.RootDirectory = "Content";

            ProcessManager.Attach(new AudioManager(GlobalContent));

            LoadGameContent(GlobalContent);
            GlobalContent.Locked = true;

            FieldFont font = GlobalContent.Load <FieldFont>("font_msdf_hyperspace");

            // Attach first game state last
            SharedGameState sharedState = (SharedGameState)ProcessManager.Attach(new SharedGameState(this));

            ProcessManager.Attach(new UIMenuGameState(this, sharedState));
        }
Example #4
0
 public ChessGameManagerService()
 {
     this.SharedGameState = SharedGameStateHelper.GetNewSharedGameState();
 }
Example #5
0
 public CommonGameState(GameManager gameManager,
                        SharedGameState sharedState) : base(gameManager)
 {
     SharedState = sharedState;
 }
Example #6
0
 public GameClient(string address, int port, SharedGameState gameState) : base(address, port)
 {
     _gameState = gameState;
     _protocol  = new RemoteInstructionProtocol(gameState);
 }
 public RemoteInstructionProtocol(SharedGameState gameState)
 {
     _gameState = gameState;
 }