Exemple #1
0
 void heroAnew(AnimatedSprite _hero)
 {
     _hero.rect = _hero.rectStartUP;
     _hero.countfire = 0;
     _hero.Visible = true;
     if (_hero.isSmall) _hero.doSmall();
 }
Exemple #2
0
        public void CreateLevel()
        {
            try { MediaPlayer.Play(Game1.songLiberty.musicLevel[currentLevel - 1]); }
             catch (System.Exception ex)
            { MediaPlayer.Play(Game1.songLiberty.musicLevel[0]); }

            Game1.Elements.blocks = new List<GameObject>();
            Game1.Elements.elemeNotCollides = new List<GameObject>();
            Game1.Elements.bonus = new List<GameObject>();
            Game1.Elements.gums = new List<AnimatedSprite>();

            String st = "Bin\\Levels\\level";
            if (!File.Exists(st + currentLevel + ".lv")) currentLevel = 1;
            string[] s = File.ReadAllLines(st + currentLevel + ".lv");
            //File.Encrypt(st + currentLevel + ".lv");
            //File.Decrypt(st + currentLevel + ".lv");

            int x = 0;
            int y = 0;
            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    Rectangle rect = new Rectangle(x, y, 40, 40);
                    switch (c)
                    {
                        #region Block
                        case 'X':
                            {
                                GameObject block = new GameObject(blockTexture[0], rect);
                                block.type = "block1";
                                Game1.Elements.blocks.Add(block);
                            } break;
                        case 'Y':
                            {
                                GameObject block = new GameObject(blockTexture[1], rect);
                                block.type = "block2";
                                Game1.Elements.blocks.Add(block);
                            } break;
                        case 'B':
                            {
                                GameObject block = new GameObject(blockTexture[2], new Rectangle(x, y, 41, 184));
                                block.type = "bamboo";
                                Game1.Elements.blocks.Add(block);
                            } break;
                        case 'S':
                            {
                                GameObject block = new GameObject(blockTexture[3], new Rectangle(x, y, 41, 92));
                                block.type = "bambootopSliceHorizontal";
                                Game1.Elements.blocks.Add(block);
                            } break;
                        #endregion
                        #region Bonus
                        case 'a':
                            {
                                GameObject bon = new GameObject(bonusTexture[0], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "apple";
                                Game1.Elements.bonus.Add(bon);
                            } break;

                        case 'b':
                            {
                                GameObject bon = new GameObject(bonusTexture[1], rect);
                                bon.type = "beetle";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        case 'h':
                            {
                                GameObject bon = new GameObject(bonusTexture[2], new Rectangle(x, y,
                                                                 rect.Width, rect.Height / 2));
                                bon.type = "hand";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        case 'c':
                            {
                                GameObject bon = new GameObject(bonusTexture[3], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "heart";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        case 'm':
                            {
                                GameObject bon = new GameObject(bonusTexture[4], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height));
                                bon.type = "men";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        case 'r':
                            {
                                GameObject bon = new GameObject(bonusTexture[5], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "ruby";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        case 'A':
                            {
                                GameObject bon = new GameObject(bonusTexture[6], new Rectangle(x, y,
                                                                 rect.Width / 2, rect.Height / 2));
                                bon.type = "box1";
                                Game1.Elements.bonus.Add(bon);
                            } break;
                        #endregion
                        #region Elements not Collides
                        case 'H':
                            {
                                GameObject block = new GameObject(blockTexture[4], new Rectangle(x, y, 280, 220));
                                block.type = "hause1";
                                Game1.Elements.elemeNotCollides.Add(block);
                            } break;
                        #endregion
                        #region Gum
                        case 'M':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[0]);
                                gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[0].Lives;
                                gum.speed = Game1.ListGums[0].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;
                        case 'R':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[1]);
                                gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[1].Lives;
                                gum.speed = Game1.ListGums[1].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;
                        case 'G':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[2]);
                                //gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[2].Lives;
                                gum.speed = Game1.ListGums[2].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;
                        case 'C':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[3]);
                                gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[3].Lives;
                                gum.speed = Game1.ListGums[3].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;
                        case 'K':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[4]);
                                gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[4].Lives;
                                gum.speed = Game1.ListGums[4].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;
                        case 'g':
                            {
                                AnimatedSprite gum = new AnimatedSprite(new Rectangle(x, y, 70, 70), runGum[5]);
                              //  gum.isSlowMode = true;
                                gum.AmountProfile.Lives = Game1.ListGums[5].Lives;
                                gum.speed = Game1.ListGums[5].speed;
                                Game1.Elements.gums.Add(gum);
                            } break;

                        #endregion
                    }
                    x += 40;
                }
                x = 0;
                y += 40;
            }
        }
