ok i get that things i want to know heres the situation i understand how the script works but here i have my inventory script. If you see in my function start i add my object to the maininventory but i have my drops that spawn when a tree is cut with the anim and everything thing is how would i make my actual logs and branch and coconut and actual item out of the item script like i know i can manipulate my class by calling it with class.variablename if im right but yeah id like to know a bit more about this or information about it.
i know i would have to add more item types and everythings like i said i know how the script work just that part is greyish :S
would i have to basicly make a function inside my inventory like item pickup and then make it if i go over the colider tagged item lets say with another colider tag player then add to inventory ?
import System.Collections.Generic;
//holding all items
var items : Item[];
//inventory
var MainInventory : List.<Item> = new List.<Item>();
//Equip menu 0 = helm 1=shoulder 2=gloves 3=pants 4=boots 5=ring 6=neckless
var EquipMenu : Item[];
//Stats
var Power : int = 0;
function Start()
{
MainInventory.Add(items[0]);
MainInventory.Add(items[1]);
MainInventory.Add(items[2]);
EquipMenu[0] = null;
}
function OnGUI()
{
for(var x = 0; x < MainInventory.Count; x++)
{
if(GUI.Button(Rect(Screen.width/2, Screen.height/2 + (20 * x), 100, 20),GUIContent ( MainInventory[x].Name,
"Stamina: " + MainInventory[x].Stamina + "
" +
"Power: " + MainInventory.Power + "
" +
"Attack Speed: " + MainInventory.attackSpeed + "
" +
"Rarity: " + MainInventory.rarity + "
" )))
{
if(MainInventory.itemType == MainInventory.itemType.helm)
{
if(EquipMenu[0] != null)
{
MainInventory.Add(EquipMenu[0]);
}
EquipMenu[0] = null;
EquipMenu[0] = MainInventory;
Power += EquipMenu[0].Power;
MainInventory.RemoveAt(x);
Debug.Log(Power);
}
else if(MainInventory[x].itemType == MainInventory[x].itemType.shoulders)
{
EquipMenu[1] = MainInventory[x];
MainInventory.RemoveAt(x);
}
}
GUI.Label(Rect(Screen.width/2 + 150, Screen.height/2 + (20 * x), 300, 300), GUI.tooltip);
var p : int = 0;
if(MainInventory[x].itemType == MainInventory[x].itemType.helm)
{
p = 0;
}
var tooltip2 =
"Stamina: " + EquipMenu[p].Stamina + "
" +
"Power: " + EquipMenu[p].Power + "
" +
“Attack Speed: " + EquipMenu[p].attackSpeed + "
" +
“Rarity: " + EquipMenu[p].rarity;
//second tooltip to compare to equipped item
if(GUI.tooltip != “”)
{
GUI.Box(new Rect(Screen.width/2 + 350, Screen.height/2 + (20 * x), 200, 300),””);
GUI.Label(new Rect(Screen.width/2 +350, Screen.height/2 + (20 * x), 300, 300), tooltip2);
}
}
for(var y = 0; y < EquipMenu.length; y++)
{
if(EquipMenu[y] != null)
{
if(GUI.Button(Rect(Screen.width/2 - 150, Screen.height/2 + (20 * y), 100, 20)," " + EquipMenu[y].Name))
{
if(EquipMenu[y] != null)
{
MainInventory.Add(EquipMenu[y]);
Power -= EquipMenu[y].Power;
EquipMenu[y] = null;
}
}
}
}
}