public static void Render(this Scene scene)
        {
            if (_bmp == null || _bmp.Size != MainForm.instance.pictureBox.Size)
            {
                _bmp   = new Bitmap(scene.Size.X * modifier + modifier * 2, scene.Size.Y * modifier + modifier * 2);
                _graph = Graphics.FromImage(_bmp);
            }

            _graph.Clear(Color.DarkRed);

            foreach (var gameObject in scene.Childrens)
            {
                (gameObject as GameObject).Render();
            }

            MainForm.instance.pictureBox.Image = _bmp;

            if (Player.instance.SelectedObject != null)
            {
                _graph.DrawRectangle(new Pen(Color.Yellow, modifier / 10), Player.instance.SelectedObject.GetRectangle());
            }
            else
            {
                ScreenUpdater.OnUnselected();
            }
        }
Esempio n. 2
0
        public override void Use()
        {
            Player.instance.Hunger = (Player.instance.Hunger + HungerRecovery).Normalize(Player.instance.MaxHunger);
            Player.instance.Inventory.Remove(this);

            ScreenUpdater.OnHungerChanged();
            ScreenUpdater.OnInventoryChanged();
        }
Esempio n. 3
0
        public static void ApplyDamage(int damage)
        {
            instance.HealthPoints -= damage;
            ScreenUpdater.OnHealthChanged();

            if (instance.HealthPoints <= 0)
            {
                Die();
            }
        }
Esempio n. 4
0
 public static void SpendHunger()
 {
     if (instance.Hunger > 0)
     {
         instance.Hunger--;
         ScreenUpdater.OnHungerChanged();
     }
     else
     {
         ApplyDamage(1);
     }
 }
Esempio n. 5
0
        public static void Create()
        {
            _instance = new InventoryPanel();
            MainForm.instance.pictureBox.Controls.Add(_instance);
            _instance.Show();
            IsShowed = true;

            MainForm.GameState = GameStates.Inventory;
            if (Player.instance.Inventory.Count > 0)
            {
                (_instance.Controls[_selectedItem] as ItemButton).Select();
            }

            ScreenUpdater.OnUnselected();
        }
Esempio n. 6
0
        public static void CheckSelectableItems()
        {
            instance.SelectedObject = (GameObject)Game.instance.ActiveScene.Childrens
                                      .FirstOrDefault(
                u =>
                (u as GameObject).Position.Distance(instance.Position) < 1.5 &&
                u is IUsable &&
                !(u as IUsable).Used
                );

            if (instance.SelectedObject != null)
            {
                ScreenUpdater.OnSelected(instance.SelectedObject);
            }
            else
            {
                ScreenUpdater.OnUnselected();
            }
        }
Esempio n. 7
0
        public static void ApplyExpierence(int expierence)
        {
            instance.Expierence += expierence;

            if (instance.Expierence >= GetMaxExp())
            {
                if (instance.Level < instance.MaxLevel)
                {
                    instance.Expierence %= GetMaxExp();
                    instance.Level++;
                }
                else
                {
                    instance.Expierence = GetMaxExp() - 1;
                }
            }

            ScreenUpdater.OnLevelExpChanged();
        }
Esempio n. 8
0
        private static void AddPlayer(this Scene scene)
        {
            if (Door.SelectedDoor == -1)
            {
                Player.instance = new Player()
                {
                    Position = new Point(scene.Size.X / 2 + 1, scene.Size.Y / 2 + 1)
                };

                scene.Childrens.Add(Player.instance);

                ScreenUpdater.UpdateAllStats();
            }
            else
            {
                if (!scene.Childrens.Contains(Player.instance))
                {
                    scene.Childrens.Add(Player.instance);
                }

                Player.SetToDoor();
            }
        }