﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NyanTorpedo : MonoBehaviour {

    private bool isSettingRainbow;

	// Use this for initialization
	void Start ()
    {
        
    }
	
	// Update is called once per frame
	void Update ()
    {
        

		if(!isSettingRainbow)
        {
            StartCoroutine(SetNewRainbow());
        }
	}

    IEnumerator SetNewRainbow ()
    {
        isSettingRainbow = true;
        yield return new WaitForSecondsRealtime(0.5f);
        if(transform.GetChild(0).gameObject.activeSelf)
        {
            transform.GetChild(1).gameObject.SetActive(true);
            transform.GetChild(0).gameObject.SetActive(false);
        }

        else if (transform.GetChild(1).gameObject.activeSelf)
        {
            transform.GetChild(0).gameObject.SetActive(true);
            transform.GetChild(1).gameObject.SetActive(false);
        }
        isSettingRainbow = false;
    }
}
