public void ActivatePower(PowerSystemScript powerSystemScript) { //Debug.Assert(powerSystemScript.LeftHandSpawn.name.StartsWith("Left")); var primaryHandSpawn = powerSystemScript.LeftHanded ? powerSystemScript.LeftHandSpawn : powerSystemScript.RightHandSpawn; var offHandSpawn = powerSystemScript.LeftHanded ? powerSystemScript.RightHandSpawn : powerSystemScript.LeftHandSpawn; //Debug.Assert(primaryHandSpawn.name.StartsWith("Right") && !powerSystemScript.LeftHanded); var primaryPowerTransform = transform.Find("PrimaryHand"); var offPowerTransform = transform.Find("OffHand"); //var localPosition = primaryPowerTransform.localPosition; //var localRotation = primaryPowerTransform.localRotation; PrimaryPower = Instantiate(primaryPowerTransform.gameObject, primaryHandSpawn.transform); OffPower = Instantiate(offPowerTransform.gameObject, offHandSpawn.transform); if (powerSystemScript.LeftHanded) { var pt = PrimaryPower.transform; var pp = pt.localPosition; pt.localPosition = new Vector3(pp.x * -1, pp.y, pp.z); var ot = OffPower.transform; var op = ot.localPosition; ot.localPosition = new Vector3(op.x * -1, op.y, op.z); } PrimaryPower.active = true; OffPower.active = true; }
// Start is called before the first frame update void Start() { Player = HandsInputScript.gameObject; PowerSystem = Player.GetComponent <PowerSystemScript>(); TextOut = transform.Find("TextOut").gameObject; var bc = transform.Find("BackCircle"); var mr = bc.GetComponent <MeshRenderer>(); BackCircleMaterial = mr.sharedMaterial; BackCircleMaterial.SetFloat("Alpha", 0); //BuildSections(); foreach (Transform t in transform) { if (t.name.StartsWith("Section")) { SectionScripts.Add(t.GetComponent <SectionScript>()); Icons.Add(t.Find("Icon").gameObject); } } }
public void RemovePower(PowerSystemScript powerSystemScript) { Destroy(PrimaryPower); Destroy(OffPower); }
// Start is called before the first frame update void Start() { WaitTill = Time.time + 1; PowerSystem = gameObject.GetComponent <PowerSystemScript>(); }