private void Awake() { Player1 = LocalId.NewShortId(); Player2 = LocalId.NewShortId(); Game = new GameView() { CurrentPlayersTurn = 0, DeclaredResource = false, Players = new GamePlayer[] { new GamePlayer() { OwnerId = Player1, Board = new GameBoard(4, 4) }, new GamePlayer() { OwnerId = Player2, Board = new GameBoard(4, 4) } } }; }
public void CreateSuccessfully() { Assert.Ignore(); var player1 = LocalId.NewShortId(); var player2 = LocalId.NewShortId(); PackageExplorer explorer = null; var gameView = new LobbyView(); gameView.SetupDependancies(explorer); gameView.Apply(new PlayerJoinedProcedure() { OwnerId = player1, DisplayName = "Player 1" }); gameView.Apply(new PlayerJoinedProcedure() { OwnerId = player2, DisplayName = "Player 2" }); gameView.Apply(new StartGameProcedure() { Gameplay = new GameplayView() { } }); gameView.Apply(new DeclareResourceProcedure() { Player = player1, ResourceIdentifier = "1" }); gameView.Apply(new PlaceResourceProcedure() { Player = player1, ResourceIdentifier = "1", ResourcePosition = new Integer2(1, 1) }); gameView.Apply(new PlaceResourceProcedure() { Player = player2, ResourceIdentifier = "1", ResourcePosition = new Integer2(3, 3) }); gameView.Apply(new EndTurnProcedure() { Player = player1 }); gameView.Apply(new DeclareResourceProcedure() { Player = player2, ResourceIdentifier = "2" }); gameView.Apply(new PlaceResourceProcedure() { Player = player1, ResourceIdentifier = "2", ResourcePosition = new Integer2(2, 1) }); gameView.Apply(new PlaceResourceProcedure() { Player = player2, ResourceIdentifier = "2", ResourcePosition = new Integer2(2, 1) }); gameView.Apply(new EndTurnProcedure() { Player = player2 }); gameView.Apply(new DeclareResourceProcedure() { Player = player1, ResourceIdentifier = "3" }); gameView.Apply(new PlaceResourceProcedure() { Player = player1, ResourceIdentifier = "3", ResourcePosition = new Integer2(1, 2) }); gameView.Apply(new PlaceResourceProcedure() { Player = player2, ResourceIdentifier = "3", ResourcePosition = new Integer2(1, 2) }); DrawGameState(gameView); gameView.Apply(new BuildBuildingProcedure() { Player = player1, BuildingIdentifier = "building", BuildingPosition = new Integer2(2, 2), Offset = new Integer2(1, 1), Orientation = BuildingOrientation.None }); gameView.Apply(new EndTurnProcedure() { Player = player1 }); DrawGameState(gameView); }
public void CreateSuccessfully() { var player1 = LocalId.NewShortId(); var player2 = LocalId.NewShortId(); PackageExplorer explorer = null; var gameView = new GameView(); gameView.Create(explorer); gameView.Players = new GamePlayer[] { new GamePlayer() { OwnerId = player1, Board = new GameBoard(4, 4), }, new GamePlayer() { OwnerId = player2, Board = new GameBoard(4, 4), } }; gameView.Apply(new DeclareResourceAction() { Client = player1, ResourceIdentifier = "1" }); gameView.Apply(new PlaceResourceAction() { Client = player1, ResourceIdentifier = "1", ResourcePosition = new Integer2(1, 1) }); gameView.Apply(new PlaceResourceAction() { Client = player2, ResourceIdentifier = "1", ResourcePosition = new Integer2(3, 3) }); gameView.Apply(new EndTurnAction() { Client = player1 }); gameView.Apply(new DeclareResourceAction() { Client = player2, ResourceIdentifier = "2" }); gameView.Apply(new PlaceResourceAction() { Client = player1, ResourceIdentifier = "2", ResourcePosition = new Integer2(2, 1) }); gameView.Apply(new PlaceResourceAction() { Client = player2, ResourceIdentifier = "2", ResourcePosition = new Integer2(2, 1) }); gameView.Apply(new EndTurnAction() { Client = player2 }); gameView.Apply(new DeclareResourceAction() { Client = player1, ResourceIdentifier = "3" }); gameView.Apply(new PlaceResourceAction() { Client = player1, ResourceIdentifier = "3", ResourcePosition = new Integer2(1, 2) }); gameView.Apply(new PlaceResourceAction() { Client = player2, ResourceIdentifier = "3", ResourcePosition = new Integer2(1, 2) }); DrawGameState(gameView); gameView.Apply(new BuildBuildingAction() { Client = player1, BuildingIdentifier = "building", BuildingPosition = new Integer2(2, 2), Offset = new Integer2(1, 1), Orientation = BuildingOrientation.None }); gameView.Apply(new EndTurnAction() { Client = player1 }); DrawGameState(gameView); }
public void Start() { // Import the project var importPipeline = new ImportPipeline(); importPipeline.ImportProcessors.Add(new BoardGameResourceImporter()); var projectExplorer = ProjectExplorer.Load("Content/BoardGame", importPipeline); // Build the project to a package. var consoleRenderer = new BuildConsoleRenderer(); var buildPipeline = new BuildPipeline(); buildPipeline.Exporters.Add(new BhvrExporter()); buildPipeline.BuildActions.Add(consoleRenderer); consoleRenderer.DrawProgressBar(32); projectExplorer.Export(buildPipeline, "BoardGame/Temp"); Console.WriteLine("Exported package..."); Step(); var gameServer = new GameServer(); gameServer.StartHosting(projectExplorer); var playerA = LocalId.NewShortId(); var playerB = LocalId.NewShortId(); gameServer.OnClientConnected(playerA, "Player A"); gameServer.OnClientConnected(playerB, "Player B"); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new StartGameCommand() { }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new DeclareResourceCommand() { ResourceIdentifier = "x" }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new PlaceResourceCommand() { ResourceIdentifier = "x", ResourcePosition = new Integer2(2, 2) }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerB, new PlaceResourceCommand() { ResourceIdentifier = "x", ResourcePosition = new Integer2(3, 1) }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerB, new EndTurnCommand()); DrawGameState(gameServer.Lobby); }
public async Task StartAsync() { // Import the project var importPipeline = ImportPipeline.Create() .UseImporter(new BoardGameResourceImporter()) .UseJsonMetaFiles(options => { options.IsMetaFilesOptional = true; }) .Build(); var projectExplorer = ProjectExplorer.Load("Content/BoardGame", importPipeline); // Build the project to a package. var consoleRenderer = new BuildConsoleRenderer(); var buildPipeline = new BuildPipeline(); buildPipeline.BuildActions.Add(consoleRenderer); consoleRenderer.DrawProgressBar(32); projectExplorer.ExportZippedToDirectory(buildPipeline, "BoardGame/Temp"); var packageExplorer = PackageExplorer.LoadFromFileAsync("BoardGame/Temp/BoardGame.bpkg").Result; var dest = new FileSystemArchive(new DirectoryInfo("BoardGame/Temp")); await packageExplorer.Source.CopyIntoAsync(dest.RootDirectory, "Fast"); var cottage = packageExplorer.Resources["buildings/cottage.json"]; foreach (var dep in cottage.Dependencies) { Console.WriteLine($"{dep.Key}: {dep.Resource?.Name}"); } Step(); var gameServer = new GameServer(); gameServer.StartHosting(projectExplorer); var playerA = LocalId.NewShortId(); var playerB = LocalId.NewShortId(); gameServer.OnClientConnected(playerA, "Player A"); gameServer.OnClientConnected(playerB, "Player B"); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new StartGameCommand() { }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new DeclareResourceCommand() { ResourceIdentifier = "x" }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new PlaceResourceCommand() { ResourceIdentifier = "x", ResourcePosition = new Integer2(2, 2) }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerB, new PlaceResourceCommand() { ResourceIdentifier = "x", ResourcePosition = new Integer2(3, 1) }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerA, new BuildBuildingCommand() { BuildingIdentifier = "cottage", BuildingPosition = new Integer2(1, 1), Offset = new Integer2(1, 1), }); DrawGameState(gameServer.Lobby); Step(); gameServer.AcceptInput(playerB, new EndTurnCommand()); DrawGameState(gameServer.Lobby); }