public void Point(int face) { Vector3 v = new Vector3(0.9f, 0.9f, 0.9f); v[tip] = 1.0f; for (int i = 0; i < faces[face].Count; i++) { changeVertices[faces[face][i]] = Vector3.Scale(changeVertices[faces[face][i]], v); } mesh.vertices = changeVertices; UpdateMesh(); IngotProperties data = GetComponent <IngotProperties>(); data.UpdatePointedness(face); }
public void Sharpen(int face, int axis, bool pos) { Vector3 v = new Vector3(1, 1, 1); v[axis] = 0.9f; for (int i = 0; i < faces[face].Count; i++) { if ((changeVertices[faces[face][i]][axis] > 0 && pos) || (changeVertices[faces[face][i]][axis] < 0 && !pos)) { changeVertices[faces[face][i]] = Vector3.Scale(changeVertices[faces[face][i]], v); } } mesh.vertices = changeVertices; UpdateMesh(); int side = pos ? 1 : 0; IngotProperties data = GetComponent <IngotProperties>(); data.UpdateSharpness(face, side); }
public GameObject Craft(IngotProperties properties) { Blade.Constraint temp = new Blade.Constraint(properties.blades, properties.pointed, properties.type, properties.material); if ((int)properties.type <= (int)IngotProperties.WeaponType.undefinedsword) //it's a sword { //if it's a sword, then we check to see which sword it shoudl be. return(FindPrefab(Swords, temp)); } else if ((int)properties.type <= (int)IngotProperties.WeaponType.undefinedaxe) // it's an axe { return(FindPrefab(Axes, temp)); } else if ((int)properties.type <= (int)IngotProperties.WeaponType.warhammer) //it's a hammer { return(FindPrefab(Hammers, temp)); } else { return(null);//do nothing cause it is nothing } }
void OnTriggerEnter(Collider c) { ObjectProperties objProp = c.gameObject.transform.root.gameObject.GetComponent <ObjectProperties> (); IngotProperties ingotProp = c.gameObject.GetComponent <IngotProperties> (); if (objProp != null) { materialDictionary = objProp.getMaterialDictionary(); materialNames = objProp.getMaterialNames(); for (int i = 0; i < materialNames.Count; ++i) { float value; materialDictionary.TryGetValue(materialNames [i].ToString(), out value); element += materialNames [i].ToString() + " " + value + "g\n"; GameObject spawned = (GameObject)Instantiate(GetElement(materialNames [i].ToString()), new Vector3(body.position.x + spawnOffsetX, body.position.y + spawnOffsetY, body.position.z + spawnOffsetZ), Quaternion.identity); spawned.GetComponent <IngotProperties> ().SetName(materialNames [i].ToString()); spawned.GetComponent <IngotProperties> ().SetValue(value); Vector3 scale = spawned.transform.localScale; spawned.transform.localScale = new Vector3(scale.x / (100 / value), scale.y / (100 / value), scale.z / (100 / value)); } Destroy(c.gameObject); } else if (ingotProp != null) { string name = ingotProp.GetName(); float value = ingotProp.GetValue(); element = name + " " + value + "g"; c.gameObject.transform.position = new Vector3(body.position.x + spawnOffsetX, body.position.y + spawnOffsetY, body.position.z + spawnOffsetZ); } }