public void SpawnPart(MechPrefab prefab) { int amount = 0; if (_prefabList.Count > 0) { foreach (Transform child in _prefabList[_currentPrefab].mounts[_currentMount].mountPoint) { MechPrefab oldPrefab = child.GetComponent <MechPrefab>(); if (oldPrefab) { MechPrefab[] grandChildren = oldPrefab.GetComponentsInChildren <MechPrefab>(); foreach (MechPrefab grandChild in grandChildren) { RemovePart(grandChild); } RemovePart(oldPrefab); Destroy(child.gameObject); } } } GameObject go = (GameObject)Instantiate(prefab.gameObject, new Vector3(0, 0, 0), Quaternion.identity); //go.transform.localScale += new Vector3 (1, 1, 1); if (firstTime) { firstTime = false; animator = go.GetComponent <Animator> (); rootGo = go; /* * DigitalRuby.PyroParticles.FPCScript script; * * script = new DigitalRuby.PyroParticles.FPCScript (); * * * * // rootGo.AddComponent<>(); * * //script = rootGo.GetComponent<FPCScript>(); * * script.healthBar = GameObject.Find ("HP_Full").GetComponent<Image>(); * script.LoadingBar = GameObject.Find ("LoadingBar").GetComponent<Transform>(); * script.energyBar = GameObject.Find ("Energy_Full").GetComponent<Image>(); * script.shieldBar = GameObject.Find ("Shield_Full").GetComponent<Image>(); * script.textIndicator = GameObject.Find ("MinesIndicator").GetComponent<Transform>(); * * rootGo.AddComponent(script); * /*/ } if (_prefabList.Count > 0) { go.transform.parent = _prefabList[_currentPrefab].mounts[_currentMount].mountPoint; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = new Vector3(1, 1, 1); } Debug.Log("Monto el " + go.GetComponent <MechPrefab>().name + " y su mount es " + _currentMount); AddPart(go.GetComponent <MechPrefab>()); UpdateGui(); }
public void SpawnPart(MechPrefab prefab, int mount) { //Debug.Log (" EL INT QUE LLEGO ES " + mount); int amount = 0; if (_prefabList.Count > 0) { foreach (Transform child in _prefabList[_currentPrefab].mounts[mount].mountPoint) { MechPrefab oldPrefab = child.GetComponent <MechPrefab>(); if (oldPrefab) { MechPrefab[] grandChildren = oldPrefab.GetComponentsInChildren <MechPrefab>(); foreach (MechPrefab grandChild in grandChildren) { RemovePart(grandChild); } RemovePart(oldPrefab); Destroy(child.gameObject); } } } GameObject go = (GameObject)Instantiate(prefab.gameObject, new Vector3(0, 0, 0), Quaternion.identity); //go.transform.localScale += new Vector3 (1, 1, 1); if (firstTime) { firstTime = false; animator = go.GetComponent <Animator> (); rootGo = go; if (isPlaying) { GameObject.Find("Canvas").GetComponentInChildren <MapCanvasController> ().playerTransform = rootGo.transform; PlayerScript playerScript = go.AddComponent <PlayerScript> (); //playerScript. playerScript.rbody = go.AddComponent <Rigidbody> (); playerScript.rbody.constraints = RigidbodyConstraints.FreezeRotation; playerScript.rbody.mass = 400; playerScript.animator = animator; playerScript.shieldBar = shieldBar; playerScript.healthBar = healthBar; playerScript.energyBar = energyBar; } } if (_prefabList.Count > 0) { go.transform.parent = _prefabList[_currentPrefab].mounts[mount].mountPoint; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = new Vector3(1, 1, 1); } //Debug.Log ("Monto el " + go.GetComponent<MechPrefab>().name + " y su mount es " + _currentMount ); go.GetComponent <MechPrefab> ().mountedOn = _currentMount; AddPart(go.GetComponent <MechPrefab>()); UpdateGui(); }