IEnumerator shift() { while (true) { yield return(new WaitForSeconds(.25f)); float m = transform.position.y + bounds * .5f - CameraFlow.getScreenMinBorderY(); if (m < 0) { transform.position += Vector3.up * bounds * 2f; } } }
IEnumerator CheckDestroy() { int sc = 0; cycles = (int)(Random.value * 20f) + 10; if (isBoss) { cycles += 20; } while (Vector2.Distance(transform.position, CameraFlow.position) < 100) { if (transform.position.y < CameraFlow.getScreenMinBorderY()) { break; } sc++; if (sc > 7) { speed *= 0.75f; sc = 0; } if (Random.value < repositionChance) { if (Random.value > 0.92) { behaviorType = 0; Range = Random.Range(6f, 12f); AdRange = Range * .05f + 1f; shootRange = Random.Range(Range * 1.5f, Range * 2.5f); fleeRange = Range * 0.5f * Random.value; } stayPos = CameraFlow.randomScreenPos(); } if (healthPercent < 0.9f) { cycles--; if (cycles < 0 && Random.value > 0.6) { speed += 3; stayPos = Vector2.down * 100 + Vector2.right * (Random.value - 0.5f) * 200; behaviorType = 1; Range = 1; } } yield return(new WaitForSeconds(1f)); } destroySelf(); }