public MainMenu(RenderWindow window, ImageManager imageManager, Client client, Server server) : base(window, imageManager) { imageManager = new ImageManager(); p = new Player(null, imageManager); mouse = new Sprite(imageManager.GetImage("mouse")); pImage = new RenderImage(window.Width, window.Height); pImage.DefaultView.Zoom(0.08F); pImage.DefaultView.Center = p.Center + new Vector2f(0, -30); pImage.SetView(pImage.DefaultView); this.window = window; this.client = client; this.server = server; items = new MenuItem[nbrItem]; items[0] = new MenuItem("Local Game", new Vector2f(0, 100), StartLocal); items[1] = new MenuItem("Connect", new Vector2f(0, 130), Connect); items[2] = new MenuItem("Options", new Vector2f(0, 160), Option); items[3] = new MenuItem("Load map", new Vector2f(0, 190), LoadMap); items[4] = new MenuItem("Save map", new Vector2f(0, 220), SaveMap); items[5] = new MenuItem("Exit", new Vector2f(0, 280), Exit); foreach (MenuItem i in items) i.CenterX((int)window.Width); }
public Chat(Client client) { writing = false; myFont = new Font("content/arial.ttf"); toWrite = ""; msgList = new List<KeyValuePair<DateTime, string>>(); this.client = client; }
public ConnectMenu(RenderWindow window, ImageManager imageManager, Client client, Server server) : base(window, imageManager) { this.server = server; this.client = client; p = new Player(null, imageManager); randomiser = new Random(); pImage = new RenderImage(window.Width, window.Height); pImage.DefaultView.Zoom(0.08F); pImage.DefaultView.Center = p.Center + new Vector2f(0, -40); pImage.DefaultView.Rotate(135); pImage.SetView(pImage.DefaultView); mouse = new Sprite(imageManager.GetImage("mouse")); title = new MenuItem("Enter an IP to connect to...", new Vector2f(0, 100), null); title.CenterX((int)window.Width); ip = new MenuItem("", new Vector2f(0, 150), null); ip.CenterX((int)window.Width); connecting = new MenuItem("Connecting...", new Vector2f(0, 180), null); connecting.CenterX((int)window.Width); }
public InputManager(Client client) { this.client = client; RenderWindow window = client.MainWindow; input = new Input(); keyMap = new Dictionary<Keyboard.Key, Action<bool>>(); keyMap[Keyboard.Key.Up] = moveUp; keyMap[Keyboard.Key.Down] = moveDown; keyMap[Keyboard.Key.Left] = moveLeft; keyMap[Keyboard.Key.Right] = moveRight; keyMap[Keyboard.Key.R] = resetPlayer; keyMap[Keyboard.Key.PageUp] = zoomIn; keyMap[Keyboard.Key.PageDown] = zoomOut; keyMap[Keyboard.Key.A] = layerIn; keyMap[Keyboard.Key.Z] = layerOut; keyMap[Keyboard.Key.N] = toggleNoclip; keyMap[Keyboard.Key.Escape] = toMainMenu; }
static void Main(string[] args) { bool isClient = false; bool isServer = false; String ip = "localhost"; String pseudo = null; int index = 0; if (args.Length != 0) { foreach (string v in args) { if (v == "-server") { isServer = true; isClient = false; } if (v == "-client") { isServer = false; isClient = true; ip = args[index + 1]; } if (v == "-pseudo") { pseudo = args[index + 1]; } index++; } } ImageManager imageManager = new ImageManager(); if (isServer) { Server server = new Server(imageManager); server.Run(); } else { RenderWindow window = new RenderWindow(new VideoMode(800, 600), "2dThing"); Dictionary<int,Screen > screens = new Dictionary<int, Screen>(); int screen = 0; Server server = new Server(imageManager); Client client = new Client(window, imageManager); client.IP = ip; MainMenu mainMenu = new MainMenu(window, imageManager, client, server); ConnectMenu connectMenu = new ConnectMenu(window, imageManager, client, server); screens.Add(Screen.MAINMENU, mainMenu); screens.Add(Screen.GAME, client); screens.Add(Screen.CONNECT, connectMenu); screens.Add(Screen.LOAD, new LoadMenu(window, imageManager, server)); screens.Add(Screen.SAVE, new SaveMenu(window, imageManager, client)); if (isClient) { client.Connect(); client.LoadEventHandler(); screen = Screen.GAME; } else mainMenu.LoadEventHandler(); while (screen >= 0) { int prevScreen = screen; screen = screens[screen].Run(); if (screen >= 0) { screens[prevScreen].UnloadEventHandler(); screens[screen].LoadEventHandler(); } } client.Disconnect(); if (server != null) server.Stop(); } }
public SaveMenu(RenderWindow window, ImageManager imageManger, Client client) : base(window, imageManger) { this.client = client; fl = new FileLister(".", false, "*.map"); }