public MechPrefab getMechPart(string name) { Debug.Log("Buscamos: " + name); MechPrefab mech = null; int position = 0; foreach (MechPrefab prefab in mechParts) { Debug.Log("pos: " + position); position++; string a = name.Remove(name.Length - 7).ToString(); string b = prefab.gameObject.name.ToString(); Debug.Log(a); Debug.Log(b); Debug.Log(a.Equals(b)); if (a.Equals(b)) { Debug.Log(">>>>>>>ENCONTRO!!!!!!!!!<<<<<<"); return(prefab); } else { Debug.Log("nada"); } } return(mech); }
public void AddPart(MechPrefab part) { _prefabList.Add(part); if(part.mounts.Count > 0) { _currentMount = 0; if(!isLocked) _currentPrefab = _prefabList.Count - 1; } }
public void AddPart(MechPrefab part) { _prefabList.Add(part); if (part.mounts.Count > 0) { _currentMount = 0; if (!isLocked) { _currentPrefab = _prefabList.Count - 1; } } }
public void printOrder() { //FindChildRecursive (rootGo.transform); string receta = ""; foreach (MechPrefab prefab in _prefabList) { Debug.Log(" EL NOMBRE ES " + prefab.gameObject.name + " El mount es " + prefab.gameObject.transform.parent + " y su mount es " + prefab); MechPrefab[] grandChildren = prefab.GetComponentsInChildren <MechPrefab> (); foreach (MechPrefab grandChild in grandChildren) //Debug.Log (" EL Tiene un child de " + grandChild.gameObject.name); //Debug.Log (" La cantidad de childs es " + grandChildren.Length); { } //List<MechPrefab> c = GetParts(); // Debug.Log (" el que encontro es " + test); MechPrefab test = getMechPart(prefab.gameObject.name); /* * * if (miniManager == null) { * GameObject x; * x = GameObject.Find ("CopyCat"); * x.AddComponent<MechManager> (); * miniManager = x.GetComponent<MechManager> (); * //Debug.Log (" Se creo el minimanager" ); * * }*/ //miniManager.mechParts = mechParts; //miniManager.SpawnPart(GetMechPart(test.gameObject.transform.name), prefab.m ountedOn); receta += test.gameObject.transform.name + "," + prefab.mountedOn + "|"; } PlayerPrefs.SetString("robotRecipe", receta); Debug.Log(receta); }
public MechPrefab getMechPart(string name) { MechPrefab mech = null; foreach (MechPrefab prefab in mechParts) { string a = name.Remove(name.Length - 7).ToString(); string b = prefab.gameObject.name.ToString(); /*Debug.Log (a); * Debug.Log (b); * Debug.Log (a.Equals(b)); */ if (a.Equals(b)) { return(prefab); } } return(mech); }
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 RemovePart(MechPrefab part) { _prefabList.Remove(part); }
public void printOrder() { foreach (MechPrefab prefab in _prefabList) { // Debug.Log (" EL NOMBRE ES " + prefab.gameObject.name + " El parent es " + prefab.gameObject.transform.parent + " y su mount es " + prefab ); MechPrefab[] grandChildren = prefab.GetComponentsInChildren <MechPrefab>(); foreach (MechPrefab grandChild in grandChildren) { //Debug.Log (" EL Tiene un child de " + grandChild.gameObject.name); //Debug.Log (" La cantidad de childs es " + grandChildren.Length); } //List<MechPrefab> c = GetParts(); MechPrefab test = getMechPart(prefab.gameObject.name); GameObject go = Instantiate(test.gameObject); Debug.Log(" el que encontro es " + test); if (miniManager == null) { GameObject x; x = GameObject.Find("CopyCat"); x.AddComponent <JuedyManager> (); miniManager = x.GetComponent <JuedyManager> (); Debug.Log(" Se creo el minimanager"); } //miniManager.mechParts = mechParts; foreach (MechPrefab x in mechParts) { // manager.mechParts.Add (x); } Debug.Log("antes" + miniManager.rootGo); miniManager.SpawnPart(GetMechPart(test.gameObject.transform.name)); Debug.Log("despues" + miniManager.rootGo); /* * * * * * * } * * * * * if(_prefabList.Count > 0) * { * for(int x = 0 ; x < _prefabList.Count ; x++) * * foreach(Transform child in _prefabList[x].transform) * { * MechPrefab oldPrefab = child.GetComponent<MechPrefab>(); * * * * * if(oldPrefab) * { * * Debug.Log (" EL NOMBRE ES " + child.gameObject.name); * * MechPrefab[] grandChildren = oldPrefab.GetComponentsInChildren<MechPrefab>(); * * foreach(MechPrefab grandChild in grandChildren) * { * * * //RemovePart(grandChild); * } * * //RemovePart(oldPrefab); * //Destroy(child.gameObject); * } * } * } * /*/ } }
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(); }