Exemplo n.º 1
0
        private void RenderTwoSimilarExits(SpriteBatch sb, RoomExit[] exits, Direction dir, Vector2 offset)
        {
            Texture2D bgtex = AssMan.Get(backgroundAsset);
            Rectangle lowRect, midRect, highRect;

            if (dir != Direction.S)
            {
                int x = dir == Direction.W ? 0 : bgtex.Width - EXITW;
                SwitchIf(exits, (a, b) => a.location.vec.Y > b.location.vec.Y);
                lowRect  = new Rectangle(x, WALLH, EXITW, (int)exits[0].location.vec.Y - (EXITH >> 1) - WALLH);
                midRect  = new Rectangle(x, lowRect.Y + lowRect.Height + EXITH, EXITW, (int)(exits[1].location.vec.Y - exits[0].location.vec.Y) - EXITH);
                highRect = new Rectangle(x, midRect.Y + midRect.Height + EXITH, EXITW, bgtex.Height - (midRect.Height + midRect.Y + EXITH));
            }
            else
            {
                SwitchIf(exits, (a, b) => a.location.vec.X > b.location.vec.X);
                lowRect  = new Rectangle(0, bgtex.Height - EXITW, (int)exits[0].location.vec.X - (EXITH >> 1), EXITW);
                midRect  = new Rectangle(lowRect.X + lowRect.Width + EXITH, lowRect.Y, (int)(exits[1].location.vec.X - exits[0].location.vec.X) - EXITH, EXITW);
                highRect = new Rectangle(midRect.X + midRect.Width + EXITH, midRect.Y, bgtex.Width - (midRect.Width + midRect.X + EXITH), EXITW);
            }
            lowRect  = Util.AddOffset(lowRect, backgroundOrigin);
            midRect  = Util.AddOffset(midRect, backgroundOrigin);
            highRect = Util.AddOffset(highRect, backgroundOrigin);

            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(lowRect, offset), Color.Black);
            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(midRect, offset), Color.Black);
            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(highRect, offset), Color.Black);
        }
Exemplo n.º 2
0
 public void Kill(string killObject)
 {
     killString = "Killed by " + killObject;
     alive      = false;
     this.state = PlayerState.Dead;
     AssMan.Get(SAsset.Death).Play();
 }
Exemplo n.º 3
0
 public void Eat()
 {
     state = PlayerState.Eating;
     AssMan.Get(SAsset.Crunch).Play();
     AssMan.Get(SAsset.Crunch).Play();
     SplashScreen.PeopleEaten++;
 }
Exemplo n.º 4
0
        public void Render(SpriteBatch sb, Vector2 offset, Player p)
        {
            bool renderedPlayer = false;

            sb.Draw(AssMan.Get(backgroundAsset), Util.AddOffset(offset, backgroundOrigin), Color.White);
            RenderExits(sb, offset);

            for (int i = 0; i < entities.Count; i++)
            {
                if (entities[i].BottomY() > PlayerBottomY(p) && !renderedPlayer)
                {
                    renderedPlayer = true;
                    p.Render(sb, Util.AddOffset(backgroundOrigin, (Util.AddOffset(offset, playerPosition))));
                }
                entities[i].Render(sb, Util.AddOffset(backgroundOrigin, offset));
            }
            if (!renderedPlayer)
            {
                p.Render(sb, Util.AddOffset(backgroundOrigin, (Util.AddOffset(offset, playerPosition))));
            }

            foreach (AfterTexture a in afterTextures)
            {
                a.Render(sb, Util.AddOffset(backgroundOrigin, offset));
            }

            foreach (Entity e in entities)
            {
                if (e.InRange(playerPosition))
                {
                    e.RenderActivityString(sb, Util.AddOffset(playerPosition, Util.AddOffset(backgroundOrigin, offset)));
                }
            }
        }
Exemplo n.º 5
0
        private void RenderNorthWall(SpriteBatch sb, Vector2 offset)
        {
            RoomExit[] exits     = ExitFilter((e) => e.location.dir == Direction.N && e.next != null);
            Texture2D  doorAsset = AssMan.Get(IAsset.Door1);

            for (int i = 0; i < exits.Length; i++)
            {
                sb.Draw(doorAsset, Util.AddOffset(backgroundOrigin, Util.AddOffset(offset, new Vector2(exits[i].location.vec.X - (doorAsset.Width >> 1), WALLH - doorAsset.Height))), Color.White);
            }
        }
Exemplo n.º 6
0
 public override void DoCollision(Screen s, Player p, Vector2 playerPos)
 {
     if (p.GetItem() == Item.Goat)
     {
         activityString = "Defenestrate";
         if (KVMA_Keyboard.ActionKey())
         {
             AssMan.Get(SAsset.Crunch).Play();
             canFire      = false;
             selectedAnim = 1;
         }
     }
 }
