Exemplo n.º 1
0
Arquivo: Level.cs Projeto: mbos14/GTFO
        //Collisions
        public bool CheckCollision(Sprite pSprite)
        {
            //Solid objects
            foreach (Sprite other in solidList)
            {
                if (pSprite.HitTest(other))
                {
                    return true;
                }
            }

            if (pSprite is Player || pSprite is PlayerBullet)
            {
                //Damage blocks
                foreach (Sprite other in damageList)
                {
                    if (pSprite.HitTest(other))
                    {
                        if (pSprite is Player)
                        {
                            Player thisplayer = (Player)pSprite;
                            thisplayer.playerDIE();
                            DrawPreDefinedLayer();
                        }
                        else if (pSprite is PlayerBullet)
                        {
                            pSprite.Destroy();
                        }
                    }
                }

                //Enemies
                foreach (Enemy other in enemyList)
                {
                    if (other._state != EnemyState.death)
                    {
                        if (pSprite.HitTest(other))
                        {
                            if (pSprite is Player)
                            {
                                Player thisplayer = (Player)pSprite;
                                thisplayer.playerDIE();
                            }
                            else if (pSprite is PlayerBullet)
                            {
                                PlayerBullet bullet = (PlayerBullet)pSprite;
                                other.HitByBullet(bullet.damage / 4, player.aimDirection);
                                pSprite.Destroy();
                            }
                        }
                    }
                }

            }

            return false;
        }
Exemplo n.º 2
0
        private void drawScreen()
        {
            //Background
            Sprite background = new Sprite("endscreenbg.png");
            AddChild(background);

            //Draw credits
            _credits = new Sprite("credits.png");
            AddChild(_credits);
            _credits.y = game.height;

            //Draw borders
            Sprite borders = new Sprite("endscreenborders.png");
            AddChild(borders);
        }
