IEnumerator WaitBehavior() { float time = GameRNG.Rand(0.1f, 2.0f); while (currentBehavior == WaitAndDoNothing && time > 0.0f) { if (swarm.Count > 0 || cubeswarm.Count > 0) { break; } time -= Time.deltaTime; body.velocity = Vector3.zero; yield return(new WaitForEndOfFrame()); } currentBehavior = SwarmBehavior; //waitBehavior = null; }
bool DoTryPlace(int xmin, int xmax, int ymin, int ymax, int size) { usedCards.Clear(); //List<CardPlacement> spots = new List<CardPlacement>(); bool result = false; bool xFirst = GameRNG.Rand() % 2 == 1; if (xFirst) { for (int y = ymin; y <= ymax; ++y) { for (int x = xmin; x <= xmax; ++x) { result = TryFillX(x, y, size); if (result) { return(true); } usedCards.Clear(); CancelPlay(); HideCards(); } } for (int x = xmin; x <= xmax; ++x) { for (int y = ymin; y <= ymax; ++y) { result = TryFillY(x, y, size); if (result) { return(true); } usedCards.Clear(); CancelPlay(); HideCards(); } } } else { //y direction first for (int x = xmin; x <= xmax; ++x) { for (int y = ymin; y <= ymax; ++y) { result = TryFillY(x, y, size); if (result) { return(true); } usedCards.Clear(); gameController.CancelPlay(this); } } for (int y = ymin; y <= ymax; ++y) { for (int x = xmin; x <= xmax; ++x) { result = TryFillX(x, y, size); if (result) { return(true); } usedCards.Clear(); gameController.CancelPlay(this); } } } return(result); }