public bool sonMovement(Vector2 pos, int id, int best) { bool res = false; Vector2 v2 = (Vector2)pos - (Vector2)transform.position; float angle = (Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg) + 90; foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); blobSon.parentCurrentSize = blobCurrentSize; if (blobSon != null && blobSon.touchID == id) { child.rotation = Quaternion.Euler(new Vector3(0, 0, angle)); blobSon.sonIndex = best; } else { //Debug.Log("Child not found!!!: " + blobSon.touchID + " "+id ); } } if (blobCurrentSize == 0) { res = true; } return(res); }
public void deleteAllSons() { foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); blobSon.autodestruction(); } }
public BlobSon getSon(int id) { foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); if (blobSon != null && blobSon.touchID == id) { return(blobSon); } } return(null); }
// Update is called once per frame void Update() { setColor(rend); anim.SetInteger("size", blobCurrentSize); foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); blobSon.parentCurrentSize = blobCurrentSize; setColor(blobSon.rend); } }
public void deleteSon(int id) { foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); if (blobSon != null && blobSon.touchID == id) { blobSon.autodestruction(); blobCurrentSize++; } } }
public bool notAlredyChild(int best) { bool res = true; foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); blobSon.parentCurrentSize = blobCurrentSize; if (blobSon.sonIndex == best) { res = false; } } return(res); }
public void createSon(int id) { Debug.Log("createSon"); Debug.Log("blobCurrentSize1: " + blobCurrentSize); if (blobCurrentSize >= 1) { Debug.Log("blobCurrentSize >= 1"); GameObject blobSon = Instantiate(Resources.Load("blobSon"), transform.position, Quaternion.identity) as GameObject; blobSon.transform.parent = transform; BlobSon bs = blobSon.GetComponent <BlobSon>(); lastSon = bs; blobCurrentSize--; bs.Initialize(blobCurrentSize, id); } Debug.Log("blobCurrentSize2: " + blobCurrentSize); }
public int [] partition() { int [] part = new int[5] { -1, -1, -1, -1, -1 }; int i = 0; foreach (Transform child in transform) { BlobSon blobSon = child.GetComponent <BlobSon>(); if (i < 5) { part[i] = blobSon.sonIndex; i++; } } return(part); }