Exemple #1
0
 // Get item from type
 public BackpackItem Get(BackpackItem.Type type, bool verbose = true)
 {
     if (backpackDictionary.ContainsKey(type))
     {
         return(backpackDictionary[type]);
     }
     if (verbose)
     {
         Debug.LogError("Arsenal : backpack dictionary doesn't contain item " + type.ToString());
     }
     return(null);
 }
Exemple #2
0
    // Get pickable item
    public GameObject GetPickable(BackpackItem.Type type, bool showName = false, bool destroyOnPick = true)
    {
        BackpackItem item = Get(type);

        if (!item)
        {
            return(null);
        }

        GameObject go = Instantiate(pickablePrefab.gameObject);

        go.name                    = type.ToString();
        go.transform.parent        = null;
        go.transform.position      = Vector3.zero;
        go.transform.localRotation = Quaternion.identity;
        go.transform.localScale    = Vector3.one;
        go.AddComponent <InteractionType>().type = InteractionType.Type.pickableBackpack;
        BackpackItem.Copy(item, go.AddComponent <BackpackItem>());
        go.SetActive(true);

        MeshFilter mf = item.gameObject.GetComponent <MeshFilter>();
        SpecialPickableShopArsenal pickable = go.GetComponent <SpecialPickableShopArsenal>();

        pickable.textmesh.text = go.name;
        if (go.name.Length >= 8)
        {
            pickable.textmesh.characterSize *= 0.5f;
        }
        if (mf)
        {
            pickable.itemMesh.mesh = mf.mesh;
        }
        else
        {
            pickable.itemMesh.gameObject.SetActive(false);
        }
        pickable.body.gameObject.SetActive(false);
        pickable.textmesh.gameObject.SetActive(showName);
        go.GetComponent <Item>().destroyOnPick = destroyOnPick;

        return(go);
    }