Exemple #3
0
 public void UpdateLogic(AnimatedSprite hero)
 {
     if (doLogic && Visible)
     {
         if (!isRight)
             rect.Offset(-dxspeed, 0);
         else
            rect.Offset(dxspeed, 0);
     }
     foreach (AnimatedSprite gum in Game1.Elements.gums)
     {
         Rectangle worldRectGum = Game1.GetScreenRect(gum.rect);
         if (worldRectGum.Intersects(Game1.GetScreenRect(rect)) && gum.Visible && Visible)
         {
             Game1.songLiberty.hitGum.Play(Game1.songLiberty.VolumeEffect, 0.01f, 1);
             gum.AmountProfile.Lives--;
             if (gum.AmountProfile.Lives < 1) hero.AmountProfile.kilGums++;
              Visible = false;
         }
     }
     foreach (GameObject block in Game1.Elements.blocks)
     {
         Rectangle worldRect = Game1.GetScreenRect(rect);
         worldRect.Height -= 10;
         if (worldRect.Intersects(Game1.GetScreenRect(block.rect)) && block.Visible && Visible)
         {
             if (block.type == "block1" || block.type == "bambootopSliceHorizontal" || block.type == "bamboo")
             {
                 Game1.songLiberty.hitBlock.Play(Game1.songLiberty.VolumeEffect, 0.01f, 1);
                 block.Visible = Visible = false;
                 GameObject bon = new GameObject(Game1.level.bonusTexture[0],
                                  new Rectangle(block.rect.X, block.rect.Y,
                                                rect.Width / 2, rect.Height / 2));
                 bon.type = "apple";
                 Game1.Elements.bonus.Add(bon);
             }
             else Visible = false;
         }
     }
 }
Exemple #4
0
        // Переміщення видимої області екрану
        void Scroll(AnimatedSprite tmpHero)
        {
            if (isTwoPlayers)
            {
                Rectangle rectH1 = GetScreenRect(hero.rect);
                Rectangle rectH2 = GetScreenRect(hero2.rect);

                if ((SizeScreen.Width - 200 < rectH1.X && SizeScreen.Width - 200 < rectH2.X)
                        || (200 > rectH1.X && 200 > rectH2.X) && (hero.Visible.Equals(hero2.Visible)))
                    ScrollX += (int) tmpHero.dxspeed;

                if ((SizeScreen.Width - 50 < GetScreenRect(tmpHero.rect).X || 10 > GetScreenRect(tmpHero.rect).X))
                    tmpHero.rect.Offset((int)-tmpHero.dxspeed, 0);

                if ((SizeScreen.Width - 200 < GetScreenRect(tmpHero.rect).X || 200 > GetScreenRect(tmpHero.rect).X)
                          && !(hero.Visible.Equals(hero2.Visible)))
                    ScrollX += (int) tmpHero.dxspeed;
            }
             else
              if ((SizeScreen.Width - 200 < GetScreenRect(tmpHero.rect).X || 200 > GetScreenRect(tmpHero.rect).X) && !isTwoPlayers)
                  ScrollX += (int) tmpHero.dxspeed;
        }
