All pastes #605148 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-05 23:54 UTC
rendered paste body
            else if (enemyBar.Value > 0 && firstattack == true)
            {
                Random rand = new Random();

                WebRequest myRequest = WebRequest.Create("http://www.kingmuffin.net/csharp/data.xml");
                WebResponse myResponse = myRequest.GetResponse();
                Stream myStream = myResponse.GetResponseStream();
                xmlDoc.Load(myStream);
                xmlDoc.Load(@"C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\gametest\gametest\data.xml");
                XmlNodeList health = xmlDoc.GetElementsByTagName("health");
                myStream.Close();
                myResponse.Close();
                myRequest.Abort();
                double attack = rand.Next(10, 100) * (double.Parse(playerstrength.Text) / 10);

                enemyBar.Value = (int)(((double.Parse(health[currentlevel - 1].InnerText) - attack)/double.Parse(health[currentlevel - 1].InnerText))*100);
                enemyhealth.Text = enemyBar.Value.ToString() + "%";
                realenhealth.Text = enemyBar.Value.ToString();

                firstattack = false;
            }
            else if (enemyBar.Value > 0 && firstattack == false)
            {
                Random rand = new Random();
                double attack = rand.Next(10, 100) * (double.Parse(playerstrength.Text) / 10);
                
                string enhealth = realenhealth.Text;

                enemyBar.Value = (int)(((double.Parse(enhealth) - attack) / double.Parse(enhealth)) * 100);
                enemyhealth.Text = enemyBar.Value.ToString() + "%";
            }