Ejemplo n.º 1
0
 public void Compare(Raccoon other)
 {
     if (this.near(other, 30f))
     {
         tooClose       += 1;
         totTooClosePos += other.Position;
     }
 }
Ejemplo n.º 2
0
        public bool near(Raccoon them, float distance)
        {
            Vector2 myPos;
            Vector2 theirPos;

            myPos    = this.Position;
            theirPos = them.Position;

            //float distance = 100;
            float collider = (float)Math.Sqrt((theirPos.X - myPos.X) * (theirPos.X - myPos.X) + (theirPos.Y - myPos.Y) * (theirPos.Y - myPos.Y));

            if (collider <= distance)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
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
            //load sounds
            musicBG = Content.Load <SoundEffect>("banjo_backgroundmusic");
            chitter = Content.Load <SoundEffect>("raccoon_chitter_sfc");
            //load images
            Raccoon1   = Content.Load <Texture2D>("images/raccoon01");
            Grass1     = Content.Load <Texture2D>("images/Grass1");
            foodTruck  = Content.Load <Texture2D>("images/snackcart_90");
            Fence1     = Content.Load <Texture2D>("images/fence1");
            pivotCirc  = Content.Load <Texture2D>("images/pivotCirc");
            winScreen  = Content.Load <Texture2D>("images/winscreen");
            loseScreen = Content.Load <Texture2D>("images/losescreen");
            //setgfx bookkeeping
            rand         = new Random((int)DateTime.Now.Ticks);
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            screenWidth  = (float)(Window.ClientBounds.Width);
            screenHeight = (float)(Window.ClientBounds.Height);
            grabRacc     = false;
            //instantiate various game objects
            maxRaccoon = 10;
            maxFence   = 1;
            gameState  = 0;
            deterent   = 1;

            elapsedTime = 0;
            eTime       = 0;
            roundTime   = 60;

            fenceALoc.X = (screenWidth / 2);
            fenceALoc.Y = (screenHeight / 2);
            snackLoc.X  = 0;
            snackLoc.Y  = (screenHeight / 2) - (foodTruck.Height / 2);

            raccoonArray = new Raccoon[maxRaccoon];
            snackcart    = new Snackcart(this, snackLoc.X, snackLoc.Y);
            fenceArray   = new Fence[maxFence];
            //gamemode

            snackCount = 100;

            //fenceA = new Fence(this, fenceALoc.X, fenceALoc.Y);

            //adds to drawable
            Components.Add(snackcart);


            for (int i = 0; i < maxRaccoon; i++)
            {
                raccoonArray[i] = new Raccoon(this, 600, 200);
                Components.Add(raccoonArray[i]);//adds to drawable
            }
            for (int i = 0; i < maxFence; i++)
            {
                fenceArray[i] = new Fence(this, fenceALoc.X, fenceALoc.Y + i * 30);
                Components.Add(fenceArray[i]);
            }


            base.Initialize();
        }