예제 #1
0
 public static bool isAlone(LifeBonus life)
 {
     for (int i = 0; i < Game1.smile.allSmiles.Count(); i++)
     {
         if (isCollision(life.Position, Game1.smile.allSmiles[i].Position))
             return false;
     }
     for (int i = 0; i < Game1.lifeBonus.allLifeBonuses.Count(); i++)
     {
         if ((life != Game1.lifeBonus.allLifeBonuses[i]) && isCollision(life.Position, Game1.lifeBonus.allLifeBonuses[i].Position))
             return false;
     }
     for (int i = 0; i < Game1.choiceBonus.allChoiceBonuses.Count(); i++)
     {
         if (isCollision(life.Position, Game1.choiceBonus.allChoiceBonuses[i].Position))
             return false;
     }
     for (int i = 0; i < Game1.sightBonus.allSightBonuses.Count(); i++)
     {
         if (isCollision(life.Position, Game1.sightBonus.allSightBonuses[i].Position))
             return false;
     }
     return true;
 }
예제 #2
0
        public bool Create(int i, int j)
        {
            int color = rand.Next(0, 10);

            LifeBonus life = new LifeBonus(TextureLoad.Heart, new Rectangle(i * Size, j * Size, Size, Size), Size, Size, new Vector2(i * Size, j * Size));
            if (color == (int)bonusType.LIFE && (j == 0 || !isAlone(life)))
            {
                allLifeBonuses.Add(life);
                return true;
            }
            return false;
        }
예제 #3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            TextureLoad.Load(Content);

            background = new Background(TextureLoad.Background, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferWidth);
            paper = new Background(TextureLoad.Paper, new Rectangle(0, background.Height - 200, 251, 200), 251, 200);

            font = TextureLoad.LifesFont;

            gun = new Gun();
            gun.Create();

            lazer = new Lazer();
            lazer.Create();

            line = new Line();
            line.Create();

            life = new LifeBonus(TextureLoad.Heart, new Rectangle(paper.Width / 2, background.Height - 2 * sizeOfSmile - 25, sizeOfSmile, sizeOfSmile), sizeOfSmile, sizeOfSmile, new Vector2(paper.Width / 2, background.Height - 2 * sizeOfSmile - 25));

            newGame();
        }
예제 #4
0
        public static void newGame()
        {
            setConstants();

            amountOfShot = 0;

            smile = new Smile();
            lifeBonus = new LifeBonus();
            choiceBonus = new ChoiceBonus();
            sightBonus = new SightBonus();

            for (int i = 0; i < maxNumInRow; i++)
                for (int j = 0; j < maxNumInCol; j++)
                {
                    if (smile.Create(i, j)) ;
                    else if (heartIsAvailable && lifeBonus.Create(i, j));
                    else if (sightIsAvailable && choiceBonus.Create(i, j));
                    else if (palmIsAvailable && sightBonus.Create(i, j));
                }

            bullet = new Bullet();
            bullet.Create();

            nextBullet = new Bullet();
            nextBullet.Create();
            nextBullet.Position = new Vector2(140, ScreenSize.Y - sizeOfSmile - 20);
        }