예제 #1
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, EntityManager manager)
        {
            base.Update(gameTime, manager);

            if (Sprite.Done)
            {
                Damage(1);
            }
        }
예제 #2
0
파일: Particle.cs 프로젝트: Natman64/JamLib
        public override void Update(GameTime gameTime, EntityManager manager)
        {
            elapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            Sprite.SetTint(Color.White * (1 - elapsedTime / fadeTime), 5f);

            if (elapsedTime >= fadeTime)
            {
                Damage(1);
            }

            base.Update(gameTime, manager);
        }
예제 #3
0
파일: Hunter.cs 프로젝트: Natman64/JamLib
        public override void Update(GameTime gameTime, EntityManager manager)
        {
            base.Update(gameTime, manager);

            if (airEnabled)
            {
                elapsedBreath += (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (elapsedBreath >= breathInterval)
                {
                    elapsedBreath = 0;
                    air.Damage(1);

                    if (air.IsEmpty)
                    {
                        die(manager);
                        return;
                    }
                }
            }
        }
예제 #4
0
파일: Hunter.cs 프로젝트: Natman64/JamLib
        protected override void shoot(EntityManager manager)
        {
            base.shoot(manager);

            SoundManager.Play(shotSound);
        }
예제 #5
0
파일: Hunter.cs 프로젝트: Natman64/JamLib
 public override void Draw(SpriteBatch spriteBatch, EntityManager manager)
 {
     base.Draw(spriteBatch, manager);
 }
예제 #6
0
 protected override void DrawBar(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, StatBar b, Color color, EntityManager manager)
 {
 }
예제 #7
0
파일: Game1.cs 프로젝트: Natman64/JamLib
        /// <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

            backdrop = Content.Load<Texture2D>("Textures/Backdrop");

            backHealthBar = Content.Load<Texture2D>("Textures/Back Health");
            frontHealthBar = Content.Load<Texture2D>("Textures/Front Health");

            playerPistol = Content.Load<Texture2D>("Textures/Diver");
            playerBarBack = Content.Load<Texture2D>("Textures/Player Bar Back");
            playerBarFront = Content.Load<Texture2D>("Textures/Player Bar Front");

            arrowTexture = Content.Load<Texture2D>("Textures/Arrow");
            fireTexture = Content.Load<Texture2D>("Textures/Fire");

            bloodTexture = Content.Load<Texture2D>("Textures/Blood");

            smallFish = Content.Load<Texture2D>("Textures/Small Fish");
            medFish = Content.Load<Texture2D>("Textures/Med Fish");
            largeFish = Content.Load<Texture2D>("Textures/Large Fish");
            moby = Content.Load<Texture2D>("Textures/Moby Dick");

            smallBubble = Content.Load<Texture2D>("Textures/Small Bubble");
            medBubble = Content.Load<Texture2D>("Textures/Medium Bubble");
            bigBubble = Content.Load<Texture2D>("Textures/Big Bubble");

            lifeSaver = Content.Load<Texture2D>("Textures/Life Saver");

            coin = Content.Load<Texture2D>("Textures/Coin Sprite");

            SoundManager.Add("Select", Content.Load<SoundEffect>("Sounds/Blip_Select6"));
            SoundManager.Add("Splode", Content.Load<SoundEffect>("Sounds/Explosion4"));
            SoundManager.Add("Damage", Content.Load<SoundEffect>("Sounds/Hit_Hurt"));
            SoundManager.Add("Shot", Content.Load<SoundEffect>("Sounds/Laser_Shoot6"));
            SoundManager.Add("Coin", Content.Load<SoundEffect>("Sounds/Pickup_Coin20"));
            SoundManager.Add("Bubble", Content.Load<SoundEffect>("Sounds/Powerup"));
            SoundManager.Add("Health", Content.Load<SoundEffect>("Sounds/Powerup6"));

            SoundManager.Volume = 1f;

            #if WINDOWS

            if (!Directory.Exists(folderPath) || !File.Exists(folderPath + "/save.txt"))
            {
                InitialSave();
            }

            ReadSave();

            #endif

            manager = new EntityManager(frontHealthBar, backHealthBar);

            #if WINDOWS
            screenManager.AddScreen(new MainMenuScreen("Super Fish Hunter!"), null);
            #endif

            #if XBOX
            screenManager.AddScreen(new StartScreen(), null);
            #endif
        }
