using UnityEngine;
using System.Collections;

using DG.Tweening;

public class Ritual_Fertility : Ritual {

	public GameObject startPivotTr;

	public override IEnumerator RitualEffectCO(){

		Debug.Log("RITUAL FERTILITY!");

		// Get the two adepts
		var adepts = FindObjectsOfType<Adept>();

		var adept1 = RandomUtilities.UniformFromList (adepts);
		Adept adept2 = null;
		while (true) {
			adept2 = RandomUtilities.UniformFromList (adepts);
			if (adept2 != adept1)
				break;
		}

		yield return new WaitForSeconds (0.2f);

		adept1.Animate ("Walk");
		adept2.Animate ("Walk");

		adept1.RemoveMovements ();
		adept2.RemoveMovements ();

		adept1.followPos = startPivotTr.transform.position;
		adept2.followPos = startPivotTr.transform.position;

		yield return new WaitForSeconds (1f);

		adept1.gameObject.SetActive (false);
		adept2.gameObject.SetActive (false);

		SfxController.instance.PlaySound ("effect_sex");

		yield return new WaitForSeconds (1.5f);

		AdeptFactory.instance.CreateAdept();

		adept1.gameObject.SetActive (true);
		adept2.gameObject.SetActive (true);

		adept1.GoToEllipse ();		
		adept2.GoToEllipse ();

	}

}