コード例 #1
0
ファイル: Tank.cs プロジェクト: Joruhe/GraysInvaders
        public void Intesects(Tank tank)
        {
            if (!tank.die)
            {
                Tank tankDie = new Tank(Game, tank);
                Game.Components.Add(tankDie);
            }

            Game.Components.Remove(tank);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: Joruhe/GraysInvaders
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            #region PADCONTROL
            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();
            /*if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed)
                colorin = Color.Green;
            if (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed)
                colorin = Color.Red;
            if (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed)
                colorin = Color.Yellow;
            if (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed)
                colorin = Color.Blue;
            if (GamePad.GetState(PlayerIndex.One).Buttons.RightShoulder == ButtonState.Pressed)
                colorin = Color.Violet;
            if (GamePad.GetState(PlayerIndex.One).Buttons.LeftShoulder == ButtonState.Pressed)
                colorin = Color.Purple;
            if (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed)
                colorin = Color.White;
            if (GamePad.GetState(PlayerIndex.One).Triggers.Right == 1f)
                colorin = Color.Pink;
            if (GamePad.GetState(PlayerIndex.One).Triggers.Left == 1f)
                colorin = Color.Orange;
               /*     if (GamePad.GetState(PlayerIndex.One).DPad.Right == ButtonState.Pressed)
                colorin = Color.Orchid;
            if (GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
                colorin = Color.Maroon;
            if (GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Pressed)
                colorin = Color.Gold;
            if (GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
                colorin = Color.Cyan;*/
            #endregion
            // TODO: Add your update logic here

            DoLogic();

            int count = 0;
            int countInvasor = 0;
            int countComplete = 0;
            int countShoot = 0;
            int countTank = 0;
            List<Invasor> list = new List<Invasor>();

            #region CONTADOR COMPONENTES
            foreach (GameComponent gc in Components)
            {
                if (gc is Background)
                    count++;
                if (gc is Shoot)
                    countShoot++;
                if (gc is Invasor)
                {
                    countInvasor++;
                    if (countInvasor == 1
                        && ((Invasor)gc).die)
                    {
                       // countInvasor = 0;
                    //    list.Add((Invasor)gc);
                    }
                }
                if (gc is Tank)
                {
                    countTank++;
                }
            }
            if (countTank == 0)
            {
                player = new Tank(this, ref tank, screen);
                Components.Add(player);
                player.PutinStartPosition();
            }

            if (count == 0)
                Exit();
            if (countInvasor == 0)
            {
                //countComplete++;
                countComplete = 1;
                invasorsManager.SheetInvaders(this, ref invasor);
                #region SELECT DIFFICULTY
                switch (countComplete)
                {
                    case 1:
                        {
                            invasorsManager.SelectDifficult(difficult.normal.ToString());
                            break;
                        }
                    case 2:
                        {
                            invasorsManager.SelectDifficult(difficult.hard.ToString());
                            break;
                        }
                    default:
                        {
                            invasorsManager.SelectDifficult(difficult.insane.ToString());
                            break;
                        }
                }
                #endregion
            }

            #endregion

            if (ufoBonus)
                UfoBonusYes();

            base.Update(gameTime);
        }
コード例 #3
0
ファイル: Tank.cs プロジェクト: Joruhe/GraysInvaders
        public Tank(Game game, Tank tank)
            : base(game)
        {
            #region CONSTRUCTRO
            this.texture = tank.texture;
            this.frameSize = new Point(64, 64);
            this.currentFrame = tank.currentFrame;
            this.position = tank.position;
            this.sheetSize = new Point(MAXSIZESHEET, 0);
            this.visible = true;
            this.enable = true;
            this.die = true;
            this.collisionOffset = new Point(0, 32);
            this.screenBounds = tank.screenBounds;

            this.millisecondsPerFrame = 60;
            #endregion
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: Joruhe/GraysInvaders
        /// <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()
        {
            #region ISWIDESCREEN
            if (!GraphicsAdapter.DefaultAdapter.IsWideScreen)
            {
                if (graphics.GraphicsDevice.DisplayMode.AspectRatio == 1.25f)
                {
                    ASPECTHD = 16.0f / 9.0f;
                    ASPECTSD = 5f / 4f;
                    ASPECTWIDTHRATIO = 1280f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT = 720f;
                    VIEWPORTWIDTH = 1280f;
                }
                else
                {
                    ASPECTHD = 16.0f / 9.0f;
                    ASPECTSD = 4f / 3f;
                    ASPECTWIDTHRATIO = 1024f / 1280f;
                    ASPECTHEIGHTRATIO = 1024f / 720f;
                    ASPECTRATIO = ASPECTSD / ASPECTHD;
                    VIEWPORTHEIGHT = 720f;
                    VIEWPORTWIDTH = 1280;
                }

            }
            #endregion

            #region BACKGROUND
            tileMap = Content.Load<Texture2D>(@"Barrier\" + nameTileMap);
            backgoundManager = new BackgroundPixelManager(this, ref tileMap, screen);
            Components.Add(backgoundManager);
            #endregion

            #region TANK
            tank = Content.Load<Texture2D>(@"Tank\" + nameTank);
            player = new Tank(this, ref tank, screen);
            Components.Add(player);
            player.PutinStartPosition();
            #endregion

            #region INVASOR
            invasor = Content.Load<Texture2D>(@"Invasors\" + nameInvasor);
            invasorsManager = new InvasorsManager(this, ref invasor, difficult.normal.ToString());
            Components.Add(invasorsManager);
            #endregion

            #region UFO
            ufo_t = Content.Load<Texture2D>(@"Ufo\" + "ufo_sheet");
            ufo = new Ufo(this, ref ufo_t);
            Components.Add(ufo);
            ufo.PutinStartPosition();
            #endregion

            #region PENTAGRAM
            pentagam_sheet = Content.Load<Texture2D>(@"Pentagram\pentagram_sheet");
            pentagramP1 = new Pentagram(this, ref pentagam_sheet, Vector2.Zero);
            pentagramP2 = new Pentagram(this, ref pentagam_sheet, new Vector2(1280 - 120,0));
            Components.Add(pentagramP1);
            Components.Add(pentagramP2);
            #endregion

            base.Initialize();
        }