示例#1
0
        // create an instance of a multi mushroom
        private void SpawnShrooms()
        {
            List <Shroom> spawnedShrooms = new List <Shroom>();


            random = new Random();
            Random randomForLoop = new Random();
            int    bound         = randomForLoop.Next(25, 40);

            for (int i = 0; i < bound; i++)
            {
                shroom = new Image();
                int shroomLeftMargin = random.Next(0, 29) * 16;
                int shroomTopMargin  = random.Next(0, 28) * 16;

                BitmapImage bitShroom = new BitmapImage(new Uri("ms-appx:/Assets/Cenitpede Sprites to .png/Mushroom_Normal_Full.png"));

                shroom.Stretch = Stretch.None;
                shroom.Source  = bitShroom;

                shroom.Width               = 16;
                shroom.Height              = 16;
                shroom.VerticalAlignment   = VerticalAlignment.Top;
                shroom.HorizontalAlignment = HorizontalAlignment.Left;
                shroom.Margin              = new Thickness(shroomLeftMargin, shroomTopMargin, 0, 0);

                Background.Children.Add(shroom);

                Shroom spawnedShroom = new Shroom(shroomLeftMargin, shroomTopMargin, shroom);


                ShroomList.Add(spawnedShroom);
            }
        }
示例#2
0
        private void DispatcherTimer_Tick(object sender, object e)
        {
            bool shotDisapeered = false, hit = false;/*, hitFlea=false;*/

            bool done = false;

            MovePlayer();
            // if shot is created on the board it will continue to move up until it is deleted
            if (shot != null)
            {
                shot.Margin = new Thickness(shot.Margin.Left, shot.Margin.Top - 20, 0, 0);
                List <Shroom> DeleteList = new List <Shroom>();
                DeleteList = Shroom.checkCollisionShroom(ShroomList, shot, out hit);
                if (hit)
                {
                    Background.Children.Remove(shot);
                    shot     = null;
                    CanShoot = true;
                }
                foreach (Shroom shroom in DeleteList)
                {
                    Background.Children.Remove(shroom.mainImage);
                }
                DeleteList.Clear();
                if (shot != null)
                {
                    shotDisapeered = CheckForBulletWallCollision(shot);
                }
                if (shotDisapeered)
                {
                    shot = null;
                }
                //hitFlea = Flea.checkCollision(fleaBoi, flea);
                //if (hitFlea)
                //{
                //    Background.Children.Remove(flea);
                //}

                // CheckForMushroomCollision(shroom);
            }
            if (GameOver)
            {
                this.Frame.Navigate(typeof(GameOverPage));
            }
            timesTicked += 1;
        }
示例#3
0
        //private void CheckForMushroomCollision(Image shroom)
        //{
        //    // if bullet hits a mushroom it gets removed from the grid (and should be able to set the shroom to a different image showing it lost health)
        //     if ((shot.Margin.Left <= shroom.Margin.Left - shroom.Width) &&  (shot.Margin.Top <= shroom.Margin.Top + shroom.Height) && (shot != null) )
        //    {
        //        Background.Children.Remove(shot);
        //        Background.Children.Remove(shroom);

        //        CanShoot = true;
        //    }
        //}

        private void SpawnOneShroom(int x, int y)
        {
            int shroomLeftMargin = x;
            int shroomTopMargin  = y;

            BitmapImage bitShroom = new BitmapImage(new Uri("ms-appx:/Assets/Cenitpede Sprites to .png/Mushroom_Normal_Full.png"));

            shroom.Stretch = Stretch.None;
            shroom.Source  = bitShroom;

            shroom.Width               = 16;
            shroom.Height              = 16;
            shroom.VerticalAlignment   = VerticalAlignment.Top;
            shroom.HorizontalAlignment = HorizontalAlignment.Left;
            shroom.Margin              = new Thickness(shroomLeftMargin, shroomTopMargin, 0, 0);

            Background.Children.Add(shroom);

            Shroom spawnedShroom = new Shroom(shroomLeftMargin, shroomTopMargin, shroom);


            ShroomList.Add(spawnedShroom);
        }