예제 #8
0
파일: Player.cs 프로젝트: Natman64/JamLib
        public override void Update(GameTime gameTime, EntityManager manager)
        {
            #if WINDOWS

            KeyboardState keyState = Keyboard.GetState();

            #region Movement

            Vector2 velocity = Vector2.Zero;

            if (horizontalMovement)
            {
                if (keyState.IsKeyDown(Keys.Left))
                {
                    velocity.X = -1;
                }

                if (keyState.IsKeyDown(Keys.Right))
                {
                    velocity.X = 1;
                }
            }

            if (verticalMovement)
            {
                if (keyState.IsKeyDown(Keys.Up))
                {
                    velocity.Y = -1;
                }

                if (keyState.IsKeyDown(Keys.Down))
                {
                    velocity.Y = 1;
                }
            }

            if (velocity != Vector2.Zero)
                velocity.Normalize();

            velocity *= speed;

            Sprite.Velocity = velocity;

            #endregion

            #region Shooting

            elapsedShot += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (keyState.IsKeyDown(Keys.Space) && elapsedShot > shotTime)
            {
                elapsedShot = 0f;

                shoot(manager);
            }

            #endregion

            #endif

            #if XBOX

            GamePadState padState = GamePad.GetState(index);

            #region Movement

            Vector2 velocity = Vector2.Zero;

            if (horizontalMovement)
            {
                velocity.X = padState.ThumbSticks.Left.X;
            }

            if (verticalMovement)
            {
                velocity.Y = -padState.ThumbSticks.Left.Y;
            }

            velocity *= speed;

            Sprite.Velocity = velocity;

            #endregion

            #region Shooting

            elapsedShot += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (padState.IsButtonDown(Buttons.A) && elapsedShot > shotTime)
            {
                elapsedShot = 0f;

                shoot(manager);
            }

            #endregion

            #endif

            #region Clamp

            Vector2 location = Sprite.Location;
            int width = Sprite.BoundingBoxRect.Width;
            int height = Sprite.BoundingBoxRect.Height;

            if (location.X < 0)
                location.X = 0;

            if (location.Y < 0)
                location.Y = 0;

            if (location.X > ScreenHelper.Viewport.Width - width)
                location.X = ScreenHelper.Viewport.Width - width;

            if (location.Y > ScreenHelper.Viewport.Height - height)
                location.Y = ScreenHelper.Viewport.Height - height;

            Sprite.Location = location;

            #endregion

            base.Update(gameTime, manager);
        }
예제 #9
0
파일: Player.cs 프로젝트: Natman64/JamLib
        protected virtual void shoot(EntityManager manager)
        {
            Rectangle bulletFrame = new Rectangle(0, 0, bulletTexture.Width, bulletTexture.Height);
            Vector2 bulletVelocity = new Vector2(bulletSpeed, 0f);
            Sprite bulletSprite = new Sprite(Sprite.Location + shotOffset, bulletTexture, bulletFrame, 1, AnimationType.Loop);

            Projectile p = new Projectile(bulletHits, bulletSprite, bulletDamage, bulletVelocity, "Enemies");

            manager.Add(p);
        }
예제 #10
0
파일: Enemy.cs 프로젝트: Natman64/JamLib
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, EntityManager manager)
        {
            Behavior();

            base.Update(gameTime, manager);
        }
예제 #11
0
파일: Entity.cs 프로젝트: Natman64/JamLib
        protected virtual void DrawBar(SpriteBatch spriteBatch, StatBar b, Color color, EntityManager manager)
        {
            Texture2D backTexture = manager.BackBarTexture;
            Texture2D frontTexture = manager.FrontBarTexture;

            int x = (int)sprite.Center.X - backTexture.Width / 2;
            int y = sprite.BoundingBoxRect.Y - backTexture.Height;

            Rectangle backRect = new Rectangle(x, y, (int)(backTexture.Width * b.Fraction), backTexture.Height);
            Rectangle frontRect = new Rectangle(x, y, frontTexture.Width, frontTexture.Height);

            spriteBatch.Draw(manager.BackBarTexture, backRect, null, color, 0f, Vector2.Zero, SpriteEffects.None, 0.1f);
            spriteBatch.Draw(manager.FrontBarTexture, frontRect, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);
        }
예제 #12
0
파일: Entity.cs 프로젝트: Natman64/JamLib
        protected void die(EntityManager manager)
        {
            health.CurrentValue = 0;
            if (OnDeath != null)
            {
                OnDeath(this);
            }

            manager.Remove(this);
            return;
        }
예제 #13
0
파일: Entity.cs 프로젝트: Natman64/JamLib
        public virtual void Update(GameTime gameTime, EntityManager manager)
        {
            sprite.Update(gameTime);

            if (health.IsEmpty)
            {
                die(manager);
                return;
            }

            if (elapsedInv > 0)
            {
                elapsedInv -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                return;
            }

            if (collides)
            {
                foreach (string group in manager.Entities.Keys)
                {
                    if (collisionGroups.Contains(group))
                    {
                        foreach (Entity e in manager.Entities[group])
                        {
                            if (e.collides && sprite.IsPixelColliding(e.sprite))
                            {
                                if (OnCollision != null)
                                {
                                    OnCollision(e);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #14
0
파일: Entity.cs 프로젝트: Natman64/JamLib
        public virtual void Draw(SpriteBatch spriteBatch, EntityManager manager)
        {
            sprite.Draw(spriteBatch);

            if (health.MaxValue > 1)
                DrawBar(spriteBatch, health, Color.Red, manager);
        }
예제 #15
0
파일: Powerup.cs 프로젝트: Natman64/JamLib
        public override void Update(GameTime gameTime, EntityManager manager)
        {
            Sprite.Velocity = new Vector2(-speed, 0);

            base.Update(gameTime, manager);
        }