Esempio n. 1
0
 public FieldForm(Game GameObject)
 {
     InitializeComponent();
     this.GameObject             = GameObject;
     MyField                     = new FieldViewer(10, new System.Drawing.Point(1, 1), 50);
     EnemyField                  = new FieldViewer(10, new System.Drawing.Point(756, 1), 50);
     EnemyField.SelectionEnabled = true;
     this.Controls.Add(MyField);
     for (int i = 0; i < GameObject.MyField.FieldSize; ++i)
     {
         for (int j = 0; j < GameObject.MyField.FieldSize; ++j)
         {
             MyField.updateCellState(GameObject.MyField.getCell(i, j).State, new Point(i, j));
         }
     }
     this.Controls.Add(EnemyField);
     EnemyField.CellClick += new DataGridViewCellEventHandler(EnemyCellClick);
     Program.ConnectionManager.OnConnectionLost += new EventHandler <EventArgs>(OnConnectionLostHandler);
     Program.ConnectionManager.OnMessageReceive += new EventHandler <GameData>(GameObject.ReceiveMsg);
     GameObject.SendMessage    += new EventHandler <GameData>(Program.ConnectionManager.SendMsg);
     GameObject.OnDataUpdate   += new EventHandler <DataUpdateEventArguments>(UpdateData);
     GameObject.OnGameFinished += new EventHandler <bool>(OnGameFinished);
     GameObject.ChangeMove     += new EventHandler(ChangeMove);
     updateEnemyLabels();
     updatePlayerLabels();
     updateMoveLabel();
     PlayerSelect    = new Point(-1, -1);
     MyField.Enabled = false;
 }
Esempio n. 2
0
 private void SafeCellStateUpdate(FieldViewer Viewer, CellState State, Point pos)
 {
     if (Viewer.InvokeRequired)
     {
         SafeCellUpdate UpdateState = new SafeCellUpdate(SafeCellStateUpdate);
         this.Invoke(UpdateState, Viewer, State, pos);
     }
     else
     {
         Viewer.updateCellState(State, pos);
     }
 }
Esempio n. 3
0
        public ShipsMappingForm(SelectField FieldCallBack)
        {
            InitializeComponent();
            ConfirmField = FieldCallBack;
            field        = new Field(10);
            FieldView    = new FieldViewer(10, new System.Drawing.Point(458, 1), 50);
            FieldView.CellContentClick += CellClickHandler;
            FieldView.Enabled           = false;
            CurCounters = new int[4];

            for (int i = 0; i < 4; ++i)
            {
                CurCounters[i] = i + 1;
            }
            this.Controls.Add(FieldView);
            FieldView.Enabled      = false;
            ResetShipBtn.Enabled   = false;
            ConfirmShipBtn.Enabled = false;
            deleteMode             = false;
            //deleteship too
        }