Witam.
Utknąłem...
Piszę grę tekstową i mam problem z dodaniem itemka do plecaka (mianowicie brak pomysłu).
Itemki tworzę tak:
Klasa Item
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
namespace TekstWorld
{
public class Item
{
protected bool destroy = false;
protected string item_name;
protected int item_lvl;
protected int item_hand;
protected int durability;
protected int max_health_points;
protected int strenght;
protected int skill;
protected int ability_power;
protected int armor;
protected int min_damage;
protected int max_damage;
protected int crit_chances;
protected int dodge_chances;
protected int movement_speed;
protected int alchemist_skill;
public void Decrease_durability(int x)
{
this.durability -= x;
if (this.durability <= 0)
this.destroy = true;
}
public string Get_item_name(Item item)
{
return this.item_name;
}
}
}
Klasa dziedzicząca po klasie Item (przedmiot):
using System;
using System.Collections.Generic;
using System.Text;
namespace TekstWorld
{
class Old_knife : Item
{
public Old_knife()
{
this.item_name = "Stary nóż";
this.item_lvl = 1;
this.item_hand = 1;
this.skill = 2;
this.max_health_points = 5;
this.min_damage = 3;
this.max_damage = 15;
this.crit_chances = 5;
this.dodge_chances = 5;
this.strenght = 5;
this.durability = 5;
}
}
}
I teraz przyszedł czas na wręczenie graczowi przedmiotu. Stworzyłem tablicę o rozmiarze odpowiadającym zmiennej max_backpack_place i wypełniłem
for (int i = 0; i < Player.max_backpack_place; i++)
{
backpack_slots[i] = "<empty>";
}
Teraz fragmenty moich prób dodania przedmiotu do plecaka:
if (Player.player_class == "Złodziej")
{
foreach (var ch in "<Otrzymano>: Stara czapka złodzieja...\n<Otrzymano>: Stary nóż...\n<Otrzymano>: Stare spodnie złodzieja...")
{
Console.Write(ch);
Thread.Sleep(10);
}
equip.Add_to_backpack(new Old_thief_hat());
equip.Add_to_backpack(new Old_thief_pants());
equip.Add_to_backpack(new Old_knife());
}
Klasa Equip:
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Diagnostics;
namespace TekstWorld
{
public class Equip
{
static private Item item = new Item();
string[] backpack_slots = new string[Player.max_backpack_place];
public void Add_to_backpack(Item item)
{
for (int i = 0; i < Player.max_backpack_place; i++)
{
backpack_slots[i] = "<empty>";
}
}
public void Show_backpack()
{
foreach (var ch in "Ekwipunek: \n" +
"Pojemność plecaka: " + Player.max_backpack_place + " miejsc.\n")
{
Console.Write(ch);
Thread.Sleep(10);
}
}
}
}
Jakieś pomysły? Z góry dziękuje za każdy