private void BtnContinue_Clicked(object sender, EventArgs e)
 {
     if ((settings.EnemyName != null) && settings.NumOfShots > 0 && settings.SizeOfGrid > 0 && (settings.YourName != null))
     {
         bluetooth.SendMessage("Setup2");
         GoToSetup2();
     }
     else
     {
         if (settings.EnemyName == null)
         {
             ToastManager.Show("Enemy Not Entered Name Yet");
         }
         else if (settings.NumOfShots == 0)
         {
             ToastManager.Show("Number Of Shots Hasn't Been Selected");
         }
         else if (settings.SizeOfGrid == 0)
         {
             ToastManager.Show("Size Of Grid Hasn't Been Selected");
         }
         else if (settings.YourName == null)
         {
             ToastManager.Show("Please Enter A Name");
         }
     }
 }
Пример #2
0
        public void GridButton_Clicked(object sender, EventArgs e)
        {
            if (settings.YourTurn)
            {
                btn = (ImageButton)sender;

                settings.YourTurn = false;
                ToastManager.Show(btn.ClassId);
                settings.AllReadySelected.Add(btn.ClassId);
                bluetooth.SendMessage(btn.ClassId);
            }
            else
            {
                ToastManager.Show("Not Your Turn");
                Task.Run(async() =>
                {
                    uint timeout = 50;
                    await MainStack.TranslateTo(-15, 0, timeout);
                    await MainStack.TranslateTo(15, 0, timeout);
                    await MainStack.TranslateTo(-9, 0, timeout);
                    await MainStack.TranslateTo(9, 0, timeout);
                    await MainStack.TranslateTo(-5, 0, timeout);
                    await MainStack.TranslateTo(5, 0, timeout);
                    await MainStack.TranslateTo(-2, 0, timeout);
                    await MainStack.TranslateTo(2, 0, timeout);
                    MainStack.TranslationX = 0;
                });
            }
        }
Пример #3
0
 public void ReceiveHit(bool value)
 {
     if (value)
     {
         btn.Source           = FileManager.SRCGridButtonShotGlassCross;
         settings.EnemyShots -= 1;
         if (settings.EnemyShots == 0)
         {
             ToastManager.Show("You Win");
             bluetooth.SendMessage("endgame");
             EndGame(true);
         }
         else
         {
             ToastManager.Show("Hit!");
             bluetooth.SendMessage("ready");
             txtStatus.Text = settings.EnemyName + "'s Turn";
         }
     }
     else
     {
         btn.Source = FileManager.SRCGridButtonCross;
         ToastManager.Show("Miss!");
         bluetooth.SendMessage("ready");
         txtStatus.Text = settings.EnemyName + "'s Turn";
     }
 }
        private void EntName_TextChanged(object sender, TextChangedEventArgs e)
        {
            string stringTemp = entName.Text;

            if (string.IsNullOrEmpty(stringTemp) || stringTemp == "")
            {
                stringTemp = "";
            }
            if (stringTemp != "")
            {
                try
                {
                    bluetooth.SendMessage(stringTemp + ",nam");
                    settings.YourName = stringTemp;
                }
                catch (Exception ex)
                {
                    ToastManager.Show(ex.Message);
                }
            }
            else
            {
                bluetooth.SendMessage(",n");
            }
        }
        public void RejectResume()
        {
            ToastManager.Show("Resume Game Rejected");
            FileManager file = new FileManager();

            file.DeleteGameSetting(settings.ConnectedDeviceName);
        }
        public void AcceptResume()
        {
            ToastManager.Show("Resuming Game");
            FileManager file = new FileManager();

            settings = file.GetGameSettings(settings.ConnectedDeviceName);
            GoToGame();
        }
Пример #7
0
        public void ReceiveCheck(string coordenates)
        {
            string[] split = coordenates.Split(',');

            if (settings.YourShotCoodinates.Contains(coordenates))
            {
                settings.YourGrid[int.Parse(split[0]), int.Parse(split[1])].Source = FileManager.SRCGridButtonShotGlassCross;
                settings.YourShotCoodinates.Remove(coordenates);
                settings.NumOfShots -= 1;
                txtNumOfShots.Text   = settings.NumOfShots.ToString();
                bluetooth.SendMessage("hit");
                ToastManager.Show("Drink Up!");
            }
            else
            {
                bluetooth.SendMessage("miss");
            }
        }
Пример #8
0
        public void EndGame(bool value)
        {
            if (!value)
            {
                ToastManager.Show("You Lose! Drink The Rest Of Your Shots!");
            }

            Button btn = new Button
            {
                Text            = "Exit Game",
                TextColor       = Theme.ButtonTextColour,
                BackgroundColor = Theme.ButtonBgColour,
                BorderColor     = Theme.ButtonBorderColour
            };

            btn.Clicked += EndGame_Clicked;
            PageStack.Children.Add(btn);
        }
        private void EntryNumOfShots_TextChanged(object sender, TextChangedEventArgs e)
        {
            string stringTemp = entryNumOfShots.Text;

            if (string.IsNullOrEmpty(stringTemp) || stringTemp == "")
            {
                stringTemp = "";
            }
            int intTemp;

            if (stringTemp != "")
            {
                try
                {
                    intTemp = int.Parse(stringTemp);
                    if (intTemp <= MaxNumOfShots)
                    {
                        bluetooth.SendMessage(intTemp.ToString() + ",num");
                        settings.NumOfShots = intTemp;
                    }
                    else
                    {
                        entryNumOfShots.Text = "";
                        ToastManager.Show("Cannot Enter More Than " + MaxNumOfShots.ToString() + " Shots");
                    }
                }
                catch (Exception ex)
                {
                    entryNumOfShots.Text = "";
                    ToastManager.Show("Number Of Shots Needs To Be A Number");
                }
            }
            else
            {
                bluetooth.SendMessage(",s");
                settings.NumOfShots = 0;
            }
        }
 private void Continue()
 {
     ToastManager.Show("Game Started");
     BGStuff.settingUpGame2 = false;
     Navigation.PushAsync(new Game(bluetooth, gameSettings));
 }