void prayForTheBirdGod() { timer = Mathf.Min(timer + Time.deltaTime, maxTimeForPraying); if(timer == maxTimeForPraying) { timer = 0; state = PRIESTSTATE.ROTATE; StartCoroutine("rotateForLooking",centerOfChurch); } //Invoke(rotateForPraying(centerOfChurch), 5f); }
IEnumerator rotateForLooking(GameObject target) { bool right = false; if(Random.Range(0,100) < 50) { right = true; } Vector3 currentVector = target.transform.position - transform.position; float angle = Vector3.Angle(transform.forward, currentVector); while (angle > 4 || angle < -4) { currentVector = target.transform.position - transform.position; angle = Vector3.Angle(transform.forward, currentVector); if(right) transform.Rotate(transform.up, Time.deltaTime * speedRotate); else transform.Rotate(transform.up, -Time.deltaTime * speedRotate); yield return null; } state = PRIESTSTATE.LOOKING; maxTimeInLookingState = Random.Range(timeInLookingState - timeInLookingState / 2, timeInLookingState + timeInLookingState / 2); yield return null; }
void seekingHotBoy() { timer = Mathf.Min(timer + Time.deltaTime, maxTimeInLookingState); for (int i = 0; i < players.Length; i++) { if (players[i].GetComponent<playerScript>().state == playerScript.STATE.ISTWERKING) { Vector3 currentVector = players[i].transform.position - transform.position; float angle = Vector3.Angle(transform.forward, currentVector); if (angle < 15 && angle > -15) { players[i].GetComponent<playerScript>().launchStun(); } } } if (timer == maxTimeInLookingState) { timer = 0; state = PRIESTSTATE.ROTATE; StartCoroutine("rotateForPraying"); } }
// Use this for initialization void Start () { state = PRIESTSTATE.PRAY; players = GameObject.FindGameObjectsWithTag("Player"); baseRotation = transform.localRotation.y; maxTimeForPraying = Random.Range(1, 2); }
IEnumerator rotateForPraying() { bool right = false; if (Random.Range(0, 100) < 50) { right = true; } Vector3 currentVector = backOfChurch.transform.position - transform.position; float angle = Vector3.Angle(transform.forward, currentVector); while (angle > 4 || angle < -4) { currentVector = backOfChurch.transform.position - transform.position; angle = Vector3.Angle(transform.forward, currentVector); if (right) transform.Rotate(transform.up, Time.deltaTime * speedRotate); else transform.Rotate(transform.up, -Time.deltaTime * speedRotate); yield return null; yield return null; } state = PRIESTSTATE.PRAY; timer = 0; maxTimeForPraying = Random.Range(timeInPrayingState - timeInPrayingState / 2, timeInPrayingState + timeInPrayingState / 2); yield return null; }