public bool Equip(SecondItem.Type type, bool forceUpdate = false) { if (type == equipedItem.type && !forceUpdate) { return(true); } if (type != SecondItem.Type.None) { SecondItem newItem = Arsenal.Instance.Get(type); if (newItem) { MeshFilter mf = newItem.GetComponent <MeshFilter>(); if (mf) { equipedMesh.mesh = mf.mesh; SecondItem.Copy(newItem, equipedItem); return(true); } } } equipedItem.Clear(); equipedMesh.mesh = null; return(false); }
protected /* override*/ void OnCreate() { //base.OnCreate(); if (weapon) { mainWeapon = weapon.type; SecondaryWeapon = weapon.type2; } hp = MAX_HP; }
public SecondItem Get(SecondItem.Type type, bool verbose = true) { if (secondDictionary.ContainsKey(type)) { return(secondDictionary[type]); } if (verbose) { Debug.LogError("Arsenal : second hand dictionary doesn't contain item " + type.ToString()); } return(null); }
public GameObject GetPickable(SecondItem.Type type, bool showName = false, bool destroyOnPick = true) { SecondItem 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.pickableSecond; SecondItem.Copy(item, go.AddComponent <SecondItem>()); 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); }