Beispiel #1
0
        //battle clicked
        void Battle_Clicked(object sender, System.EventArgs e)
        {
            //pick a random number for monster and user
            Random random = new Random();
            double m      = random.Next(1, 10);
            double u      = random.Next(1, 10);
            double p;

            //if monster number is larger
            if (m >= u)
            {
                UHealth -= m * 10;
                //if user health reachs 0
                if (UHealth <= 0)
                {
                    LostLabel.IsVisible    = true;
                    ReturnButton.IsVisible = true;
                    BattleButton.IsVisible = false;
                }
                p = UHealth / 500;
                UserHealth.ProgressTo(p, 250, Easing.Linear);
                UpdateHealthlabels();
            }
            //if users number is larger
            else if (u > m)
            {
                MHealth -= u * 10;
                //if monster health reachs 0
                if (MHealth <= 0)
                {
                    WonLabel.IsVisible     = true;
                    ReturnButton.IsVisible = true;
                    BattleButton.IsVisible = false;
                }
                p = MHealth / monsterInfo.Health;
                MonsterHealth.ProgressTo(p, 250, Easing.Linear);
                UpdateHealthlabels();
            }
        }