Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            // Set the desired size and background color
            ClientSize     = new Size(Constants.VIEWSIZE, Constants.VIEWSIZE + Constants.MENUSIZE);
            this.BackColor = Color.Black;

            // Make a new controller
            controller = new GameController.GameController();

            // register handlers for the controller's events
            controller.newInformation += UpdateView;
            controller.Error          += ShowError;
            controller.Connected      += HandleConnected;
            controller.AllowInput     += StartGameFunctionality;

            // Place and add the drawing panel
            drawingPanel          = new DrawingPanel(controller);
            drawingPanel.Location = new Point(0, Constants.MENUSIZE);
            drawingPanel.Size     = new Size(Constants.VIEWSIZE, Constants.VIEWSIZE);
            this.Controls.Add(drawingPanel);

            //register key handlers
            this.KeyDown += HandleKeyDown;
            this.KeyUp   += HandleKeyUp;
        }
Esempio n. 2
0
        private void OnClientChanged(IClient oldClient, IClient newClient)
        {
            // Remove old handlers
            if (oldClient != null)
            {
                oldClient.GameStarted -= OnGameStarted;

                _controller?.UnsubscribeFromClientEvents();
                Bot?.UnsubscribeFromClientEvents();
            }

            // Add new handlers
            if (newClient != null)
            {
                newClient.GameStarted += OnGameStarted;
                // And create controller + bot
                _controller = new GameController.GameController(newClient);
                //Bot = new GenericBot(newClient, new LuckyToiletOnePiece(), null);
                Bot = new GenericBot(newClient, new AdvancedPierreDellacherieOnePiece(), new SinaCSpecials());
                //Bot = new GenericBot(newClient, new ColinFaheyTwoPiece(), new SinaCSpecials());
            }
            else
            {
                _controller = null;
                Bot         = null;
            }
        }
Esempio n. 3
0
        public static void Main()
        {
            iocContainer = new Container(new StructureMapRegistry());
            _bus         = iocContainer.GetInstance <Bus>();
            var controller = new GameController.GameController(_bus);

            controller.Run();
        }
Esempio n. 4
0
 /// <summary>
 /// Creates a new drawing panel with the specified controller and preps it for drawing frames of TankWars
 /// </summary>
 /// <param name="cntlr"></param>
 public DrawingPanel(GameController.GameController cntlr)
 {
     DoubleBuffered  = true;
     theWorld        = cntlr.GetWorld();
     controller      = cntlr;
     ActiveAnimation = new HashSet <object>();
     controller.TriggerAnimations += HandleAnimations;
     playerColors = new Dictionary <string, Tuple <Image, Image, Image> >();
     LoadImages();
 }
Esempio n. 5
0
 /// <summary>
 /// this constructor for the form, iniiialized all the form components and adds the panel on the form
 /// </summary>
 public Form1()
 {
     InitializeComponent();
     //game controller referce
     gameController = new GameController.GameController();
     gameController.registerNetwork1(formNetwork);
     gameController.RegisterFrame(refreshPanel);
     gameController.RegisterEvent(append);
     gameController.RegisterClose(close);
     //making a panel for the world
     panel          = new DrawingPanel.DrawingPanel(gameController.GetWorld());
     panel.Location = new System.Drawing.Point(0, 40);
     //defualting the panel size to the max, will be later adjusted to the user
     panel.Size = new System.Drawing.Size(2000, 2000);
     //adding control inputs to the panel
     this.Controls.Add(panel);
 }