public List <VideoData> GenerateRecomendedVideos(VideoData newVideo, bool isHomePage)
    {
        previousBrowserHistory.Push(currentState);

        List <VideoData> recomendedVideos = new List <VideoData>();

        if (isHomePage)
        {
            foreach (var item in allNonDeepVideos)
            {
                if (item.title != targetVideo.title)
                {
                    recomendedVideos.Add(item);
                }
            }
        }
        else
        {
            // use tags from recomended video to return a list of similar videos

            foreach (VideoData video in allVideos)
            {
                if (video == newVideo)
                {
                    continue;
                }
                if (SharesTag(video, newVideo))
                {
                    recomendedVideos.Add(video);
                }
                else
                {
                    int rand = UnityEngine.Random.Range(0, randomVideoChance.y);
                    if (rand < randomVideoChance.x)
                    {
                        recomendedVideos.Add(video);
                    }
                }
            }
        }

        CheckForDeepVideos(newVideo);

        recomendedVideos.Shuffle();

        currentState = new BrowserHistoryState();
        currentState.currentVideo = newVideo;
        currentState.isHomePage   = isHomePage;
        currentState.videoDatas   = recomendedVideos;

        return(recomendedVideos);
    }
    public bool GetNextBrowserState(out BrowserHistoryState historyState)
    {
        historyState = new BrowserHistoryState();
        if (forwardBrowserHistory.Count > 0)
        {
            previousBrowserHistory.Push(currentState);
            currentState = forwardBrowserHistory.Pop();
            historyState = currentState;
            return(true);
        }

        return(false);
    }
    public bool GetPreviousBrowserState(out BrowserHistoryState historyState)
    {
        historyState = new BrowserHistoryState();

        if (currentState.isHomePage)
        {
            return(false);
        }

        if (previousBrowserHistory.Count > 0)
        {
            forwardBrowserHistory.Push(currentState);
            currentState = previousBrowserHistory.Pop();
            historyState = currentState;
            return(true);
        }

        return(false);
    }
 public void LoadHistoryState(BrowserHistoryState historyState)
 {
     recomendedVideos?.LoadHistory(historyState);
     UpdateCurrentVideoUI(historyState.currentVideo);
     GenerateComments(historyState.currentVideo);
 }
示例#5
0
 public void LoadHistory(BrowserHistoryState historyState)
 {
     Setup(historyState.videoDatas);
 }