Пример #1
0
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
            player.Update(gameTime, this);
            loManager.Update(gameTime, this);
            popManager.Update(gameTime);
            cam.Position           = player.CenterBox;
            Globals.ScreenPosition = new Vector2(cam.Position.X - (Globals.ScreenWidth / 2), cam.Position.Y - (Globals.ScreenHeight / 2));

            if (!player.Exist)
            {
                ExitScreen();
            }
            var delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (Input.s > Input.sO)
            {
                cam.Zoom += (float)0.1;
                Console.WriteLine(cam.Zoom);
            }
            if (Input.s < Input.sO)
            {
                cam.Zoom -= (float)0.1;
                Console.WriteLine(cam.Zoom);
            }
            if (Input.KeyClick(Keys.Back))
            {
                cam.Reset();
            }
            Input.sO = Input.s;

            if (Input.KeyClick(Keys.Space))
            {
                items.Clear();
            }

            if (Input.KeyClick(Keys.Enter))
            {
                if (spawnEnemy)
                {
                    spawnEnemy = false;
                }
                else
                {
                    spawnEnemy = true;
                }
            }

            if (spawnEnemy)
            {
                delay += delta;
                if (delay > 3)
                {
                    loManager.AddEnemy(new Enemy(goblinSheet, ScreenManager.GraphicsDevice, player)
                    {
                        Position = new Vector2(player.Position.X + Rng.Noxt(-Globals.ScreenWidth / 2, Globals.ScreenWidth / 2), player.Position.Y + Rng.Noxt(-Globals.ScreenHeight / 2, Globals.ScreenHeight / 2))
                    });

                    delay -= 1;
                }
            }

            if (Input.KeyHold(Keys.NumPad1))
            {
                items.Add(new Usable(UsableType.HealthPot, itemSheet)
                {
                    Position = new Vector2(player.Position.X + Rng.Noxt(-Globals.ScreenWidth / 2, Globals.ScreenWidth / 2), player.Position.Y + Rng.Noxt(-Globals.ScreenHeight / 2, Globals.ScreenHeight / 2))
                });
            }
            if (Input.KeyHold(Keys.NumPad2))
            {
                items.Add(new Usable(UsableType.ManaPot, itemSheet)
                {
                    Position = new Vector2(player.Position.X + Rng.Noxt(-Globals.ScreenWidth / 2, Globals.ScreenWidth / 2), player.Position.Y + Rng.Noxt(-Globals.ScreenHeight / 2, Globals.ScreenHeight / 2))
                });
            }
            items.RemoveAll(i => !i.Exist);
            foreach (var i in items)
            {
                i.Update(gameTime);
                if (player.LootRadius.Intersects(i.Rectangle) && !player.inventory.IsFull && i.IsLootable)
                {
                    i.IsBeingLooted = true;
                }
                else if (player.inventory.IsFull)
                {
                    i.IsBeingLooted = false;
                }
                if (i.IsBeingLooted)
                {
                    i.VacuumLoot(gameTime, i, player.Position, player.inventory);
                }
                else
                {
                    if (i.Speed >= 0f)
                    {
                        i.Speed -= 400f * (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    if (i.Speed < 0)
                    {
                        i.Speed = 0f;
                    }
                }
            }
        }