// ----- private methods public void OpenDoor(Player player, HUD hud, Inventory inventory) { int[] stock = inventory.ItemStock(); /*for (int i = 0; i < Global.globalAccess.itemIDs.Count; i++) * { * if (this._avatar == Global.globalAccess.ItemValues.avatars[i]) * { * string ID = i.ToString(); * if (stock[i] > 0) * { * * inventory.DecreaseStock(i); * hud.Draw(); // updates visible inventory * aliveInWorld = false; * hud.DisplayText($"< {player.Name()} {Global.ITEM_TEXTSUCCESS(ID)} >", false); * _opened = true; * } * else * { * hud.DisplayText($"< { player.Name()} {Global.ITEM_TEXTFAILURE(ID)} >", false); * } * } * }*/ if (this._avatar == 'd') { if (stock[(int)ITEM.KEYSMALL] > 0) { inventory.DecreaseStock(ITEM.KEYSMALL); hud.Draw(); // updates visible inventory aliveInWorld = false; hud.DisplayText($"< {player.Name()} {Global.MESSAGE_DOORSMALLOPEN} >", false); _opened = true; } else { hud.DisplayText($"< { player.Name()} {Global.MESSAGE_DOORSMALLLOCKED} >", false); } } if (this._avatar == 'D') { if (stock[(int)ITEM.KEYBIG] > 0) { inventory.DecreaseStock(ITEM.KEYBIG); hud.Draw(); // updates visible inventory aliveInWorld = false; hud.DisplayText($"< {player.Name()} {Global.MESSAGE_DOORBIGOPEN} >", false); _opened = true; } else { hud.DisplayText($"< {player.Name()} {Global.MESSAGE_DOORBIGLOCKED} >"); } } }
protected private void KillCharacter(string name, Camera camera, HUD hud) // kills character and displays that to HUD holds gameComepletionMessage { aliveInWorld = false; //show dead Charcter _avatar = Global.CHARACTER_DEADAVATAR; Draw(camera); //immediately update sprite //draw death to HUD string deathMessage = $"< {name} {Global.MESSAGE_SLAIN} >"; hud.DisplayText(deathMessage); }
private static GAMESTATE GameOverWinCondition(Player player, HUD hud, GAMESTATE gameState) // checks if win condition is met and sets game over { /// current win condition, reach the goal point if (player.X() == Global.PLAYER_WINPOINT[0]) { if (player.Y() == Global.PLAYER_WINPOINT[1]) { string victoryMessage; victoryMessage = $"< {Global.MESSAGE_PLAYERVICTORY} > "; hud.DisplayText(victoryMessage); gameState = GAMESTATE.GAMEOVER; } } return(gameState); }
public void HealShell(int value, Inventory inventory, HUD hud)// restores shield and values to limits if broken { int[] shield = Shield(); // bug temporarly patched shield used to heal 50 points instead of desired 30.... if (inventory.buffedShellHeal <= 0) { shield[(int)STATUS.CURRENT] += (value - 20); hud.DisplayText($"< {Name()} {Global.MESSAGE_POTSHIELDMISSING} [+" + (value - 20) + "] >", false); } else { shield[(int)STATUS.CURRENT] += (value - 20) * effectMultiplier; inventory.buffedShellHeal--; hud.DisplayText($"< {Name()} {Global.MESSAGE_POTSHIELDDRINK} [+" + (value - 20) + " X" + effectMultiplier + "] >", false); } shield[(int)STATUS.CURRENT] = SetStatToLimits(shield[(int)STATUS.CURRENT], shield[(int)STATUS.MAX]); }
// ----- Public Methods public void HealHealth(int value, Inventory inventory, HUD hud)// restores health and values to limits if broken { int[] health = Health(); //different messages for buffed items, if there are no buffed items, then regular message is displayed if (inventory.buffedHealthPotions <= 0) { health[(int)STATUS.CURRENT] += value; hud.DisplayText($"< {Name()} {Global.MESSAGE_POTHEALTHMISSING} [+" + value + "] >", false); } else { health[(int)STATUS.CURRENT] += value * effectMultiplier; inventory.buffedHealthPotions--; hud.DisplayText($"< {Name()} {Global.MESSAGE_POTHEALTHDRINK} [+" + value + " X" + effectMultiplier + "] >", false); } health[(int)STATUS.CURRENT] = SetStatToLimits(health[(int)STATUS.CURRENT], health[(int)STATUS.MAX]); }
// ----- public methods public void DisplayDamageToHUD(string name, int attackDamage, int[] health, HUD hud, bool isEnemy) // translates damage done into parsable message and displays it in the HUD { // holds its own message due to complexity in display not much vaiation visible = no desire to modulate health[(int)STATUS.CURRENT] = SetStatToLimits(health[(int)STATUS.CURRENT], health[(int)STATUS.MAX]); string damageMessage = $"< {name} taking {attackDamage} points of Damage "; if (isEnemy) { damageMessage += $"[{health[(int)STATUS.CURRENT]}/{health[(int)STATUS.MAX]}] >"; } else { damageMessage += $">"; } hud.DisplayText(damageMessage, false); }
public void UseShieldPot(Player player, Item item, HUD hud) { if (stockItems[(int)ITEM.POTSHELL] > 0) { DecreaseStock(ITEM.POTSHELL); player.HealShell(item.Power(Global.ITEM_AVATAR(ITEM.POTSHELL)), this, hud); //update HUD bar and display to HUD text box hud.setHudHealthAndShield(player.Health(), player.Shield()); hud.Draw();// updates visible inventory hud.UpdateHotBar(player, this); } else { hud.DisplayText($"< {player.Name()} {Global.MESSAGE_POTSHIELDMISSING} >", false); } }
public GAMESTATE Update(Player player, GAMESTATE gameState, Item item, Inventory inventory) { hud.Update(player, inventory); Fight(player, opponent, item, inventory); // ends fight if (player.Health()[(int)STATUS.CURRENT] == 0) { return(GameOver()); } if (opponent.Health()[(int)STATUS.CURRENT] == 0) { opponent.CheckForDying(camera, hud); hud.DisplayText($"< " + player.Name() + " has picked up $" + opponent.currentMoney + " that the " + opponent.Name() + " dropped! >"); player.currentMoney = player.currentMoney + opponent.currentMoney; return(End()); } return(gameState); }
public void PickupFoundItems(Player player, List <Item> items, HUD hud) { for (int i = 0; i < items.Count; i++) { if (items[i].PickedUpByPlayer()) { //switch statement changed to if else to accept Global parameter /*for (int j = 0; j < Global.globalAccess.itemIDs.Count; j++) * { * string ID = j.ToString(); * if (items[i].Avatar() == Global.ITEM_AVATAR(ID)) * { * IncreaseStock(ID); * } * }*/ if (items[i].Avatar() == Global.ITEM_AVATAR(ITEM.POTHEAL)) { IncreaseStock(ITEM.POTHEAL); } else if (items[i].Avatar() == Global.ITEM_AVATAR(ITEM.POTSHELL)) { IncreaseStock(ITEM.POTSHELL); } else if (items[i].Avatar() == Global.ITEM_AVATAR(ITEM.KEYBIG)) { IncreaseStock(ITEM.KEYBIG); } else if (items[i].Avatar() == Global.ITEM_AVATAR(ITEM.KEYSMALL)) { IncreaseStock(ITEM.KEYSMALL); } hud.UpdateHotBar(player, this); hud.Draw(); hud.DisplayText($"< {player.Name()} picked up {items[i].Name()} [{items[i].Avatar()}] >", false); items[i].PickedUpByPlayer(false); // removes the items ability to be picked up /this completes the process of putting the item in the invetory, otherwise pick up every item set to pickedup every time player picks up new item } } }
private void UseInvetoryOutput(Player player, Item item, TradeMenu tradeMenu) // SpaceBar Input / HOLDS OBJECT USE SLOTS / { Weapon weapon = player.EquipedWeapon(); if (menuInput.Key == ConsoleKey.Spacebar) { //item slots // max 20 /*for (int i = 0; i < this.itemPos.GetLength(0); i++) * { * if (cursorPos == i) * { * for (int j = 0; j < Global.globalAccess.itemIDs.Count; j++) * { * string ID = j.ToString(); * if (item.Avatar() == Global.globalAccess.ItemValues.avatars[j]) * { * if (Global.globalAccess.ItemValues.effects[i] == "none" || Global.globalAccess.ItemValues.effects[i] == null) // should be enum * { * hud.DisplayText($"< this item is insignificant >", false); * } * else if (Regex.IsMatch(Global.globalAccess.ItemValues.desc[i], @"^[a-zA-Z]+$")) #region regex explaination * /// ^ start of the string * /// [] character set * /// \ one time * /// + continious * /// $ end of the string #endregion * { * if (cursorPos == i) { hud.DisplayText($" \"{Global.globalAccess.ItemValues.desc[i]}\"", false); } * else { hud.DisplayText($"< i can't seem to remember what this is >", false); } * * if (Global.globalAccess.ItemValues.powers[i] > 0) * { * UsePot(player, item, hud, Global.globalAccess.ItemValues.effects[i]); * } * else { hud.DisplayText($"< it has no effect >", false); } * } * else * { } * } * } * } * } */ if (cursorPos == 1) { UseHealthPot(player, item, hud); } else if (cursorPos == 2) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 3) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 4) { hud.DisplayText(" \"A Big Key, for Big Problems, I mean Big Doors\"", false); } else if (cursorPos == 5) { hud.DisplayText(" \"A Small Key, it looks generic, I bet it would fit most locks\"", false); } else if (cursorPos == 6) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 7) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 8) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 9) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 10) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 11) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 12) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 13) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 14) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 15) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 16) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 17) { hud.DisplayText($"< empty >", false); } else if (cursorPos == 18) { hud.DisplayText($"< empty >", false); } else { hud.DisplayText($"< empty >", false); } //weapon slots for (int i = 0; i < Global.globalAccess.weaponIDs.Count; i++) { string ID = i.ToString(); if (cursorPos == 20 + i && stockWeapons[Global.globalAccess.weaponIDs[ID]]) { player.damageMultiplier = tradeMenu.kaliburnDamageMultiplier; player.EquipWeapon(ID); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } else { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } } /*else if (navigator == 20 && _stockWeapons[(int)WEAPON.FISTS]) { player.EquipWeapon(WEAPON.FISTS); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else if (navigator == 21 && _stockWeapons[(int)WEAPON.DAGGER]) { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } else { player.damageMultiplier = tradeMenu.daggerDamageMultiplier; player.EquipWeapon(WEAPON.DAGGER); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else if (navigator == 22 && _stockWeapons[(int)WEAPON.SHORTSWORD]) { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } else { player.damageMultiplier = tradeMenu.shortswordDamageMultiplier; player.EquipWeapon(WEAPON.SHORTSWORD); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else if (navigator == 23 && _stockWeapons[(int)WEAPON.BROADSWORD]) { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } else { player.damageMultiplier = tradeMenu.broadswordDamageMultplier; player.EquipWeapon(WEAPON.BROADSWORD); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else if (navigator == 24 && _stockWeapons[(int)WEAPON.LONGSWORD]) { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } else { player.damageMultiplier = tradeMenu.longswordDamageMultplier; player.EquipWeapon(WEAPON.LONGSWORD); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else if (navigator == 25 && _stockWeapons[(int)WEAPON.CLAYMORE]) { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); } else { player.damageMultiplier = tradeMenu.claymoreDamageMultiplier; player.EquipWeapon(WEAPON.CLAYMORE); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * if (navigator == 26 && _stockWeapons[(int)WEAPON.KALIBURN]) { player.damageMultiplier = tradeMenu.kaliburnDamageMultiplier; player.EquipWeapon(WEAPON.KALIBURN); hud.DisplayText($"< {player.Name()} Equiped {weapon.Name()} >", false); } * else { hud.DisplayText($"< {player.Name()} Equiped nothing... >", false); }*/ hud.UpdateHotBar(player, this); // update hotbar on inventory use } }
private void GameOverMessage() { hud.DisplayText(Global.MESSAGE_GAMEOVER); }
public GAMESTATE Update(List <Enemy> enemies, List <Door> doors, List <Item> item, Map map, Camera camera, HUD hud, Battle battle, Inventory inventory, GAMESTATE gameState, List <Vendor> vendors, TradeMenu tradeMenu) { if (aliveInWorld) { CheckForDying(camera, hud); // gets Input GetInput(); // "Looks at" selected direction DirectionalOutput(); // used in place of Directional, Opens inventory (and debug battle if not disabled) gameState = OpenInventoryOutput(inventory, gameState, battle, enemies[0]); // battle and enemies used for debug // used in place of Directional, only Healing items currently gameState = UseItemOutput(item[0], hud, inventory, gameState);// item is passed in blank because it's recognized inside the method this is for typing and can probably be done better //check everything for collision bool collision = false; //Enemy Collision / Attacking for (int i = 0; i < enemies.Count; i++) { if (CheckForCharacterCollision(enemies[i].X(), enemies[i].Y(), enemies[i].AliveInWorld())) // enemy values read as zero on firstcontact, needs enemy locate to read adjesent tile's { //access weapons damage //collide collision = true; //collide to deal damage gameState = StartAttacking(enemies[i].AliveInWorld(), battle, this, enemies[i], gameState, inventory); } } for (int i = 0; i < vendors.Count; i++) { if (CheckForCharacterCollision(vendors[i].X(), vendors[i].Y(), vendors[i].AliveInWorld())) // enemy values read as zero on firstcontact, needs enemy locate to read adjesent tile's { //access weapons damage //collide //collision = true; hud.Draw(); hud.DisplayText($"< This is a Vendor, Press 'T' to Trade >", false); //if player hits "T" when colliding with a vendor it will start a trade between the two.... if (_playerInput.Key == ConsoleKey.T) { gameState = StartTrading(vendors[i].AliveInWorld(), tradeMenu, this, vendors[i], gameState, inventory); } } } //Door Collision / Unlocking for (int i = 0; i < doors.Count; i++) { if (CheckForCharacterCollision(doors[i].X(), doors[i].Y(), doors[i].AliveInWorld())) { // Use Key or not doors[i].OpenDoor(this, hud, inventory); //collide collision = true; } } //toolkit.DisplayText($"checking at: {map.getTile(_XYHolder[0], _XYHolder[1])}"); // --------- debugg if (!CheckForWallCollision(map.getTile(_XYHolder[0], _XYHolder[1] - 1), map.getWallHold())) { if (!collision) { Move(); } } } return(gameState); }
private void BuyOrSellWeapon(int weapon, Inventory inventory, Player player) { // this is for when you choose an weapon to buy or sell, items chosen will check things like your amount of money for buying and, check your items for selling....... //if you have no items to sell, the deal is cancle as well as if you have not enough money to buy tradeBuff = 0; Draw(); Console.SetCursorPosition(10, 5); Console.WriteLine("Are you buying or selling....."); Console.SetCursorPosition(10, 7); Console.WriteLine("1 - Buy -$" + tradePrice); Console.SetCursorPosition(10, 9); Console.WriteLine("2 - Sell +$" + tradePrice); Console.SetCursorPosition(10, 11); Console.WriteLine("3 - Cancel"); ConsoleKeyInfo tradeDecision = Console.ReadKey(true); Draw(); Console.SetCursorPosition(10, 5); Console.WriteLine("Press any button to continue....."); if (tradeDecision.Key == ConsoleKey.D1) { //always equips fist when wepon is boughten or sold to prevent weapon being in still in hand when sold bug player.EquipWeapon("0"); // 0 should be the default weapon for (int i = 0; i < Global.globalAccess.weaponIDs.Count; i++) { string ID = i.ToString(); if (weapon == i) { if (inventory.StockWeapons[i] == true) { hud.DisplayText($"< " + player.Name() + " already owns a " + Global.WEAPON_NAME(ID) + " >", false); } else { CompleteWeaponTransaction(Global.globalAccess.weaponIDs[ID], player, inventory); } } } /*else if (weapon == WEAPON.SHORTSWORD) { if (inventory.shortswordOwned == true) {hud.DisplayText($"< " + player.Name() + " already owns a " + Global.WEAPON_NAME(WEAPON.SHORTSWORD) + " >", false); } else { CompleteWeaponTransaction(WEAPON.SHORTSWORD, player, inventory); } } * else if (weapon == WEAPON.BROADSWORD) { if (inventory.broadswordOwned == true) {hud.DisplayText($"< You already own a " + Global.WEAPON_NAME(WEAPON.BROADSWORD) + " >", false); } else { CompleteWeaponTransaction(WEAPON.BROADSWORD, player, inventory); } } * else if (weapon == WEAPON.LONGSWORD) { if (inventory.longswordOwned == true) {hud.DisplayText($"< You already own a " + Global.WEAPON_NAME(WEAPON.LONGSWORD) + " >", false); } else { CompleteWeaponTransaction(WEAPON.LONGSWORD, player, inventory); } } * else if (weapon == WEAPON.CLAYMORE) { if (inventory.claymoreOwned == true) {hud.DisplayText($"< You already own a " + Global.WEAPON_NAME(WEAPON.CLAYMORE) + " >", false); } else { CompleteWeaponTransaction(WEAPON.CLAYMORE, player, inventory); } } * else if (weapon == WEAPON.KALIBURN) { if (inventory.kaliburnOwned == true) {hud.DisplayText($"< You already own a " + Global.WEAPON_NAME(WEAPON.KALIBURN) + " >", false); } else { CompleteWeaponTransaction(WEAPON.KALIBURN, player, inventory); } }*/ } if (tradeDecision.Key == ConsoleKey.D2) { player.EquipWeapon("0"); for (int i = 0; i < Global.globalAccess.weaponIDs.Count; i++) { string ID = i.ToString(); if (weapon == i) { if (inventory.StockWeapons[i] == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(ID) + " to sell! >", false); } else { daggerDamageMultiplier = 0; inventory.StockWeapons[i] = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(ID) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } } } /*if (weapon == WEAPON.DAGGER) { if (inventory.daggerOwned == false) {hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.DAGGER) + " to sell! >", false); } else { daggerDamageMultiplier = 0; inventory.daggerOwned = false; hud.DisplayText($"< " + player.Name() +" sold a " + Global.WEAPON_NAME(WEAPON.DAGGER) +" >", false); player.currentMoney = player.currentMoney + tradePrice; } } * else if (weapon == WEAPON.SHORTSWORD) { if (inventory.shortswordOwned == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.SHORTSWORD) + " to sell! >", false); } else { shortswordDamageMultiplier = 0; inventory.shortswordOwned = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(WEAPON.SHORTSWORD) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } } * else if (weapon == WEAPON.BROADSWORD) { if (inventory.broadswordOwned == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.BROADSWORD) + " to sell! >", false); } else { broadswordDamageMultplier = 0; inventory.broadswordOwned = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(WEAPON.BROADSWORD) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } } * else if (weapon == WEAPON.LONGSWORD) { if (inventory.longswordOwned == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.LONGSWORD) + " to sell! >", false); } else { longswordDamageMultplier = 0; inventory.longswordOwned = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(WEAPON.LONGSWORD) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } } * else if (weapon == WEAPON.CLAYMORE) { if (inventory.claymoreOwned == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.CLAYMORE) + " to sell! >", false); } else { claymoreDamageMultiplier = 0; inventory.claymoreOwned = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(WEAPON.CLAYMORE) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } } * else if (weapon == WEAPON.KALIBURN) { if (inventory.kaliburnOwned == false) { hud.DisplayText($"< " + player.Name() + " does not own a " + Global.WEAPON_NAME(WEAPON.KALIBURN) + " to sell! >", false); } else { kaliburnDamageMultiplier = 0; inventory.kaliburnOwned = false; hud.DisplayText($"< " + player.Name() + " sold a " + Global.WEAPON_NAME(WEAPON.KALIBURN) + " >", false); player.currentMoney = player.currentMoney + tradePrice; } }*/ } }