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(); } }
public override void Use() { Player.instance.Hunger = (Player.instance.Hunger + HungerRecovery).Normalize(Player.instance.MaxHunger); Player.instance.Inventory.Remove(this); ScreenUpdater.OnHungerChanged(); ScreenUpdater.OnInventoryChanged(); }
public static void ApplyDamage(int damage) { instance.HealthPoints -= damage; ScreenUpdater.OnHealthChanged(); if (instance.HealthPoints <= 0) { Die(); } }
public static void SpendHunger() { if (instance.Hunger > 0) { instance.Hunger--; ScreenUpdater.OnHungerChanged(); } else { ApplyDamage(1); } }
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(); }
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(); } }
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(); }
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(); } }