예제 #1
0
        /// <summary>
        /// Beep with less as less pause like a bomb. NOTE: this is a blocking proceedure that wont stop till its done.
        /// </summary>
        public static void PlayBombBeepCountdown()
        {
            int pause = 2000;

            while (pause > 400)
            {
                GenericsClass.Beep(BeepPitch.High, BeepDurration.Medium);
                Thread.Sleep(pause -= (int)(pause * 0.15));
            }
            while (pause >= 25)
            {
                GenericsClass.Beep(BeepPitch.High, BeepDurration.Medium);
                Thread.Sleep(pause -= 25);
            }
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Medium);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Medium);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Short);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Short);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Short);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Short);
            GenericsClass.Beep(BeepPitch.High, BeepDurration.Short);

            GenericsClass.Beep(BeepPitch.High, 100);
            GenericsClass.Beep(BeepPitch.High, 100);
            GenericsClass.Beep(BeepPitch.High, 100);

            GenericsClass.Beep(BeepPitch.High, 50);
            GenericsClass.Beep(BeepPitch.High, 50);
            GenericsClass.Beep(BeepPitch.High, 50);
        }
예제 #2
0
        public void Wander(float delta)
        {
            Vector2 pos = new Vector2(Cursor.Position.X, Cursor.Position.Y);

            cycle++;
            if (cycle == updatesBetweenJitter)
            {
                cycle = 0;
                // SHOULDFIX adjust this code to not convert to/from degrees to
                // radians - if slow
                float targetJitter = (float)(GenericsClass.Random.NextDouble() * targetMaxJitter * 2 - targetMaxJitter);
                lastJitterHeading += targetJitter;
                lastJitterHeading %= 360;
                // dif to jitter on circle around object
                float jitterX1 = (float)(pos.X + Math.Sin((180 - lastJitterHeading) * Math.PI / 180) * targetRadius);
                float jitterY1 = (float)(pos.Y + Math.Cos((180 - lastJitterHeading) * Math.PI / 180) * targetRadius);
                // dif to jitter on circle around ant - shifted along current
                // heading
                float jitterX2 = (float)(jitterX1 + Math.Sin((180 - heading) * Math.PI / 180) * targetDistance);
                float jitterY2 = (float)(jitterY1 + Math.Cos((180 - heading) * Math.PI / 180) * targetDistance);

                float newHeading = GenericsClass.CalcHeading(pos.X, pos.Y, jitterX2, jitterY2, true, true);
                SetHeading(newHeading);
            }
            MoveCursorByHeading(delta, BouceOnBounds);
        }
예제 #3
0
        public static double Bounce(float headingAngle, float normalAngle)
        {
            double h = GenericsClass.DegreesToRadians(headingAngle);
            double n = GenericsClass.DegreesToRadians(normalAngle);
            double r = n + (n - ((h + Math.PI) % (2 * Math.PI)));

            return(GenericsClass.RadiansToDegrees(r));
            // return (float)(normalAngle+(normalAngle-(headingAngle+180)));
        }
예제 #4
0
 public static string DownloadHTML(string url, string cookie = null, bool reportExceptions = false)
 {
     try
     {
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
         request.KeepAlive = false;
         request.Timeout   = DOWNLOAD_HTML_TIMEOUT;
         if (cookie != null)
         {
             request.Headers.Add(HttpRequestHeader.Cookie, cookie);
         }
         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
         if (response.StatusCode == HttpStatusCode.OK)
         {
             Stream       receiveStream = response.GetResponseStream();
             StreamReader readStream    = null;
             if (response.CharacterSet == null)
             {
                 readStream = new StreamReader(receiveStream);
             }
             else
             {
                 readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
             }
             string data = readStream.ReadToEnd();
             response.Close();
             readStream.Close();
             return(data);
         }
         return(null);
     }
     catch (UriFormatException e)
     {
         GenericsClass.Log("DownloadHTML(string,string,bool) - Caught UriFormatException from url:\"" + url + "\" - " + e.Message);
         return(null);
     }
     catch (WebException e)
     {
         if (reportExceptions)
         {
             if (e.Message.IndexOf("timed out") > -1)
             {
                 GenericsClass.Log("DownloadHTML(string,string,bool) - WebException - Call to page timed out.");
             }
             else
             {
                 //track real errors too
                 if (url.IndexOf('?') > -1)//No need to send full url data - prevent endless repeating the nested failure call stack
                 {
                     GenericsClass.Log("DownloadHTML(string,string,bool) - Caught web exception from (trimmed) url:\"" + url.Substring(0, url.IndexOf('?')) + "\" - " + e.Message);
                 }
                 else
                 {
                     GenericsClass.Log("DownloadHTML(string,string,bool) - Caught web exception from url:\"" + url + "\" - " + e.Message);
                 }
             }
             return(null);
         }
         else
         {
             throw e;
         }
     }
 }
예제 #5
0
 public CursorWanderAI(float speed, float startHeading)
 {
     this.speed = speed;
     SetHeading(startHeading);
     GenericsClass.CalcAllSceensBounds();
 }
예제 #6
0
 public CursorWanderAI()
 {
     speed = 0;
     SetHeading(0);
     GenericsClass.CalcAllSceensBounds();
 }