1
0
forked from s425077/PotatoPlan
PotatoPlan/Game1/Sources/Objects/InventorySystem/Cargo.cs

118 lines
2.9 KiB
C#
Raw Normal View History

2020-05-06 16:22:30 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Cargo
{
2020-05-24 01:57:27 +02:00
private Items[,] items = new Items[2, 281];
2020-05-06 16:22:30 +02:00
private int[] Count = new int[2];
// Creation of the house stock
public void initStorageItems()
{
// Name, Weight, Index
// Fertilizer Storage
items[0, 0] = new Items("10-26-26", 1, 0);
items[0, 1] = new Items("14-35-14", 1, 1);
items[0, 2] = new Items("17-17-17", 1, 2);
items[0, 3] = new Items("20-20", 1, 3);
items[0, 4] = new Items("28-28", 1, 4);
items[0, 5] = new Items("DAP", 1, 5);
items[0, 6] = new Items("Urea", 1, 6);
//Crop Seed Storage
2020-05-10 01:38:08 +02:00
items[1, 0] = new Items("Barley", 2, 0);
2020-05-06 16:22:30 +02:00
items[1, 1] = new Items("Cotton", 1, 1);
2020-05-10 01:38:08 +02:00
items[1, 2] = new Items("Ground Nuts", 5, 2);
items[1, 3] = new Items("Maize", 3, 3);
items[1, 4] = new Items("Millets", 4, 4);
items[1, 5] = new Items("Oil Seeds", 4, 5);
items[1, 6] = new Items("Paddy", 5, 6);
items[1, 7] = new Items("Pulses", 5, 7);
items[1, 8] = new Items("Sugarcane", 3, 8);
items[1, 9] = new Items("Tobacco", 2, 9);
items[1, 10] = new Items("Wheat", 2, 10);
2020-05-06 16:22:30 +02:00
}
public void addItem(Items item, int Type)
{
items[Type, Count[Type]] = item;
Count[Type]++;
}
public Items getItemByIndex(int i, int Type)
{
return items[Type, i];
}
public bool itemExists(int Index, int type)
{
if (Count[type] == 0)
{
return false;
}
int i = 0;
do
{
if (items[type, i].getIndex() == Index)
{
return true;
}
i++;
} while (items[type, i] != null && Count[type] > i);
return false;
}
public void removeItem(int Index, int type)
{
int i = 0;
if (itemExists(Index, type))
{
do
{
if (items[type, i].getIndex() == Index)
{
sortBackInPlace(i, type);
break;
}
i++;
} while (items[type, i] != null && Count[type] > i);
}
}
public void sortBackInPlace(int i, int type)
{
do
{
items[type, i] = items[type, i + 1];
i++;
} while (items[type, i] != null && Count[type] > i);
items[type, i] = null;
Count[type]--;
}
public int getCount(int Index, int Type)
{
int Count = 0;
int i = 0;
if (items[Type, 0] != null)
{
do
{
if (items[Type, i].getIndex() == Index)
{
Count++;
}
i++;
} while (items[Type, i] != null);
}
return Count;
}
}