Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     _gameObjectInfo = this.gameObject.GetComponent <customGameObject>();
     if (_gameObjectInfo)
     {
         _gameObjectInfo.validate();
     }
 }
Beispiel #2
0
    // based on the type of interaction component that the interactive object
    // has, the inventoryMgr will handle the add in a specific way
    public void Add(interactiveObj iObj)
    {
        objectInteraction oi = iObj.OnCloseEnough;

        switch (oi.interactionType)
        {
        case (objectInteraction.InteractionType.Unique):
        {
            // slot into first available spot
            insert(iObj);
        }
        break;

        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;
            }

            for (int i = 0; i < inventoryObjects.Count; i++)
            {
                //todo
                customGameObject cgoi = inventoryObjects[i].item.GetComponent <customGameObject>();
                customGameObject.CustomObjectType io = customGameObject.CustomObjectType.Invalid;
                if (cgoi != null)
                {
                    io = cgoi.objectType;
                }

                if (ot == io)
                {
                    inventoryObjects[i].quantity++;
                    // add token from this object to missionMgr to track, it this obj has a token
                    missionToken mt = iObj.gameObject.GetComponent <missionToken>();
                    if (mt != null)
                    {
                        _missionMgr.add(mt);
                    }

                    iObj.gameObject.SetActive(false);
                    inserted = true;
                    break;
                }
            }

            //
            //	if we get this far, it means no duplicate found in the inventory, so let's insert it
            //
            if (!inserted)
            {
                insert(iObj);
            }
        }
        break;
        }
    }