Exemplo n.º 3
0
        private void getEnding(bool pLevelWon)
        {
            SoundChannel soundChannel = new SoundChannel(2);
            if (pLevelWon)
            {
                Sprite background = new Sprite("youwon.png");
                AddChild(background);

                Sound youWonSound = new Sound("youwin.mp3");
                youWonSound.Play(false, 2);
            }
            else
            {
                Sprite background = new Sprite("gameover.png");
                AddChild(background);

                Sound gameOverSound = new Sound("gameover.wav");
                gameOverSound.Play(false, 2);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Resolves the collision.
        /// </summary>
        /// <returns><c>true</c>, if collision was resolved, <c>false</c> otherwise.</returns>
        /// <param name="collisionObject">Collision object.</param>
        /// <param name="moveX">Move x.</param>
        /// <param name="moveY">Move y.</param>
        bool resolveCollision(Sprite collisionObject, float moveX, float moveY)
        {
            if (moveX > 0) {
                x = collisionObject.x - width;
                return false;
            }
            if (moveX < 0) {
                x = collisionObject.x + collisionObject.width;
                return false;
            }
            if ((moveY) > 0) {
                y = collisionObject.y - height;
                return false;
            }

            if ((moveY) < 0) {

                y = collisionObject.y + collisionObject.height;

            }
            return true;
        }
Exemplo n.º 5
0
        private void drawScreen()
        {
            //Background
            AnimationSprite background = new AnimationSprite("endscreenbg.png", 1, 2);
            AddChild(background);

            //Draw credits
            _credits = new Sprite("credits.png");
            AddChild(_credits);
            _credits.y = game.height;

            //Draw borders
            Sprite borders = new Sprite("endscreenborders.png");
            AddChild(borders);

            //Draw YOUWON or YOULOST
            AnimationSprite wonlost = new AnimationSprite("wonlost.png", 1, 2);
            wonlost.SetOrigin(wonlost.width / 2, wonlost.height / 2);
            wonlost.SetXY(_game.width / 2, 100);
            AddChild(wonlost);

            //Check if player has won or lost
            if (CurrentWonTest == LevelTest.Won)
            {
                background.SetFrame((int)CurrentWonTest);
                wonlost.SetFrame((int)CurrentWonTest);
            }
            else if (CurrentWonTest == LevelTest.Lost)
            {
                background.SetFrame((int)CurrentWonTest);
                wonlost.SetFrame((int)CurrentWonTest);
            }

            //Draw "Throw in a coin to play again"
            _insertcoin = new Sprite("insertcoin.png");
            AddChild(_insertcoin);
            _insertcoin.SetOrigin(_insertcoin.width / 2, _insertcoin.height / 2);
            _insertcoin.SetXY(game.width / 2, game.height - _insertcoin.height);
        }
Exemplo n.º 6
0
        public LevelSelect()
            : base()
        {
            //Set the menu background
            Sprite background = new Sprite ("Sprites/bg.png");
            AddChild (background);

            //render the game logo
            Sprite logo = new Sprite ("Sprites/logo.png");
            logo.SetOrigin ((logo.width / 2), (logo.height / 2));
            logo.SetXY (244, 130);
            AddChild (logo);

            //list of the level names
            _levelList = new LevelLister ();

            //list of level buttons
            _levelButtons = new List<DrawString> ();

            Console.WriteLine ("LevelSelect");

            //add the menubuttons to the list
            int i = 275;
            foreach (string levelName in _levelList.GetLevels()) {
                _levelButtons.Add (new DrawString (levelName, 244, i, _font, _defaultColor));
                i += 60;
            }

            //add menu buttons to an array
            _levelButtonsArray = _levelButtons.ToArray ();
            for (int k = 0; k < _levelButtonsArray.Length; k++) {
                AddChild (_levelButtonsArray [k]);
            }

            //draw the back button
            _backButton = new DrawString ("Back", 244, 615, _font, _defaultColor);
            AddChild (_backButton);
        }
Exemplo n.º 7
0
Arquivo: Level.cs Projeto: mbos14/GTFO
 //Collisions
 public bool CheckCollision(Sprite pSprite)
 {
     //foreach (Sprite other in invisibleList)
     //{
     //    if (pSprite is Enemy)
     //    {
     //        if (pSprite.HitTest(other))
     //        {
     //            //Turn around
     //        }
     //    }
     //}
     //Solid objects
     foreach (Sprite other in solidList)
     {
         if (pSprite.HitTest(other))
         {
             return true;
         }
     }
     //Damage blocks
     foreach (Sprite other in damageList)
     {
         if (pSprite.HitTest(other))
         {
             if (pSprite is Player)
             {
                 Player thisplayer = (Player)pSprite;
                 thisplayer.playerDIE();
             }
             else if (pSprite is PlayerBullet)
             {
                 pSprite.Destroy();
             }
         }
     }
     return false;
 }
Exemplo n.º 8
0
 public void DrawSprite(Sprite pSprite, PointF pPos)
 {
     DrawSprite(pSprite);
     pSprite.SetXY(pPos.X, pPos.Y);
 }
Exemplo n.º 9
0
Arquivo: Menu.cs Projeto: mbos14/GTFO
        private void drawSecond()
        {
            if (_coinInserted && !_secondDrewn)
            {
                menuBG.Destroy();
                _text.Destroy();

                Sprite background = new Sprite("buttonmenu.png");
                AddChild(background);

                _text = new AnimationSprite("text.png", 1, 4);
                AddChild(_text);
                _text.SetFrame(1);
                _text.SetXY(game.width / 2 - 390 , game.height - 60);
                _secondDrewn = true;
            }
        }
Exemplo n.º 10
0
        private void drawInput()
        {
            Sprite background = new Sprite("keyboardbg.png");
            AddChild(background);

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    KeyboardButtons keyboardButton = new KeyboardButtons(_frameIndicator, _buttonValue);
                    buttonList.Add(keyboardButton);
                    AddChild(keyboardButton);
                    keyboardButton.SetXY(_buttonStartPointX + j * BUTTONSIZE, _buttonStartPointY + i * BUTTONSIZE);
                    keyboardButton.SetFrame(_frameIndicator);
                    _frameIndicator += 2;
                    _buttonValue++;
                }
            }

            _mouse = new Mouse();
            AddChild(_mouse);
        }
Exemplo n.º 11
0
		public void DrawSprite(Sprite sprite) {
			float halfWidth = sprite.texture.width / 2.0f;
			float halfHeight = sprite.texture.height / 2.0f;
			Vector2 p0 = sprite.TransformPoint(-halfWidth, -halfHeight);
			Vector2 p1 = sprite.TransformPoint(halfWidth, -halfHeight);
			Vector2 p2 = sprite.TransformPoint(-halfWidth, halfHeight);
			destPoints[0] = new PointF(p0.x, p0.y);
			destPoints[1] = new PointF(p1.x, p1.y);
			destPoints[2] = new PointF(p2.x, p2.y);
			graphics.DrawImage(sprite.texture.bitmap, destPoints);
		}