Category5.VictimUFO.PlaceInWorld C# (CSharp) Method

PlaceInWorld() protected method

protected PlaceInWorld ( ) : void
return void
        protected virtual void PlaceInWorld()
        {
            int border = rnd.Next(0, 3);
            float X;
            float Y;

            switch (border)
            {
                case (int)Heading.North:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 3f * (float)Math.PI / 4f;
                    Y = 1 - squareDimensions;
                    X = rnd.Next(0, (int)level.Bounds.Width - squareDimensions);
                    break;
                case (int)Heading.East:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 5f * (float)Math.PI / 4f;
                    X = level.Bounds.Width - 1;
                    Y = rnd.Next(0, (int)level.Bounds.Height - squareDimensions);
                    break;
                case (int)Heading.South:
                    flyHeading = rnd.Next() * ((float)Math.PI / 4f) + 7f * (float)Math.PI / 4f;
                    Y = level.Bounds.Height - 1;
                    X = rnd.Next(0, (int)level.Bounds.Width - squareDimensions);
                    break;
                case (int)Heading.West:
                    flyHeading = rnd.Next() * (float)Math.PI / 4f + (float)Math.PI / 4f;
                    X = 1 - squareDimensions;
                    Y = rnd.Next(0, (int)level.Bounds.Height - squareDimensions);
                    break;
                default:
                    throw new Exception("Unknown Border Of The Level to Generate");
                    break;
            }

            bounds = new Rectangle2D(X, Y, squareDimensions, squareDimensions);
        }