Removed offset for player position calculation as server does this for now
[clanbomber-xamarin-client.git] / src / communication / ConnectionTest / ConnectionTest / ConnectionTest / MainPage.xaml.cs
index 7dc03f8..2cdf227 100644 (file)
@@ -31,7 +31,7 @@ namespace Bomberman
 
             con = new TcpJsonConnection(ServerPkgReceived);
 
-            //con.Connect(IPAddress.Parse("192.168.0.5"));
+            //con.Connect(IPAddress.Parse("10.29.17.60"));
             con.Connect(Dns.GetHostEntry(Dns.GetHostName()).AddressList[1]);    //localhost
 
 
@@ -59,6 +59,7 @@ namespace Bomberman
                         horizontalLayout.Children.Add(dummy);
                         Button up = new Button();
                         up.Pressed += Up_Pressed;
+                        up.Released += Up_Released;
                         up.Text = "^";
                         horizontalLayout.Children.Add(up);
                         horizontalLayout.Children.Add(dummy);
@@ -68,15 +69,18 @@ namespace Bomberman
                         Button left = new Button();
                         left.Text = "<";
                         left.Pressed += Left_Pressed;
+                        left.Released += Left_Released;
                         horizontalLayout.Children.Add(left);
 
                         Button bomb = new Button();
                         bomb.Pressed += Bomb_Pressed;
+                        bomb.Released += Bomb_Released;
                         bomb.Text = "*";
                         horizontalLayout.Children.Add(bomb);
 
                         Button right = new Button();
                         right.Pressed += Right_Pressed;
+                        right.Released += Right_Released;
                         right.Text = ">";
                         horizontalLayout.Children.Add(right);
                         break;
@@ -85,6 +89,7 @@ namespace Bomberman
                         horizontalLayout.Children.Add(dummy);
                         Button down = new Button();
                         down.Pressed += Down_Pressed;
+                        down.Released += Down_Released;
                         down.Text = "V";
                         horizontalLayout.Children.Add(down);
                         horizontalLayout.Children.Add(dummy);
@@ -96,6 +101,31 @@ namespace Bomberman
             }
         }
 
+        private void Down_Released(object sender, EventArgs e)
+        {
+            con.SendEvent(TcpJsonConnection.InputState.Idle);
+        }
+
+        private void Right_Released(object sender, EventArgs e)
+        {
+            con.SendEvent(TcpJsonConnection.InputState.Idle);
+        }
+
+        private void Bomb_Released(object sender, EventArgs e)
+        {
+            con.SendEvent(TcpJsonConnection.InputBomb.Idle);
+        }
+
+        private void Left_Released(object sender, EventArgs e)
+        {
+            con.SendEvent(TcpJsonConnection.InputState.Idle);
+        }
+
+        private void Up_Released(object sender, EventArgs e)
+        {
+            con.SendEvent(TcpJsonConnection.InputState.Idle);
+        }
+
         private void MainPage_SizeChanged(object sender, EventArgs e)
         {
             CreateInitializePlayground(c_defaultPlaygroundSize);
@@ -162,32 +192,27 @@ namespace Bomberman
         private void Bomb_Pressed(object sender, EventArgs e)
         {
             con.SendEvent(TcpJsonConnection.InputBomb.PlaceBomb);
-            con.SendEvent(TcpJsonConnection.InputBomb.Idle);
         }
 
         private void Right_Pressed(object sender, EventArgs e)
         {
             con.SendEvent(TcpJsonConnection.InputState.Right);
-            con.SendEvent(TcpJsonConnection.InputState.Idle);
         }
 
         private void Left_Pressed(object sender, EventArgs e)
         {
             con.SendEvent(TcpJsonConnection.InputState.Left);
-            con.SendEvent(TcpJsonConnection.InputState.Idle);
         }
 
         private void Down_Pressed(object sender, EventArgs e)
         {
             con.SendEvent(TcpJsonConnection.InputState.Down);
-            con.SendEvent(TcpJsonConnection.InputState.Idle);
         }
 
 
         private void Up_Pressed(object sender, EventArgs e)
         {
             con.SendEvent(TcpJsonConnection.InputState.Up);
-            con.SendEvent(TcpJsonConnection.InputState.Idle);
         }
     }
 }