Exemplo n.º 7
0
 public override bool Update(List <Entity> entities, Player p, Vector2 playerPos)
 {
     if (armed && canFire)
     {
         if (Game1.rand.Next() % 40 == 0)
         {
             dir          = (Direction)(Game1.rand.Next() % 4);
             selectedAnim = (int)dir;
             entities.Add(new LaserBeam(dir, Util.AddOffset(Util.AddOffset(location, hitOffset), new Vector2(0, -58))));
             AssMan.Get(SAsset.Laser).Play();
         }
     }
     return(true);
 }
Exemplo n.º 8
0
        public void Render(SpriteBatch sb, Vector2 location)
        {
            ticks++;
            if (ticks > maxTicks)
            {
                currentAsset++;
                if (currentAsset == assets.Length)
                {
                    currentAsset = 0;
                }
                ticks = 0;
            }

            sb.Draw(AssMan.Get(assets[currentAsset]), location, null, Color.White, 0.0f, Vector2.Zero, 1.0f, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0.0f);
        }
Exemplo n.º 9
0
        private void RenderNoExits(SpriteBatch sb, Direction d, Vector2 offset)
        {
            Rectangle maskRect = new Rectangle(0, WALLH, EXITW, AssMan.Get(backgroundAsset).Height - WALLH);

            if (d == Direction.E)
            {
                maskRect.X = AssMan.Get(backgroundAsset).Width - EXITW;
            }
            else if (d == Direction.S)
            {
                maskRect = new Rectangle(0, AssMan.Get(backgroundAsset).Height - EXITW, AssMan.Get(backgroundAsset).Width, EXITW);
            }

            maskRect = Util.AddOffset(maskRect, backgroundOrigin);
            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(maskRect, offset), Color.Black);
        }
Exemplo n.º 10
0
        public LaserBeam(Direction dir, Vector2 location) :
            base(location)
        {
            this.dir     = dir;
            selectedAnim = (int)dir;
            anims        = new Animation[]
            {
                new Animation(new IAsset[]
                {
                    IAsset.Laser_North
                }, 5),
                new Animation(new IAsset[]
                {
                    IAsset.Laser_East
                }, 5),
                new Animation(new IAsset[]
                {
                    IAsset.Laser_South
                }, 5),
                new Animation(new IAsset[]
                {
                    IAsset.Laser_West
                }, 5),
            };

            switch (dir)
            {
            case Direction.N:
                location.Y  -= AssMan.Get(IAsset.Laser_North).Height;
                collisionBox = new Rectangle(0, 0, 9, 80); break;

            case Direction.E:
                location.X  -= AssMan.Get(IAsset.Laser_West).Width;
                collisionBox = new Rectangle(0, 0, 80, 9); break;

            case Direction.S:
                location.Y  += AssMan.Get(IAsset.Laser_North).Height;
                collisionBox = new Rectangle(0, 0, 9, 80); break;

            default:
                location.X  += AssMan.Get(IAsset.Laser_West).Width;
                collisionBox = new Rectangle(0, 0, 80, 9); break;
            }
        }
Exemplo n.º 11
0
        public override bool Update(List <Entity> entities, Player p, Vector2 playerPos)
        {
            location.Y += flySpeed;
            Rectangle scHitOff = Util.AddOffset(collisionBox, location);

            if (Game1.rand.Next() % 75 == 0)
            {
                AssMan.Get((Game1.rand.Next() % 3) + SAsset.Flap1).Play();
            }
            if (scHitOff.Intersects(Util.AddOffset(Util.AddOffset(p.GetRect(), playerPos), p.DrawOffset)))
            {
                p.Kill("Flying Book");
            }
            if (location.Y > Game1.SCREENH)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 12
0
 private void RenderStatusString(SpriteBatch sb)
 {
     if (statusStringLife > 0)
     {
         statusStringLife += 2;
         sb.DrawString(AssMan.victorianFont, RoomStatusString, new Vector2(0, 0), Color.White);
         if (statusStringLife < 255)
         {
             sb.Draw(AssMan.Get(IAsset.Mask), new Rectangle(0, 0, 200, 100), new Color(0, 0, 0, 255 - statusStringLife));
         }
         else
         {
             sb.Draw(AssMan.Get(IAsset.Mask), new Rectangle(0, 0, 200, 100), new Color(0, 0, 0, 255 - (512 - statusStringLife)));
         }
         if (statusStringLife >= 512)
         {
             statusStringLife = 0;
         }
     }
 }
Exemplo n.º 13
0
        private void RenderOneExit(SpriteBatch sb, RoomExit e, Direction d, Vector2 offset)
        {
            Texture2D bgtex    = AssMan.Get(backgroundAsset);
            Rectangle lowRect  = new Rectangle(0, WALLH, EXITW, (int)(e.location.vec.Y - (EXITH >> 1) - WALLH));
            Rectangle highRect = new Rectangle(0, lowRect.Y + lowRect.Height + EXITH, EXITW, bgtex.Height - (lowRect.Height + lowRect.Y + EXITH));

            if (d == Direction.E)
            {
                highRect.X = lowRect.X = bgtex.Width - EXITW;
            }
            else if (d == Direction.S)
            {
                lowRect  = new Rectangle(0, bgtex.Height - EXITW, (int)e.location.vec.X - (EXITH >> 1), EXITW);
                highRect = new Rectangle(lowRect.X + lowRect.Width + EXITH, lowRect.Y, bgtex.Width - (EXITH >> 1) - (int)e.location.vec.X, EXITW);
            }
            lowRect  = Util.AddOffset(lowRect, backgroundOrigin);
            highRect = Util.AddOffset(highRect, backgroundOrigin);

            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(lowRect, offset), Color.Black);
            sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(highRect, offset), Color.Black);
        }
