Ejemplo n.º 1
0
        public void CreateImage()
        {
            if (image_to_place == null)
            {
                Debug.LogError("image_to_place is empty in StaticImageNode. Make sure to fill that field in.", this.gameObject);
                Finish_Node();
                return;
            }

            // Create a new gameobject
            GameObject go = new GameObject(image_to_place.name);

            if (place_in_foreground)
            {
                go.transform.SetParent(UIManager.ui_manager.foreground_static_image_parent);
            }
            else
            {
                go.transform.SetParent(UIManager.ui_manager.background_static_image_parent);
            }

            go.transform.localScale = Vector3.one;
            Image im = go.AddComponent <Image>();

            im.sprite = image_to_place;
            SaveManager.SetSaveFeature(this, go);

            // Set the size of the image
            switch (size_option)
            {
            case Image_Size.native_size:
                im.SetNativeSize();
                // 0,0, being center, -0.5,-0.5 being bottom left, 0.5,0.5 being top right
                go.transform.localPosition = new Vector3(image_coordinates.x * UIManager.ui_manager.canvas_width,
                                                         image_coordinates.y * UIManager.ui_manager.canvas_height,
                                                         1);
                break;

            case Image_Size.fit_whole_screen:
                im.rectTransform.anchorMin     = new Vector2(0, 0);
                im.rectTransform.anchorMax     = new Vector2(1, 1);
                im.rectTransform.pivot         = new Vector2(0.5f, 0.5f);
                im.rectTransform.sizeDelta     = Vector2.zero;
                im.rectTransform.localPosition = Vector2.zero;
                break;

            case Image_Size.custom_size:
                go.transform.localPosition = new Vector3(image_coordinates.x * UIManager.ui_manager.canvas_width,
                                                         image_coordinates.y * UIManager.ui_manager.canvas_height,
                                                         1);
                im.rectTransform.pivot     = new Vector2(0.5f, 0.5f);
                im.rectTransform.sizeDelta = custom_image_size;
                break;
            }

            if (fade_in_new_image)
            {
                StartCoroutine(UIManager.ui_manager.Fade_In_Image(im, fade_in_time));
            }
        }
Ejemplo n.º 2
0
 public override void Run_Node()
 {
     StartCoroutine(AudioManager.audio_manager.Fade_Out_Music(5));
     AudioManager.audio_manager.Set_Music(gameObject.GetComponent <AudioSource>().clip);
     SaveManager.SetSaveFeature(this, AudioManager.audio_manager.background_music_audio_source.gameObject);
     Finish_Node();
 }
Ejemplo n.º 3
0
        public override void Run_Node()
        {
            if (new_music == null || new_music == AudioManager.audio_manager.background_music_audio_source.clip)
            {
                SaveManager.RemoveSaveFeature(AudioManager.audio_manager.background_music_audio_source.gameObject);
                Finish_Node();
                return;
            }

            SaveManager.SetSaveFeature(this, AudioManager.audio_manager.background_music_audio_source.gameObject);

            if (fadeOutPreviousMusic && AudioManager.audio_manager.background_music_audio_source.isPlaying)
            {
                // Fade out the previous background music for a smooth transition
                StartCoroutine(AudioManager.audio_manager.Fade_Out_Music(fadeOutTime));
                StartCoroutine(Wait(fadeOutTime));  // Wait, then add our background music
            }
            else
            {
                // If not fading out the previous background music, move the Child of this object that has the AudioSource
                // to be the child of MusicManager and have it play the AudioSource
                AudioManager.audio_manager.Set_Music(new_music);
                Finish_Node();
            }
        }
Ejemplo n.º 4
0
        public override void Run_Node()
        {
            if (new_ambience == AudioManager.audio_manager.ambience_audio_source.clip && AudioManager.audio_manager.ambience_audio_source.volume != 0)
            {
                Debug.Log("Ambience is already playing", this.gameObject);
                Finish_Node();
                return;
            }

            SaveManager.SetSaveFeature(this, AudioManager.audio_manager.ambience_audio_source.gameObject);

            if (fade_out_previous_ambience && AudioManager.audio_manager.ambience_audio_source.isPlaying)
            {
                // Fade out the previous ambience sounds for a smooth transition
                StartCoroutine(AudioManager.audio_manager.Fade_Out_Ambience(fadeOutTime));
                StartCoroutine(Wait(fadeOutTime));  // Wait, then add our background music
            }
            else
            {
                // If not fading out the previous ambience sounds, move the Child of this object that has the AudioSource
                // to be the child of MusicManager and have it play the AudioSource
                Debug.Log("Setting ambience " + new_ambience.name);
                AudioManager.audio_manager.Set_Ambience(new_ambience);
                Finish_Node();
            }
        }
Ejemplo n.º 5
0
        public override void Run_Node()
        {
            Actor   actor = ActorManager.Get_Actor(actor_name);
            Vector3 scale = actor.transform.localScale;

            scale.x = -scale.x;
            actor.transform.localScale = scale;

            SaveManager.SetSaveFeature(this, actor.gameObject);

            Finish_Node();
        }
