public float GetWeight() { if (ObjectHeld != null) { L2Ram Ram = ObjectHeld.GetComponent("L2Ram") as L2Ram; return(Ram.GetWeight()); } return(0f); }
void OnTriggerEnter(Collider other) { string idx = other.gameObject.name; if (idx[0] >= '1' && idx[0] <= '5') { // if weight balance hits any of the ram , just show its weight L2Ram ram = GameObject.Find("L2Ram" + idx).GetComponent("L2Ram") as L2Ram; ram.showText(); } }
public float GetTotalWeight() { float totalWeight = weight; foreach (GameObject obj in otherItems) { if (obj.GetComponent("L2Ram") != null) { L2Ram tmpRam = obj.GetComponent("L2Ram") as L2Ram; totalWeight += tmpRam.GetWeight(); } } return(totalWeight); }