Exemplo n.º 14
0
 public void Render(SpriteBatch sb, Vector2 location)
 {
     if (state == PlayerState.WalkEast ||
         state == PlayerState.WalkWest ||
         state == PlayerState.WalkNorth ||
         state == PlayerState.WalkSouth)
     {
         soundTicks++;
         if (soundTicks == animSpeed)
         {
             AssMan.Get(Game1.rand.Next() % 2 == 0 ? SAsset.Step1 : SAsset.Step2).Play();
             soundTicks = 0;
         }
     }
     anims[state].Render(sb, Util.AddOffset(DrawOffset, location));
     //sb.Draw(AssMan.Get(IAsset.Mask), Util.AddOffset(Util.AddOffset(GetRect(), location), DrawOffset), Color.Blue);
     sb.Draw(AssMan.Get(ItemIcon(heldItem)), new Vector2(100, 100), Color.White);
     if (!alive)
     {
         sb.DrawString(AssMan.victorianFont, killString, new Vector2(700, 400), Color.Red);
     }
 }
Exemplo n.º 15
0
 /// <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()
 {
     base.Initialize();
     AssMan.LoadStaticAssets(Content);
     PushScreen(new SplashScreen());
 }
Exemplo n.º 16
0
 public override void Render(SpriteBatch sb)
 {
     m.Render(sb, p);
     sb.Draw(AssMan.Get(bodyAsset), new Rectangle((int)(bodyStart.X + ((dayTicks * (bodyDest.X - bodyStart.X)) / (float)dayTickLength)), (int)bodyStart.Y, 64, 64),
             null, Color.White, (float)(dayTicks * (Math.PI / 16)), new Vector2(32, 32), SpriteEffects.None, 0.0f);
 }
Exemplo n.º 17
0
 public Rectangle GetRect()
 {
     return(new Rectangle(0, 0, AssMan.Get(IAsset.Player_Idle).Width, AssMan.Get(IAsset.Player_Idle).Height));
 }
Exemplo n.º 18
0
 public override void Render(SpriteBatch sb)
 {
     sb.Draw(AssMan.Get(IAsset.SplashScreen), Vector2.Zero, Color.White);
     sb.DrawString(AssMan.victorianFont, PeopleEaten + " Successes...", new Vector2(21, 21), Color.Black);
     sb.DrawString(AssMan.victorianFont, PeopleEaten + " Successes...", new Vector2(20, 20), Color.Red);
 }
Exemplo n.º 19
0
 public void Render(SpriteBatch sb, Vector2 offset)
 {
     sb.Draw(AssMan.Get(asset), Util.AddOffset(offset, vector), Color.White);
 }
Exemplo n.º 20
0
 public ChangeScreen(string txt)
 {
     this.txt = txt;
     AssMan.Get(SAsset.Mystery).Play();
 }
Exemplo n.º 21
0
        protected void SetBackgroundParams()
        {
            Texture2D bgtex = AssMan.Get(backgroundAsset);

            backgroundOrigin = new Vector2((Game1.SCREENW - bgtex.Width) >> 1, (Game1.SCREENH - bgtex.Height) >> 1);
        }
Exemplo n.º 22
0
 public bool OutOfBounds(Vector2 v)
 {
     return(!(v.X > EXITW && v.Y > WALLH && v.X < AssMan.Get(backgroundAsset).Width - EXITW && v.Y < AssMan.Get(backgroundAsset).Height - EXITW));
 }