Game Development Reference
In-Depth Information
interactive object. To determine this matching, we first store a reference to
the CustomGameObject script on the interactive object that is being inser-
ted. If this object does not have a CustomGameObject script, we assume
the type is Invalid , as shown in the following code:
case(ObjectInteraction.InteractionType.Accumulate):
{
bool inserted = false;
// find object of same type, and
increase
CustomGameObject cgo =
iObj.gameObject.GetComponent<CustomGameObject>();
CustomGameObject.CustomObjectType ot =
CustomGameObject.CustomObjectType.Invalid;
if (cgo != null)
ot = cgo.objectType;
7. The InventoryMgr class then loops over all inventory objects in the list. If
it finds an object that has a matching CustomGameObject type to the inter-
active object that is being inserted, it increases the quantity property on that
InventoryObj . If a match is not found, then InventoryObj is permitted
to be inserted in the list as if it were a unique item, as shown in the following
code:
for (int i = 0; i <
inventoryObjects.Count; i++)
{
CustomGameObject cgoi =
inventoryObjects[i].item.GetComponent
<CustomGameObject>();
CustomGameObject.CustomObjectType io =
CustomGameObject.CustomObjectType.Invalid;
if (cgoi != null)
io = cgoi.objectType;
Search WWH ::




Custom Search