Ejemplo n.º 6
0
        public override void Run_Node()
        {
            if (ActorManager.Is_Actor_On_Scene(actor_name))
            {
                Actor actor = ActorManager.Get_Actor(actor_name);
                SaveManager.SetSaveFeature(this, actor.gameObject);

                Debug.Log("Actor on scene " + actor.actor_name);

                if (fade_in_new_image)
                {
                    Sprite old_sprite = actor.cur_image.overrideSprite;

                    if (lighten_actor)
                    {
                        actor.Lighten();
                    }
                    if (bring_actor_to_front)
                    {
                        ActorManager.Bring_Actor_To_Front(actor);
                    }

                    // Fade out old image
                    actor.fading_child_image.gameObject.SetActive(true);
                    actor.fading_child_image.overrideSprite = old_sprite;

                    // Set colour of old image to match current image
                    actor.fading_child_image.color = actor.cur_image.color;
                    actor.fading_child_image.GetComponent <RectTransform>().sizeDelta = actor.rect.sizeDelta;
                    StartCoroutine(Fade_Out_Coroutine(fade_out_time, actor.fading_child_image));

                    // Fade in new image
                    actor.cur_image.overrideSprite = new_image;
                    StartCoroutine(Fade_In_Coroutine(fade_out_time, actor.cur_image));

                    // Wait before we allow it to finish
                    StartCoroutine(Wait(actor, fade_out_time * 1.1f));
                }
                else
                {
                    Debug.Log("Actor on scene " + actor.actor_name);

                    actor.cur_image.overrideSprite = new_image;
                    Finish_Node();
                }
            }
            else
            {
                Finish_Node();

                Debug.Log(actor_name + " is not on the scene. Remember to correctly name your actor and use 'EnterActorNode'");
            }
        }
Ejemplo n.º 7
0
        public override void Run_Node()
        {
            Actor actor_script;

            // Check if the actor is already present
            if (ActorManager.Is_Actor_On_Scene(actor_name))
            {
                // Actor is already on the scene
                Debug.Log("Actor " + actor_name + " already on scene");
                actor_script = ActorManager.Get_Actor(actor_name).GetComponent <Actor>();
                Finish_Node();
                return;
            }
            else
            {
                // Actor is not in the scene. Instantiate it
                if (VNSceneManager.verbose_debug_logs)
                {
                    Debug.Log("Creating new actor " + actor_name);
                }

                if (destination == Actor_Positions.CUSTOM && custom_position != null)
                {
                    actor_script = ActorManager.Instantiate_Actor(actor_name, destination, custom_position);
                }
                else
                {
                    actor_script = ActorManager.Instantiate_Actor(actor_name, destination);
                }
            }
            SaveManager.SetSaveFeature(this, actor_script.gameObject);

            switch (entrance_type)
            {
            case Entrance_Type.Slide_In:
                actor_script.Slide_In(destination, 2.0f);
                Finish_Node();
                break;

            case Entrance_Type.Fade_In:
                actor_script.Place_At_Position(destination);
                actor_script.Fade_In(fade_in_time);
                StartCoroutine(Wait(fade_in_time + 0.2f));
                break;

            case Entrance_Type.None:
                Finish_Node();
                break;
            }
        }
Ejemplo n.º 8
0
        public bool fade_in;    // Set the background to black immediately, then fade in the background image

        public override void Run_Node()
        {
            activateImage();           // Ensure whatever image we're operating on is active

            if (!fade_in && !fade_out) // && !fade_out_then_in_background)
            {
                // Simply set background or foreground and end if we aren't fading
                if (!set_foreground)
                {
                    UIManager.ui_manager.background.sprite = sprite;
                    UIManager.ui_manager.background.color  = Color.white;
                }
                else
                {
                    UIManager.ui_manager.foreground.sprite = sprite;
                    UIManager.ui_manager.foreground.color  = Color.white;
                }

                Finish_Node();
            }
            else
            {
                if (fade_out && fade_in)
                {
                    StartCoroutine(Fade_Out_Then_In_Coroutine(2.0f));
                }
                else if (fade_in)
                {
                    StartCoroutine(Fade_In_Coroutine(2.0f));
                }
                else if (fade_out)
                {
                    StartCoroutine(Fade_Out_Coroutine(2.0f));
                }
            }


            // Ensure we save the foreground or background in case the user Saves and Loads the game later
            if (set_foreground)
            {
                SaveManager.SetSaveFeature(this, UIManager.ui_manager.foreground.gameObject);
            }
            else
            {
                SaveManager.SetSaveFeature(this, UIManager.ui_manager.background.gameObject);
            }
        }
        public override void Run_Node()
        {
            activateImage();           // Ensure whatever image we're operating on is active

            if (!fade_in && !fade_out) // && !fade_out_then_in_background)
            {
                // Simply set background and end if we aren't fading
                if (set_foreground)
                {
                    UIManager.ui_manager.foreground.sprite = getImage().sprite;
                    SaveManager.SetSaveFeature(this, UIManager.ui_manager.foreground.gameObject);
                }
                else
                {
                    UIManager.ui_manager.background.sprite = getImage().sprite;
                    SaveManager.SetSaveFeature(this, UIManager.ui_manager.background.gameObject);
                }

                Finish_Node();
            }
            else
            {
                if (fade_out && fade_in)
                {
                    StartCoroutine(Fade_Out_Then_In_Coroutine(2.0f));
                }
                else if (fade_in)
                {
                    StartCoroutine(Fade_In_Coroutine(2.0f));
                }
                else if (fade_out)
                {
                    StartCoroutine(Fade_Out_Coroutine(2.0f));
                }
            }

            if (!wait_for_all_fading)
            {
                Finish_Node();
            }
        }