private void UpdateMinimap() { for (int i = 0; i < MinimapGrid.Rows.Count; i++) { for (int j = 0; j < MinimapGrid.ColumnCount; j++) { var checkCell = MinimapGrid.Rows[i].Cells[j]; checkCell.Style.BackColor = System.Drawing.Color.White; checkCell.Value = ""; ILocation loc = ListLocations.GetLocAt(_player.PosX - (i - 2), (j - 2) + _player.PosY); if (loc != null) { if (loc.Revealed) { checkCell.Value = loc.Name; } else { if (loc.Discovered) { checkCell.Value = "???"; checkCell.Style.BackColor = System.Drawing.Color.White; } else { checkCell.Value = ""; checkCell.Style.BackColor = System.Drawing.Color.Black; } } } else { checkCell.Value = ""; checkCell.Style.BackColor = System.Drawing.Color.Black; } } } MinimapGrid.Rows[2].Cells[2].Value = _player.PlayerLocation.Name; MinimapGrid.Rows[2].Cells[2].Selected = true; }
private void MoveTo(char dir) { ILocation loc = _player.PlayerLocation; if (!_player.Dead) { if (!_player.Combat) { switch (dir) { case 'n': if (ListLocations.GetLocAt(_player.PosX + 1, _player.PosY) != null) { _player.PosX++; } break; case 'e': if (ListLocations.GetLocAt(_player.PosX, _player.PosY + 1) != null) { _player.PosY++; } break; case 's': if (ListLocations.GetLocAt(_player.PosX - 1, _player.PosY) != null) { _player.PosX--; } break; case 'w': if (ListLocations.GetLocAt(_player.PosX, _player.PosY - 1) != null) { _player.PosY--; } break; default: break; } _player.PlayerLocation = ListLocations.GetLocAt(_player.PosX, _player.PosY); if (_player.PlayerLocation.MonsterHere != null) { _player.PlayerLocation.SpawnedMonster = new Monster(_player.PlayerLocation.MonsterHere); } infoBox.Text = Utils.LocInfoWriter(_player); } else { infoBox.Text = "You can't run while fighting a monster!\n\n" + "You see a " + loc.MonsterHere.Name + " " + "(" + loc.SpawnedMonster.HpCur + "/" + loc.MonsterHere.HpMax + " HP)."; } } UpdateInventory(); _player.PlayerLocation.Revealed = true; #region set adjacent locations to discovered try { ListLocations.GetLocAt(_player.PosX, _player.PosY + 1).Discovered = true; } catch { } try { ListLocations.GetLocAt(_player.PosX, _player.PosY - 1).Discovered = true; } catch { } try { ListLocations.GetLocAt(_player.PosX + 1, _player.PosY).Discovered = true; } catch { } try { ListLocations.GetLocAt(_player.PosX - 1, _player.PosY).Discovered = true; } catch { } #endregion UpdateMinimap(); }