コード例 #1
0
ファイル: ProtectSprite.cs プロジェクト: travinh/TowerDefense
        public void P_BeAttacked(MediumEnemy EnemySprite, int CurrentHealth)
        {
            if (EnemySprite.position.X <= (this.position.X + this.size.X))
            {
                CurrentHealth -= EnemySprite.E_GetPower();
            }

            if (CurrentHealth == 0)
            {
                P_Die = true;
            }
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: travinh/TowerDefense
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);



            // TODO: use this.Content to load your game content here

            //--Backgrounds--
            Background = Content.Load <Texture2D>("Background");
            mainFrame  = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            //--Drawing Protect Sprite--
            P1 = new ProtectSprite(Content.Load <Texture2D>("Charizard"), new Vector2(200f, 200f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            P2 = new ProtectSprite(Content.Load <Texture2D>("Blastoise"), new Vector2(200f, 400f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            P3 = new ProtectSprite(Content.Load <Texture2D>("Bulbasaur"), new Vector2(200f, 600f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            //--Drawing Enemy Sprite--
            E1 = new MediumEnemy(Content.Load <Texture2D>("Pidgey"), new Vector2(2000f, 200f), new Vector2(200f, 200f),
                                 graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            E2 = new MediumEnemy(Content.Load <Texture2D>("Ratata"), new Vector2(2000f, 400f), new Vector2(200f, 200f),
                                 graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);

            //--Drawing Fire--
            Fire1 = new FireSprite(Content.Load <Texture2D>("Fire"), new Vector2(400f, 200f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            Fire2 = new FireSprite(Content.Load <Texture2D>("Fire"), new Vector2(400f, 400f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            Fire3 = new FireSprite(Content.Load <Texture2D>("Fire"), new Vector2(400f, 600f), new Vector2(200f, 200f),
                                   graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            E1.Populate();
        }