Пример #1
0
    private void BouncingOnTheBox(BouncingBox box)
    {
        moveVector.y = moveVector.y * -box.verticalBounciness;
        moveVector.x = moveVector.x * box.horizontalBounciness;
        float nextBounce = GetNextBouncingSpot();

        if (transform.position.x + nextBounce > goal.transform.position.x - 1)
        {
            indicator.SetActive(false);
            AutoAim();
        }
        else
        {
            indicator.SetActive(true);
            indicator.transform.position = new Vector2(transform.position.x + nextBounce, indicator.transform.position.y);
        }
    }
Пример #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            int maxX = graphics.GraphicsDevice.Viewport.Width;
            int maxY = graphics.GraphicsDevice.Viewport.Height;
            numBouncyThings = 20;
            numBouncyBox = numBouncyThings / 2;
            numBouncyTriangles = numBouncyThings / 2;
            bouncyThings = new BouncingThing[numBouncyThings];
            Random r = new Random();
            for (int i = 0; i < numBouncyThings; i++)
            {
                if (i < numBouncyTriangles)
                {
                    bouncyThings[i] = new BouncingTriangle(maxX, maxY, r);
                }
                else
                {
                    bouncyThings[i] = new BouncingBox(maxX, maxY, r);
                }
            }

            base.Initialize();
        }