private void RenderPlayer(Image image, int x, int y, FinMaths.Core.Player Player) { FinMaths.Core.PlayerGraphic pg = Player.graphic.Invoke(Player.state.AnimationCycle); int width = Convert.ToInt32(pg.Width * Player.scale); int height = Convert.ToInt32(pg.Height * Player.scale); Bitmap bm = new Bitmap(width, height); using (Graphics gr = Graphics.FromImage(bm)) { for (int iy = 0; iy < pg.Height; iy++) { for (int ix = 0; ix < pg.Width; ix++) { char c = pg.Graphic[iy * pg.Width + ix]; if (c != '.') { Point p = new Point(Convert.ToInt32((ix) * Player.scale), Convert.ToInt32((iy) * Player.scale)); Size s = new Size(Convert.ToInt32(Player.scale), Convert.ToInt32(Player.scale)); Color colour = pg.ColourMap.Invoke(new Tuple<int, int, string> (Player.location.X + x + Convert.ToInt32((ix) * Player.scale), Player.location.Y + y + Convert.ToInt32((iy) * Player.scale), c.ToString())); Brush brush = GetBrush(colour); gr.FillRectangle(brush, new Rectangle(p, s)); } } } using (Graphics gr2 = Graphics.FromImage(image)) { gr2.DrawImage(bm, new Point(Player.location.X + x, Player.location.Y + y)); } } }
public void Start(FinMaths.Core.GameElement initialState) { currentState = FinMaths.Core.FirstGameState(initialState); MemoryStream ms = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, currentState); byte[] bytes = ms.ToArray(); serverQueueManager.SendServerState(currentState); serverQueueManager.ClientKeyPressesRecieved += new EventHandler<ClientKeyPressesRecievedArgs>(serverQueueManager_ClientKeyPressesRecieved); gameTimer.GameTick+=new EventHandler(TimerEvent); gameTimer.Start(); }
public void RenderFormation(Bitmap bm, Point loc, FinMaths.Core.GameElement ge) { FinMaths.Core.GameElement.Formation f = ge as FinMaths.Core.GameElement.Formation; FinMaths.Core.Player gu = f.Item1; Point newLoc = new Point(loc.X + gu.location.X, loc.Y + gu.location.Y); foreach (FinMaths.Core.GameElement childGe in f.Item2) { if (childGe.IsPlayer) { RenderPlayer(bm, newLoc.X, newLoc.Y, (childGe as FinMaths.Core.GameElement.Player).Item); } else { RenderFormation(bm, newLoc, childGe); } } }
public void SendClientKeyPresses(FinMaths.Core.KeyPress kp) { ServerInputQueue.Send(kp.ToString()); }
public void SendServerState(FinMaths.Core.GameElement state) { if (ClientInputQueue == null) { MessageQueue cmq = new MessageQueue(".\\Private$\\Finvaders.ServerOutput"); ClientInputQueue = cmq; } ClientInputQueue.Formatter = new BinaryMessageFormatter(); ClientInputQueue.Send(state); }