Exemple #5
0
        // Завантаження файлів в память
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Music Load
            String str = "Sounds\\";
            MediaPlayer.IsRepeating = true;
            songLiberty.background = Content.Load<Song>(@str + "background");
            songLiberty.winner = Content.Load<Song>(@str + "winner");
            songLiberty.musicLevel[0] = Content.Load<Song>(@str + "NinjAcademy_Music");
            songLiberty.musicLevel[1] = Content.Load<Song>(@str + "smb2-characterselect");
            songLiberty.musicLevel[2] = Content.Load<Song>(@str + "QotR");
            songLiberty.musicLevel[3] = Content.Load<Song>(@str + "smb-overworld");

            songLiberty.click = Content.Load<SoundEffect>(@str + "click");
            songLiberty.throwChuck = Content.Load<SoundEffect>(@str + "throwChuck");
            songLiberty.hitGum = Content.Load<SoundEffect>(@str + "hitGum");
            songLiberty.shot = Content.Load<SoundEffect>(@str + "shot");
            songLiberty.hitBlock = Content.Load<SoundEffect>(@str + "hitBlock");
            songLiberty.catchBonus = Content.Load<SoundEffect>(@str + "catchBonus");
            #endregion

            Font = Content.Load<SpriteFont>("Font\\Arial14");
            //cursor = new GameObject(Content.Load<Texture2D>("Textures\\menu\\cursor"));

            spritePers = new SpriteAnimatedTexture[6];
            spritePers[0] = LoadPersTexture("Mario");
            spritePers[1] = LoadPersTexture("ChuckNorris");
            spritePers[2] = LoadPersTexture("Aladdin");
            spritePers[3] = LoadPersTexture("Assassin");
            spritePers[4] = LoadPersTexture("Scorpion");
            spritePers[5] = LoadPersTexture("Homer");

            Rectangle rectStartUP = new Rectangle(300, 370, 60, 60);
            hero = new AnimatedSprite(rectStartUP, spritePers[heroChoice].idle, spritePers[heroChoice].run,
                                      spritePers[heroChoice].jump);
            hero.fireTexture = Content.Load<Texture2D>("Textures\\a_Persons\\ammunition");
            hero.rectStartUP = rectStartUP;

            hero2 = new AnimatedSprite(Game1.hero.rectStartUP, Game1.spritePers[Game1.heroChoice2].idle,
                                             Game1.spritePers[Game1.heroChoice2].run,
                                             Game1.spritePers[Game1.heroChoice2].jump);
            hero2.fireTexture = Content.Load<Texture2D>("Textures\\a_Persons\\ammunition");
            hero2.rectStartUP = Game1.hero.rectStartUP;
            hero2.rectStartUP.Offset(-35, 0);

            str = "Textures\\Game Elements\\Background\\";
            background[0] = Content.Load<Texture2D>(str + "highscoreBg");
            background[1] = Content.Load<Texture2D>(str +  "43");
            background[2] = Content.Load<Texture2D>(str + "gameplayBG");
            background[3] = Content.Load<Texture2D>(str + "love_is_all_around_us_by_Codex_nz");
            background[4] = Content.Load<Texture2D>(str + "1600_0069");
        }
Exemple #6
0
        // Встановлення герєві анімації текстур
        public static void ChangePersTexture(AnimatedSprite _hero, int _heroChoice)
        {
            _hero.idle = spritePers[_heroChoice].idle;
            _hero.run = spritePers[_heroChoice].run;
            _hero.jump = spritePers[_heroChoice].jump;
            _hero.YShift = _hero.frameWidth = _hero.frameHeight = _hero.run.Height;

            _hero.AmountProfile.type = spritePers[_heroChoice].type;
        }
        void drawSceenPrf(SpriteBatch spriteBatch, Vector2 _PosScreen, AnimatedSprite _hero)
        {
            Avatar = new GameObject(_hero.idle);
            Avatar.rect = new Rectangle(0 + (int)_PosScreen.X, 0 + (int)_PosScreen.Y, 73, 73);
            Apple.rect = new Rectangle(71 + (int)_PosScreen.X, 50 + (int)_PosScreen.Y,23, 23);
            Ruby.rect = new Rectangle(156 + (int)_PosScreen.X, 50 + (int)_PosScreen.Y, 23, 23);
            Ammunition.rect = new Rectangle(62 + (int)_PosScreen.X, 78 + (int)_PosScreen.Y, 40, 40);

            Avatar.Draw(spriteBatch);
            for (int i = 0; i < _hero.AmountProfile.Lives; i++)
            {
                Lives.rect = new Rectangle(73 + i * 27 + (int)_PosScreen.X, 10 + (int)_PosScreen.Y, 20, 25);
                Lives.Draw(spriteBatch);
            }
            if(_hero.AmountProfile.Lives > -1)
              for (int i = 0; i < _hero.AmountProfile.Life; i++)
              {
                  Life.rect = new Rectangle(64 + 27 * (_hero.AmountProfile.Lives - 1) + 10 + (i + 1) * 28 +
                                                    (int)_PosScreen.X, 15 + (int)_PosScreen.Y, 17, 17);
                  Life.Draw(spriteBatch);
               }

            Apple.Draw(spriteBatch);
            spriteBatch.DrawString(Font, " x" + _hero.AmountProfile.Apple,
                             new Vector2(Apple.rect.X + Apple.rect.Height + 3, Apple.rect.Y + 3), Color.Red);

            Ruby.Draw(spriteBatch);
            spriteBatch.DrawString(Font, " x" + _hero.AmountProfile.Ruby,
                             new Vector2(Ruby.rect.X + Ruby.rect.Height + 3, Ruby.rect.Y + 3), Color.Red);

            spriteBatch.Draw(Ammunition.Sprite, Ammunition.rect, new Rectangle(0, 0, 79, 70),
                              Color.AliceBlue, 0, Vector2.Zero, SpriteEffects.None, 0);
            spriteBatch.DrawString(Font, " x" + _hero.AmountProfile.ammunition,
                       new Vector2(Ammunition.rect.X + Ammunition.rect.Height - 3, Ammunition.rect.Y + 3), Color.Red);
        }