Example #1
0
 /// <summary>
 /// Create or remove the cat
 /// </summary>
 protected void ToggleCat()
 {
     if (cat == null)
     {
         cat = new Cat(catTexture, GraphicsDevice.Viewport.TitleSafeArea.Width, 
                       GraphicsDevice.Viewport.TitleSafeArea.Height);
     }
     else
     {
         cat = null;
     }
 }
Example #2
0
        /// <summary>
        /// Update each flock member, Each bird want to fly with or flee from everything
        /// it sees depending on what type it is
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        /// <param name="cat"></param>
        public void Update(GameTime gameTime, Cat cat)
        {
            foreach (Bird thisBird in flock)
            {
                thisBird.ResetThink();

                foreach (Bird otherBird in flock)
                {
                    //this check is so we don't try to fly to ourself!
                    if (thisBird != otherBird)
                    {
                        thisBird.ReactTo(otherBird, ref flockParams);
                    }
                }

                //Look for the cat
                thisBird.ReactTo(cat, ref flockParams);

                thisBird.Update(gameTime, ref flockParams);
            }
        }
Example #3
0
        public FlockingSample()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

#if WINDOWS_PHONE || IOS
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            graphics.IsFullScreen = true;
#endif
            inputState = new InputState();

            flock = null;
            cat = null;

            flockParams = new AIParameters();
            ResetAIParams();
        }