Beispiel #1
0
        public void RespondToShot(FireResponse resp, char x, int y, string player, string region, FireResult?result = null)
        {
            WeaponResponseComm c   = new WeaponResponseComm(x, y, resp, result);
            string             msg = JsonConvert.SerializeObject(c);

            client.Publish(gametopic + "/" + region + "/" + player, Encoding.ASCII.GetBytes(msg));
        }
Beispiel #2
0
 private void M_ShotResponseRecieved(object sender, EventArgs e)
 {
     if (myTurn)
     {
         WeaponResponseComm c = (WeaponResponseComm)sender;
         short field          = 0;
         if (c.result == null)
         {
             if (c.response == FireResponse.hit)
             {
                 //myTurn = true;
                 field = 3;
             }
             else
             {
                 field = 2;
                 //myTurn = false;
             }
         }
         else if (c.result == FireResult.sunk)
         {
             //myTurn = true;
             field = 4;
         }
         else     //implement o win
         {
             Won.Invoke(me, EventArgs.Empty);
         }
         myTurn = false;
         opponent.Battlefield.field[getIntFromLetter(c.x), c.y] = field;
     }
 }