void Health() { // reduce the health of each ant by 1 per frame, or 2 if standing on acid block int x = (int)transform.position.x; int y = (int)(transform.position.y - 0.5f); int z = (int)transform.position.z; if (wm.GetBlock(x, y, z) is Antymology.Terrain.AcidicBlock) { health -= 2; } else { health--; } if (health <= 0) { wm.Ants.Remove(gameObject); Destroy(gameObject); } }
/// <summary> /// Ant observing their surrounding. /// </summary> void UpdateSurrounding() { int c = 0; for (int i = 0; i < Surrounding.GetLength(0); ++i) { for (int j = 0; j < Surrounding.GetLength(1); ++j) { for (int k = 0; k < Surrounding.GetLength(2); ++k) { Surrounding[i, j, k] = Winstance.GetBlock(x + i - 1, y + j - 3, z + k - 1); Score[c++] = Surrounding[i, j, k].score(); } } } Sharing = Physics.OverlapSphere(transform.position, 0.9f); }