Beispiel #1
0
    public bool Equip(ShieldItem.Type type, bool forceUpdate = false)
    {
        if (type == equipedItem.type && !forceUpdate)
        {
            return(true);
        }

        if (type != ShieldItem.Type.None)
        {
            ShieldItem newItem = Arsenal.Instance.Get(type);
            if (newItem)
            {
                MeshFilter mf = newItem.GetComponent <MeshFilter>();
                if (mf)
                {
                    equipedMesh.mesh = mf.mesh;
                    ShieldItem.Copy(newItem, equipedItem);
                    return(true);
                }
            }
        }
        equipedItem.Clear();
        equipedMesh.mesh = null;
        return(false);
    }
Beispiel #2
0
 public ShieldItem Get(ShieldItem.Type type, bool verbose = true)
 {
     if (shieldDictionary.ContainsKey(type))
     {
         return(shieldDictionary[type]);
     }
     if (verbose)
     {
         Debug.LogError("Arsenal : shield dictionary doesn't contain item " + type.ToString());
     }
     return(null);
 }
Beispiel #3
0
    public GameObject GetPickable(ShieldItem.Type type, bool showName = false, bool destroyOnPick = true)
    {
        ShieldItem 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.pickableShield;
        ShieldItem.Copy(item, go.AddComponent <ShieldItem>());
        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);
    }