public void UpdateBlocks(SupportBlock supportBlock, bool isRed) { if (isRed) { redLocation = supportBlock; } else { blueLocation = supportBlock; } if (redLocation == null || blueLocation == null) { UpdateAllGood(); } else { int minX = redLocation.x > blueLocation.x ? blueLocation.x : redLocation.x; int maxX = redLocation.x > blueLocation.x ? redLocation.x : blueLocation.x; int minY = redLocation.y > blueLocation.y ? blueLocation.y : redLocation.y; int maxY = redLocation.y > blueLocation.y ? redLocation.y : blueLocation.y; for (int i = 0; i < supportBlocks.Length; i++) { supportBlocks[i].UpdateBlockTag(minX, maxX, minY, maxY, redLocation, blueLocation); } } }
public void UpdateBlockTag(int minX, int maxX, int minY, int maxY, SupportBlock red, SupportBlock blue) { if (this == blue && this == red) { gameObject.tag = both; } if (this == blue) { gameObject.tag = blueLocation; } else if (this == red) { gameObject.tag = redLocation; } else { if (minX <= x && maxX >= x && minY <= y && maxY >= y) { gameObject.tag = good; } else { gameObject.tag = bad; } } }
public void ResetMap() { redLocation = null; blueLocation = null; UpdateAllGood(); }