Ejemplo n.º 1
0
 public void OnClickNextSpeechButton()
 {
     if (CanClickNext)
     {
         VisualNovel.UpdateSpeech();
     }
 }
 public override void Preload()
 {
     if (PreLoad)
     {
         VisualNovel = new VisualNovel(VNPath);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Save the Screenshot info of VnInfo to db
        /// </summary>
        /// <param name="visualNovel"></param>
        /// <param name="dbVnInfoScreens"></param>
        /// <returns></returns>
        private static List <VnInfoScreens> FormatVnInfoScreens(VisualNovel visualNovel, ILiteCollection <VnInfoScreens> dbVnInfoScreens)
        {
            try
            {
                List <VnInfoScreens> vnScreenshot = new List <VnInfoScreens>();
                if (visualNovel.Screenshots.Count > 0)
                {
                    var prevVnInfoScreens = dbVnInfoScreens.Query().Where(x => x.VnId == visualNovel.Id).ToList();
                    foreach (var screenshot in visualNovel.Screenshots)
                    {
                        var entry = prevVnInfoScreens.FirstOrDefault(x => x.ImageLink == screenshot.Url) ??
                                    new VnInfoScreens();
                        entry.VnId        = visualNovel.Id;
                        entry.ImageLink   = !string.IsNullOrEmpty(screenshot.Url) ? screenshot.Url : string.Empty;
                        entry.ReleaseId   = screenshot.ReleaseId;
                        entry.Height      = screenshot.Height;
                        entry.Width       = screenshot.Width;
                        entry.ImageRating = screenshot.ImageRating;
                        vnScreenshot.Add(entry);
                    }
                }

                return(vnScreenshot);
            }
            catch (Exception e)
            {
                App.Logger.Error(e, "Failed to save VnInfo screens");
                SentryHelper.SendException(e, null, SentryLevel.Warning);
                return(new List <VnInfoScreens>());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Save list of VnInfo Relations
        /// </summary>
        /// <param name="visualNovel"></param>
        /// <param name="dbVnInfoRelations"></param>
        /// <returns></returns>
        private static List <VnInfoRelations> FormatVnInfoRelations(VisualNovel visualNovel, ILiteCollection <VnInfoRelations> dbVnInfoRelations)
        {
            try
            {
                List <VnInfoRelations> vnRelations = new List <VnInfoRelations>();
                if (visualNovel.Relations.Count > 0)
                {
                    var prevVnInfoRelations = dbVnInfoRelations.Query().Where(x => x.VnId == visualNovel.Id).ToList();
                    foreach (var relation in visualNovel.Relations)
                    {
                        var entry = prevVnInfoRelations.FirstOrDefault(x => x.RelationId == relation.Id) ??
                                    new VnInfoRelations();
                        entry.VnId       = visualNovel.Id;
                        entry.RelationId = relation.Id;
                        entry.Relation   = relation.Type.ToString();
                        entry.Title      = relation.Title;
                        entry.Original   = relation.Original;
                        entry.Official   = relation.Official ? "Yes" : "No";
                        vnRelations.Add(entry);
                    }
                }

                return(vnRelations);
            }
            catch (Exception e)
            {
                App.Logger.Error(e, "Failed to save VnInfo Relations");
                SentryHelper.SendException(e, null, SentryLevel.Warning);
                return(new List <VnInfoRelations>());
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Save VnInfo Tags
        /// </summary>
        /// <param name="visualNovel"></param>
        /// <param name="dbVnInfoTags"></param>
        /// <returns></returns>
        private static List <VnInfoTags> FormatVnInfoTags(VisualNovel visualNovel, ILiteCollection <VnInfoTags> dbVnInfoTags)
        {
            try
            {
                List <VnInfoTags> vnTags = new List <VnInfoTags>();
                if (visualNovel.Tags.Count > 0)
                {
                    List <VnInfoTags> prevVnInfoTags = dbVnInfoTags.Query().Where(x => x.VnId == visualNovel.Id).ToList();
                    foreach (var tag in visualNovel.Tags)
                    {
                        var entry = prevVnInfoTags.FirstOrDefault(x => x.TagId == tag.Id) ?? new VnInfoTags();
                        entry.VnId    = visualNovel.Id;
                        entry.TagId   = tag.Id;
                        entry.Score   = tag.Score;
                        entry.Spoiler = tag.SpoilerLevel;
                        vnTags.Add(entry);
                    }
                }

                return(vnTags);
            }
            catch (Exception e)
            {
                App.Logger.Error(e, "Failed to save VnInfo Tags");
                SentryHelper.SendException(e, null, SentryLevel.Warning);
                return(new List <VnInfoTags>());
            }
        }
Ejemplo n.º 6
0
 public void LoadVisualNovel(VisualNovel visualNovel)
 {
     Reset(false);
     if (visualNovel.nodes != null || !visualNovel.hasData)
     {
         if (visualNovel.hasData)
         {
             if (!_nodes.Contains(null))
             {
                 _nodes = new List <Node>(visualNovel.nodes);
                 Debug.Log("Added " + visualNovel.nodes.Length + " node(s).");
             }
             else
             {
                 Debug.LogError("Failed to load Visual Novel Asset: " + visualNovel.name + ". There are no nodes present within the node array!");
             }
         }
         _visualNovel       = visualNovel;
         _visualNovelLoaded = true;
     }
     else
     {
         Debug.LogError("Failed to load visual novel! There are no nodes within the internal node list.");
     }
     Repaint();
 }
Ejemplo n.º 7
0
    private void GenerateNodePathForNovel(VisualNovel visualNovel)
    {
        Node[] nodes = new Node[_nodes.Count];
        for (int i = 0; i < nodes.Length; i++)
        {
            nodes[i] = _nodes[i];
        }
        visualNovel.nodes     = nodes;
        visualNovel.nodeCount = visualNovel.nodes.Length;
        List <int> path = new List <int>();

        visualNovel.valid = true;
        if (visualNovel.nodes.Length > 2)
        {
            if (visualNovel.nodes[0].isStartNode)
            {
                FollowNode(visualNovel.nodes[0], path); //Good old friend called recursion.
                if (path.Count > 0)
                {
                    Node endNode = _nodes[path[path.Count - 1]];
                    Debug.Log("Node Path ended at node: " + _nodes[path[path.Count - 1]].nodeName);

                    if (endNode.isEndNode)
                    {
                        Debug.Log("Node path generated successfully for " + visualNovel.name + ".");
                        visualNovel.nodePath = path.ToArray();
                    }
                    else
                    {
                        Debug.LogError("Failed to generate Node Path for " + visualNovel.name + ". A valid path must end at the exit node! Node Path ended at node: " + _nodes[path[path.Count - 1]].nodeName);
                        visualNovel.valid = false;
                    }
                }
                else
                {
                    Debug.LogError("Failed to create Node Path!");
                    visualNovel.valid = false;
                }
            }
            else
            {
                Debug.LogError("Failed to generate Node Path for " + visualNovel.name + ". A valid path must begin at the start node!");
                visualNovel.valid = false;
            }
        }
        else
        {
            Debug.LogError("Failed to generate Node Path for " + name + ". The specified node list consists of only a start and exit node! This is not allowed.");
            visualNovel.valid = false;
        }
        EditorUtility.SetDirty(visualNovel);

        visualNovel.hasData = true;
        visualNovel.author  = System.Environment.UserName;
        Debug.Log("Node Path: " + path.Count);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        Debug.Log("Visual Novel [" + visualNovel.name + "] saved.");
    }
Ejemplo n.º 8
0
 public void NextCutscene()
 {
     playingCutscene = true;
     if (_cutsceneIndex + 1 < cutscenes.Length)
     {
         _cutsceneIndex++;
         CurrentCutscene = cutscenes[_cutsceneIndex];
     }
 }
Ejemplo n.º 9
0
    protected override void Execute()
    {
        VisualNovel.UpdateSpeech();
        var index = VisualNovel.GetCurrentSpeechIndex();

        VisualNovelService.Save(index);

        SceneManager.LoadScene("TurnBattle");
    }
Ejemplo n.º 10
0
 public void Reset(bool clearObject)
 {
     _nodes.Clear();
     if (clearObject)
     {
         _visualNovel = null;
     }
     CreateStateNodes();
 }
    private IEnumerator LoadNovelAfterSeconds(VisualNovel novel, float seconds)
    {
        yield return(new WaitForSeconds(seconds));

        if (novel)
        {
            gameObject.SetActive(true);
            LoadVisualNovel(novel);
        }
    }
Ejemplo n.º 12
0
 //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
 public bool execute(VisualNovelSystem vns, VisualNovel vn)
 {
     if (text.Equals("~"))
     {
         vns.clearText();
     }
     else
     {
         vns.setText(text);
     }
     return(halt);
 }
Ejemplo n.º 13
0
 public void GoToCutscene(int index)
 {
     if (index < cutscenes.Length)
     {
         _cutsceneIndex  = index;
         CurrentCutscene = cutscenes[_cutsceneIndex];
     }
     else
     {
         Debug.LogError("Cutscene Manager: Cutscene with index " + index + " does not exist within the Cutscene Manager!");
     }
 }
Ejemplo n.º 14
0
 public void JumpToCutscene(int cutsceneIndex)
 {
     if (cutsceneIndex < cutscenes.Length)
     {
         _cutsceneIndex  = cutsceneIndex;
         CurrentCutscene = cutscenes[cutsceneIndex];
     }
     else
     {
         Debug.LogError("Cutscene of index " + cutsceneIndex + " is not valid!");
     }
 }
Ejemplo n.º 15
0
    public void startNovel(VisualNovel novel)
    {
        currentNovel = novel;

        showNovel();

        //Pass the background dimensions to the novel so it can scale properly
        Vector3 bgScale = background.transform.localScale;

        novel.scaleToBackground(bgScale.x, bgScale.y);

        novel.start();
    }
Ejemplo n.º 16
0
    void buildListOfNovels()
    {
        scanThreads = new List <Thread>();
        novels      = new List <VisualNovel>();
        variables   = new Dictionary <string, int>();

        string[] novelFolders = Directory.GetDirectories(LIBRARY_DIRECTORY);

        //Scan all the novels
        Vector3 novelPosition      = new Vector3(-270, 250, 0);
        Vector3 incrementPositionX = new Vector3(105, 0, 0);
        Vector3 incrementPositionY = new Vector3(0, -115, 0);

        foreach (string folder in novelFolders)
        {
            try {
                //Create the visual novel entity
                VisualNovel novel = new VisualNovel(folder);

                //Create an accompanying novel icon
                GameObject newNovelIcon = (GameObject)Instantiate(novelIconPrefab, novelPosition, gameObject.transform.rotation);
                newNovelIcon.transform.parent        = novelSelector.gameObject.transform;
                newNovelIcon.transform.localScale    = new Vector3(1, 1, 1);
                newNovelIcon.transform.localPosition = novelPosition;

                //Update the button's icon and text to that of the novel
                Button novelButton = newNovelIcon.GetComponent <Button>();
                novelButton.image.sprite = Sprite.Create(novel.getThumbnail(), new Rect(0, 0, 100, 75), new Vector2(0, 0), .01f);
                Text novelText = newNovelIcon.GetComponentInChildren <Text>();
                novelText.text = novel.getTitle();
                StartNovel theNovelStarter = newNovelIcon.GetComponent <StartNovel>();
                theNovelStarter.novel  = novel;
                theNovelStarter.system = this;

                //Increment the position that the next icon will be created at
                novelPosition += incrementPositionX;

                if (novelPosition.x > 270)
                {
                    novelPosition.x = -270;
                    novelPosition  += incrementPositionY;
                }
            } catch (System.Exception e) {
                Debug.Log("Could not parse directory " + folder + "\n\n because of " + e.Message);
            }
        }
    }
Ejemplo n.º 17
0
    //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
    public override bool execute(VisualNovelSystem vns, VisualNovel vn)
    {
        if (resourcePath.Equals("~"))
        {
            vns.stopMusic();
        }
        else
        {
            Debug.Log("Playing audio " + this.resourcePath);
            //sound = resourceStream.GetAudioClip(false, false, AudioType.OGGVORBIS);
            sound = resourceStream.GetAudioClip(true);
            sound.LoadAudioData();
            vns.playMusic(sound);
        }

        return(false);
    }
Ejemplo n.º 18
0
        public override List <ActionPanel> OnMenuSelect(Squad ActiveSquad, ActionPanelHolder ListActionMenuChoice)
        {
            VisualNovel NewVisualNovel = new VisualNovel(ListVisualNovel[ActiveVisualNovelIndex]);

            NewVisualNovel.ListGameScreen = Map.ListGameScreen;
            NewVisualNovel.Load();

            if (ActiveVisualNovelIndex + 1 < ListVisualNovel.Count)
            {
                ++ActiveVisualNovelIndex;
            }

            return(new List <ActionPanel>()
            {
                new ActionPanelVisualNovel(ListActionMenuChoice, NewVisualNovel)
            });
        }
Ejemplo n.º 19
0
    //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
    public override bool execute(VisualNovelSystem vns, VisualNovel vn)
    {
        if (resourcePath.Equals("~"))
        {
            vns.stopMusic();
        }
        else
        {
            Debug.Log("Playing music " + this.resourcePath);

            music = resourceStream.GetAudioClip(true);
            music.LoadAudioData();
            vns.playMusic(music);
        }

        return(false);
    }
Ejemplo n.º 20
0
    IEnumerator LoadNovel(Novel novel)
    {
        novelPlace  = 0;
        activeNovel = null;

        System.IO.StreamReader streamReader = new System.IO.StreamReader(novel.location + Path.DirectorySeparatorChar + novel.name + ".xml");
        string xml = streamReader.ReadToEnd();

        streamReader.Close();


        VisualNovel currentNovel = xml.DeserializeXml <VisualNovel>();

        novel.visualNovel = currentNovel;
        activeNovel       = novel;

        int resourcesCount = 0;

        while (resourcesCount < novel.visualNovel.resources.allResources.Length)
        {
            availableResources.Add(novel.visualNovel.resources.allResources[resourcesCount].id, novel.visualNovel.resources.allResources[resourcesCount]);

            resourcesCount += 1;
        }

        if (availableResources.ContainsKey("Background"))
        {
            WWW backgroundWWW = new WWW("file://" + novel.location + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + availableResources["Background"].location);
            yield return(backgroundWWW);

            backgroundTexture = new Texture2D(Screen.width, Screen.height);
            backgroundWWW.LoadImageIntoTexture(backgroundTexture);
        }

        if (availableResources.ContainsKey(novel.visualNovel.playerStory.dialogue[0].speakerImage))
        {
            WWW speakerWWW = new WWW("file://" + novel.location + Path.DirectorySeparatorChar + "Images" + Path.DirectorySeparatorChar + availableResources[novel.visualNovel.playerStory.dialogue[0].speakerImage].location);
            yield return(speakerWWW);

            speakerTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, true);
            speakerWWW.LoadImageIntoTexture(speakerTexture);
        }

        StartNovel();
    }
 public void LoadVisualNovel(VisualNovel novel)
 {
     ResetNovel();
     visualNovel = novel;
     if (!novel || !novel.valid || !novel.hasData)
     {
         textFields[0].text = "You";
         textFields[1].text = "It seems like there is no visual novel instance assigned to this panel or the specified instance has no data...";
     }
     else
     {
         SetPage(1);
         if (onNovelStart != null)
         {
             onNovelStart.Invoke(this);
         }
     }
 }
Ejemplo n.º 22
0
    public void executeReadyOperation(VisualNovelSystem vns, VisualNovel vn)
    {
        if (this.ready() && currentOperation < operations.Count && operations[currentOperation].isReady() && !halt)
        {
            Debug.Log("Attempting to execute operation " + currentOperation + " which is a " + operations[currentOperation].GetType() + " pointing to " + operations[currentOperation].getResourcePath());
            try {
                halt = operations[currentOperation].execute(vns, vn);
            } catch (System.Exception e) {
                Debug.LogError("Could not execute operation " + currentOperation + " in " + this.pathToScript);
            }

            currentOperation++;

            //Prepare the next operation
            if (currentOperation < operations.Count)
            {
                operations[currentOperation].prepare(vns.getVariables());
            }
        }
    }
 public override void ExecuteTrigger(int Index)
 {
     switch (Index)
     {
     case 0:
         scriptVisualNovel = (ScriptVisualNovel)GetDataContainerByID(_TargetID, ScriptVisualNovel.ScriptName);
         if (scriptVisualNovel != null)
         {
             ActiveVisualNovel = scriptVisualNovel.ActiveVisualNovel = new VisualNovel(scriptVisualNovel.VisualNovelName);
             scriptVisualNovel.ActiveVisualNovel.OnVisualNovelFrameChanged += OnVisualNovelFrameChanged;
             scriptVisualNovel.ActiveVisualNovel.OnVisualNovelPaused        = OnVisualNovelPaused;
             scriptVisualNovel.ActiveVisualNovel.OnVisualNovelResumed       = OnVisualNovelResumed;
             scriptVisualNovel.ActiveVisualNovel.OnVisualNovelEnded         = OnVisualNovelEnded;
             Owner.PushScreen(scriptVisualNovel.ActiveVisualNovel);
             break;
         }
         break;
     }
     IsActive = true;
 }
    private void CreateNovel(int index, Node[] nodes)
    {
        VisualNovel novel = CreateInstance <VisualNovel>();

        novel.nodes     = nodes;
        novel.nodeCount = nodes.Length;
        novel.hasData   = index == 0 ? true : false;
        novel.valid     = false;
        novel.author    = ((VisualNovel)target).author;
        string extension = ".asset";
        string path      = AssetDatabase.GetAssetPath(target);
        string name      = System.IO.Path.GetFileName(path);

        path = path.Replace(name, "");
        name = name.Replace(extension, "");
        string newPath = AssetDatabase.GenerateUniqueAssetPath(path + name + "_" + index + extension);

        AssetDatabase.CreateAsset(novel, newPath);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
Ejemplo n.º 25
0
    //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
    public bool execute(VisualNovelSystem vns, VisualNovel vn)
    {
        if (inputVariable != null)
        {
            value = vns.getVariable(inputVariable);
        }

        if (operation.Equals("="))
        {
            Debug.Log("Setting " + outputVariable + " to " + value);
            vns.setVariable(outputVariable, value);
        }
        else if (operation.Equals("+"))
        {
            Debug.Log("Adding " + value + " to the current value of " + outputVariable);
            vns.setVariable(outputVariable, vns.getVariable(outputVariable) + value);
        }


        return(false);
    }
        private async Task <uint> GetVnId()
        {
            using (var context = new DatabaseContext())
            {
                uint data = 0;
                data = context.VnInfo.Where(v => v.Title == SelectedItem).Select(x => x.VnId).FirstOrDefault();
                if (data != 0)
                {
                    return(data);
                }
                if (data == 0)
                {
                    data = context.VnIdList.Where(v => v.Title == SelectedItem).Select(x => x.VnId)
                           .FirstOrDefault();
                    return(data);
                }
                if (data == 0)
                {
                    Vndb client   = new Vndb(true);
                    var  response = await client.GetVisualNovelAsync(VndbFilters.Title.Equals(SelectedItem));

                    if (response == null)
                    {
                        HandleError.HandleErrors(client.GetLastError(), 0);
                    }
                    else
                    {
                        VisualNovel firstOrDefault = response?.Items.FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            data = firstOrDefault.Id;
                        }
                        client.Logout();
                        client.Dispose();
                        return(data);
                    }
                }
                return(0);
            }
        }
Ejemplo n.º 27
0
    //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
    public bool execute(VisualNovelSystem vns, VisualNovel vn)
    {
        bool haltingOperation = false;

        Debug.Log("Attempting to evaluate variable with name " + variable);
        try {
            int  storedValue = vns.getVariable(variable);
            bool evaluates   = false;
            if (equalityOperator.Equals("=="))
            {
                evaluates = storedValue == value;
            }
            else if (equalityOperator.Equals("!="))
            {
                evaluates = storedValue != value;
            } //TODO there are probably some more cases that are easy to nix when you get a chance
            if (evaluates)
            {
                foreach (VisualNovelOperation operation in operations)
                {
                    operation.prepare(vns.getVariables());
                    bool eachOperation = operation.execute(vns, vn);

                    //one-way switch for halting operations
                    if (eachOperation == true)
                    {
                        haltingOperation = true;
                    }
                }
            }
        } catch (KeyNotFoundException knfe) {
            Debug.Log("no key found for " + variable + " in dictionary. Assuming false");
        }


        return(haltingOperation);
    }
 public ActionPanelVisualNovel(ActionPanelHolder ListActionMenuChoice, VisualNovel ActiveVisualNovel)
     : base("Visual Novel", ListActionMenuChoice, false)
 {
     this.ActiveVisualNovel = ActiveVisualNovel;
     ActiveVisualNovel.OnVisualNovelEnded += OnVisualNovelEnded;
 }
Ejemplo n.º 29
0
 //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
 public override bool execute(VisualNovelSystem vns, VisualNovel vn)
 {
     vns.prepareBackgroundImage(resourceStream);
     return(false);
 }
Ejemplo n.º 30
0
 //Perform whatever operation is needed on the VisualNovelSystem/VisualNovel.
 public abstract bool execute(VisualNovelSystem vns, VisualNovel vn);