VS Code C# Client Environment Setup
Overview
This document provides instructions for setting up the C# environment for developing code which controls a ship in the Space Battle Arena (SBA) programming game.
This initial C# support was added by the community and is built by them, it is not yet officially supported by Mikeware, use at your own risk. See Issue #162
These instructions were prepared for VS Code 1.39 and above.
Initial C# Setup
These instructions were tested with .NET Core 3.0
Download and install the .NET 3 Core SDK, if you haven't already.
Open VS Code and Install the C# extension:
ms-vscode.csharp
Initial Environment Setup
Create a new folder and open it in VS Code.
Open the Terminal and type:
dotnet new console
Then add the SBA NuGet package:
dotnet add package SBA_Client.Net
Class Setup
Open up the Program.cs file.
Modify it to look like this:
using System; using System.Collections.Generic; using System.Drawing; using SpaceBattleArena; namespace APCS { class Program { static void Main(string[] args) { TextClient<BasicGameInfo>.run("127.0.0.1", new MyShip(), 2012); } } class MyShip : BasicSpaceship { override public RegistrationData registerShip(int numImages, int worldWidth, int worldHeight) { return new RegistrationData("Example Ship", Color.White, 0); } override public ShipCommand getNextCommand(BasicEnvironment env) { return new IdleCommand(1); } } }
Execution Instructions
Note: Do not terminate the program through the VS Code UI; instead, click in the Terminal window and use 'Ctrl+C' to gracefully close the connection.
In your Program.cs file, edit the IP address in the call to TextClient.run to point it to the location of your server.
TextClient<BasicGameInfo>.run("127.0.0.1", new MyShip(), 2012);
Open the Terminal and use:
dotnet run
To start the application.
Type 'Ctrl+C' in the Terminal pane to disconnect your ship.