상속: FlowData
예제 #1
0
    private void OnDestroy()
    {
        StopAllCoroutines();

        if (m_LoadingScreen != null)
        {
            Destroy(m_LoadingScreen);
            m_LoadingScreen = null;
        }
        if (m_Overlay != null)
        {
            Destroy(m_Overlay);
            m_Overlay = null;
        }

        m_Instance         = null;
        m_ActionController = null;
        m_OpenedViews.Clear();
        m_OpenedViews = null;
        m_ClosedViews.Clear();
        m_ClosedViews = null;
        m_OpeningView = null;
        m_ClosingViews.Clear();
        m_ClosingViews      = null;
        m_GainingFocusView  = null;
        m_LosingFocusView   = null;
        m_CurrentActionData = null;
        m_QueuedActions.Clear();
        m_QueuedActions = null;
    }
예제 #2
0
    public virtual void OpenView(FlowViewData viewData, FlowActionData actionData)
    {
        m_State = eState.OPENING;
        m_ViewData = viewData;

        OnViewOpened();
    }
예제 #3
0
    public virtual void OpenView(FlowViewData viewData, FlowActionData actionData)
    {
        m_State    = eState.OPENING;
        m_ViewData = viewData;

        OnViewOpened();
    }
예제 #4
0
    public override void OpenView(FlowViewData viewData, FlowActionData actionData)
    {
        base.OpenView(viewData, actionData);

        LoadHand(1);
        LoadHand(2);
    }
예제 #5
0
    private void LoadData()
    {
        TextAsset xmlFile = Resources.Load(FLOW_XML_PATH) as TextAsset;

        if (xmlFile != null && xmlFile.text != "")
        {
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(xmlFile.text);

            // First, find the root.
            foreach (XmlNode baseNode in xmlDocument.GetElementsByTagName("flow"))
            {
                LoadFlowData(baseNode);

                // Find the action nodes.
                foreach (XmlNode viewNode in baseNode.ChildNodes)
                {
                    // First look for the views.
                    List <FlowActionData> viewActionsData = new List <FlowActionData>();
                    FlowViewData          viewData        = LoadViewData(viewNode, ref viewActionsData);
                    if (viewData != null)
                    {
                        m_ViewsData.Add(viewData.ViewId, viewData);

                        // Add it to the view action data list.
                        foreach (FlowActionData actionData in viewActionsData)
                        {
                            Dictionary <string, FlowActionData> actionsData = null;
                            if (m_ViewActionsData.ContainsKey(viewData.ViewId))
                            {
                                actionsData = m_ViewActionsData[viewData.ViewId];
                                if (!actionsData.ContainsKey(actionData.ActionName))
                                {
                                    actionsData.Add(actionData.ActionName, actionData);
                                }
                            }
                            else
                            {
                                actionsData = new Dictionary <string, FlowActionData>();
                                actionsData.Add(actionData.ActionName, actionData);
                                m_ViewActionsData.Add(viewData.ViewId, actionsData);
                            }
                        }
                    }
                    // Then, for global actions.
                    else
                    {
                        FlowActionData actionData = LoadActionData(viewNode);

                        // Add it to the action data list.
                        if (actionData != null && !m_ActionsData.ContainsKey(actionData.ActionName))
                        {
                            m_ActionsData.Add(actionData.ActionName, actionData);
                        }
                    }
                }
            }
        }
    }
예제 #6
0
    public FlowViewData Clone()
    {
        // Remember to always keep this function up to date.
        FlowViewData viewData = new FlowViewData(ViewId, ViewName);
        foreach (string parameterKey in m_Parameters.Keys)
        {
            viewData.AddParameter(parameterKey, m_Parameters[parameterKey]);
        }

        return viewData;
    }
예제 #7
0
    public FlowViewData Clone()
    {
        // Remember to always keep this function up to date.
        FlowViewData viewData = new FlowViewData(ViewId, ViewName);

        foreach (string parameterKey in m_Parameters.Keys)
        {
            viewData.AddParameter(parameterKey, m_Parameters[parameterKey]);
        }

        return(viewData);
    }
예제 #8
0
    public override void OpenView(FlowViewData viewData, FlowActionData actionData)
    {
        base.OpenView(viewData, actionData);

        object levelIdObj = actionData.GetParameterValue("LEVEL_ID");

        if (levelIdObj != null)
        {
            LoadLevelList(int.Parse(levelIdObj.ToString()));
        }
        else
        {
            LoadLevelList();
        }

        LoadNextLevel(true);
    }
예제 #9
0
    private IEnumerator LoadView(FlowViewData viewData, FlowActionData actionData)
    {
        // Let the loading screen appearing.
        if (actionData.UseLoadingScreen)
        {
            yield return(new WaitForSeconds(m_ActionController.LoadingMinDuration));
        }

        // TODO ppoirier: Ideally, we should do an async call.
        Application.LoadLevelAdditive(viewData.ViewName);

        // TODO ppoirier: Seems necessary when not on a Pro licence.
        yield return(null);

        GameObject viewObj = GameObject.Find(viewData.ViewName);

        if (viewObj != null)
        {
            viewObj.transform.parent   = transform;
            viewObj.transform.position = new Vector3(0.0f, 0.0f, m_OpenedViews.Count * -m_ActionController.ViewDepth);

            View view = viewObj.GetComponent <View>();
            if (view != null)
            {
                // Display overlay if requested/necessary.
                m_Overlay.transform.position = new Vector3(0.0f, 0.0f, m_OpenedViews.Count * -m_ActionController.ViewDepth + m_ActionController.OverlayOffset);
                m_Overlay.SetActive(actionData.IsPopup && actionData.UseOverlay);

                view.name = viewData.ViewId;
                view.OpenView(viewData, actionData);
            }
            else
            {
                Destroy(viewObj);
                Debug.LogError("FlowManager, LoadView: The scene '" + viewData.ViewName + "' must have a 'View' script attached to it.");
            }
        }
        else
        {
            Debug.LogError("FlowManager, LoadView: Cannot load scene '" + viewData.ViewName + "'.");
        }
    }
예제 #10
0
    private FlowViewData LoadViewData(XmlNode viewNode, ref List <FlowActionData> actionsData)
    {
        FlowViewData viewData = null;

        if (viewNode.Name == "view")
        {
            string viewId   = "";
            string viewName = "";
            foreach (XmlAttribute viewAttributes in viewNode.Attributes)
            {
                if (viewAttributes.Name == "id")
                {
                    viewId = viewAttributes.Value;
                }
                else if (viewAttributes.Name == "name")
                {
                    viewName = viewAttributes.Value;
                }
            }

            // Keep the string item only if it has a key.
            if (!string.IsNullOrEmpty(viewId) && !string.IsNullOrEmpty(viewName))
            {
                viewData = new FlowViewData(viewId, viewName);
                viewData.AddParameters(LoadParameters(viewNode));

                foreach (XmlNode actionNode in viewNode.ChildNodes)
                {
                    FlowActionData actionData = LoadActionData(actionNode);
                    if (actionData != null)
                    {
                        actionsData.Add(actionData);
                    }
                }
            }
        }

        return(viewData);
    }
예제 #11
0
    private FlowViewData LoadViewData(XmlNode viewNode, ref List<FlowActionData> actionsData)
    {
        FlowViewData viewData = null;
        if (viewNode.Name == "view")
        {
            string viewId = "";
            string viewName = "";
            foreach (XmlAttribute viewAttributes in viewNode.Attributes)
            {
                if (viewAttributes.Name == "id")
                {
                    viewId = viewAttributes.Value;
                }
                else if (viewAttributes.Name == "name")
                {
                    viewName = viewAttributes.Value;
                }
            }

            // Keep the string item only if it has a key.
            if (!string.IsNullOrEmpty(viewId) && !string.IsNullOrEmpty(viewName))
            {
                viewData = new FlowViewData(viewId, viewName);
                viewData.AddParameters(LoadParameters(viewNode));

                foreach (XmlNode actionNode in viewNode.ChildNodes)
                {
                    FlowActionData actionData = LoadActionData(actionNode);
                    if (actionData != null)
                    {
                        actionsData.Add(actionData);
                    }
                }
            }
        }

        return viewData;
    }
예제 #12
0
 protected virtual void OnDestroy()
 {
     m_ViewData = null;
 }
예제 #13
0
    private void TriggerNextAction()
    {
        if (!IsBusy && m_QueuedActions.Count > 0)
        {
            // Get the first in action in queue.
            m_CurrentActionData = m_QueuedActions[0];
            FlowViewData viewData = m_ActionController.GetViewData(m_CurrentActionData.ViewId);

            m_QueuedActions.Remove(m_CurrentActionData);

            View topView = GetTopView();
            if (topView != null && viewData != null && viewData.ViewId == topView.ViewData.ViewId)
            {
                topView.HandleAction(m_CurrentActionData);

                TriggerNextAction();
            }
            else if (string.IsNullOrEmpty(m_CurrentActionData.ViewId) || viewData != null)
            {
                // Find if the view is already opened.
                for (int i = m_OpenedViews.Count - 1; i >= 0; --i)
                {
                    View view = m_OpenedViews[i];

                    // If already in the queue, it gains the focus.
                    if ((string.IsNullOrEmpty(m_CurrentActionData.ViewId) && view.ViewData == GetBeforeTopView()) ||
                        (viewData != null && view.ViewData.ViewId == viewData.ViewId))
                    {
                        m_GainingFocusView = view;

                        // If a popup, or we are closing the top view.
                        if (string.IsNullOrEmpty(m_CurrentActionData.ViewId) || m_CurrentActionData.IsPopup)
                        {
                            // Close all popup on higher levels than one opening.
                            for (int j = i + 1; j < m_OpenedViews.Count; ++j)
                            {
                                if (m_LosingFocusView == m_OpenedViews[j])
                                {
                                    m_LosingFocusView = null;
                                }
                                m_ClosingViews.Add(m_OpenedViews[j]);
                            }
                        }
                    }
                    // If not in the queue, close/hide the other ones.
                    // We don't want to close view in the case we're just closing the top one.
                    else if (!string.IsNullOrEmpty(m_CurrentActionData.ViewId))
                    {
                        // If we are opening a popup, hide them.
                        if (m_CurrentActionData.IsPopup)
                        {
                            // If it's the top view.
                            if (topView != null && view.ViewData == topView.ViewData)
                            {
                                // Losing focus because we are opening a new view.
                                m_LosingFocusView = view;
                            }
                        }
                        // If we are not opening a popup, close everything.
                        else
                        {
                            m_ClosingViews.Add(view);
                        }
                    }
                }

                // If nothing is gaining focus, we open a new view.
                if (viewData != null && m_GainingFocusView == null)
                {
                    m_OpeningView = viewData;
                }

                // Display the loading screen if requested.
                if (m_OpeningView != null && m_CurrentActionData.UseLoadingScreen)
                {
                    m_LoadingScreen.transform.position = new Vector3(0.0f, 0.0f, (m_OpenedViews.Count + 1) * -m_ActionController.ViewDepth);
                    m_LoadingScreen.SetActive(true);
                }

                TriggerNextView();
            }
            else
            {
                Debug.LogError("FlowManager, TriggerNextAction: Cannot trigger '" + m_CurrentActionData.ActionName + "' in current scene (" + (viewData == null ? "NONE" : viewData.ViewId) + ").");
                TriggerNextAction();
            }
        }
    }
예제 #14
0
    public void OnViewCompleted(View view)
    {
        switch (view.State)
        {
        case View.eState.OPENED:
            if (m_OpeningView == view.ViewData)
            {
                m_OpeningView = null;
                m_OpenedViews.Add(view);
            }
            else if (m_GainingFocusView == view)
            {
                m_GainingFocusView = null;

                // Put the view at the end of the queue.
                m_OpenedViews.Remove(view);
                m_OpenedViews.Add(view);
            }
            break;

        case View.eState.CLOSED:
            if (m_ClosingViews.Contains(view))
            {
                m_ClosingViews.Remove(view);
                m_OpenedViews.Remove(view);

                // Destroy immediately if using loading screen.
                if (m_CurrentActionData.UseLoadingScreen)
                {
                    Destroy(view.gameObject);
                }
                // Postpone destroying to the end of the sequence.
                else
                {
                    m_ClosedViews.Add(view);
                }
            }
            break;

        case View.eState.FOCUS_LOST:
            if (m_LosingFocusView == view)
            {
                m_LosingFocusView = null;
            }
            break;
        }

        if (!TriggerNextView())
        {
            // Destroy when everything is loaded.
            foreach (View closedView in m_ClosedViews)
            {
                // Destroy it.
                Destroy(closedView.gameObject);
            }
            m_ClosedViews.Clear();

            // Hide the loading screen.
            m_LoadingScreen.SetActive(false);

            TriggerNextAction();
        }
    }
예제 #15
0
    private IEnumerator LoadView(FlowViewData viewData, FlowActionData actionData)
    {
        // Let the loading screen appearing.
        if (actionData.UseLoadingScreen)
        {
            yield return new WaitForSeconds(m_ActionController.LoadingMinDuration);
        }

        // TODO ppoirier: Ideally, we should do an async call.
        Application.LoadLevelAdditive(viewData.ViewName);

        // TODO ppoirier: Seems necessary when not on a Pro licence.
        yield return null;

        GameObject viewObj = GameObject.Find(viewData.ViewName);
        if (viewObj != null)
        {
            viewObj.transform.parent = transform;
            viewObj.transform.position = new Vector3(0.0f, 0.0f, m_OpenedViews.Count * -m_ActionController.ViewDepth);

            View view = viewObj.GetComponent<View>();
            if (view != null)
            {
                // Display overlay if requested/necessary.
                m_Overlay.transform.position = new Vector3(0.0f, 0.0f, m_OpenedViews.Count * -m_ActionController.ViewDepth + m_ActionController.OverlayOffset);
                m_Overlay.SetActive(actionData.IsPopup && actionData.UseOverlay);

                view.name = viewData.ViewId;
                view.OpenView(viewData, actionData);
            }
            else
            {
                Destroy(viewObj);
                Debug.LogError("FlowManager, LoadView: The scene '" + viewData.ViewName + "' must have a 'View' script attached to it.");
            }
        }
        else
        {
            Debug.LogError("FlowManager, LoadView: Cannot load scene '" + viewData.ViewName + "'.");
        }
    }
예제 #16
0
    public void OnViewCompleted(View view)
    {
        switch (view.State)
        {
        case View.eState.OPENED:
            if (m_OpeningView == view.ViewData)
            {
                m_OpeningView = null;
                m_OpenedViews.Add(view);
            }
            else if (m_GainingFocusView == view)
            {
                m_GainingFocusView = null;

                // Put the view at the end of the queue.
                m_OpenedViews.Remove(view);
                m_OpenedViews.Add(view);
            }
            break;
        case View.eState.CLOSED:
            if (m_ClosingViews.Contains(view))
            {
                m_ClosingViews.Remove(view);
                m_OpenedViews.Remove(view);

                // Destroy immediately if using loading screen.
                if (m_CurrentActionData.UseLoadingScreen)
                {
                    Destroy(view.gameObject);
                }
                // Postpone destroying to the end of the sequence.
                else
                {
                    m_ClosedViews.Add(view);
                }
            }
            break;
        case View.eState.FOCUS_LOST:
            if (m_LosingFocusView == view)
            {
                m_LosingFocusView = null;
            }
            break;
        }

        if (!TriggerNextView())
        {
             // Destroy when everything is loaded.
            foreach (View closedView in m_ClosedViews)
            {
                // Destroy it.
                Destroy(closedView.gameObject);
            }
            m_ClosedViews.Clear();

            // Hide the loading screen.
            m_LoadingScreen.SetActive(false);

            TriggerNextAction();
        }
    }
예제 #17
0
    private void TriggerNextAction()
    {
        if (!IsBusy && m_QueuedActions.Count > 0)
        {
            // Get the first in action in queue.
            m_CurrentActionData = m_QueuedActions[0];
            FlowViewData viewData = m_ActionController.GetViewData(m_CurrentActionData.ViewId);

            m_QueuedActions.Remove(m_CurrentActionData);

            View topView = GetTopView();
            if (topView != null && viewData != null && viewData.ViewId == topView.ViewData.ViewId)
            {
                topView.HandleAction(m_CurrentActionData);

                TriggerNextAction();
            }
            else if (string.IsNullOrEmpty(m_CurrentActionData.ViewId) || viewData != null)
            {
                // Find if the view is already opened.
                for (int i = m_OpenedViews.Count - 1; i >= 0; --i)
                {
                    View view = m_OpenedViews[i];

                    // If already in the queue, it gains the focus.
                    if ((string.IsNullOrEmpty(m_CurrentActionData.ViewId) && view.ViewData == GetBeforeTopView()) ||
                        (viewData != null && view.ViewData.ViewId == viewData.ViewId))
                    {
                        m_GainingFocusView = view;

                        // If a popup, or we are closing the top view.
                        if (string.IsNullOrEmpty(m_CurrentActionData.ViewId) || m_CurrentActionData.IsPopup)
                        {
                            // Close all popup on higher levels than one opening.
                            for (int j = i + 1; j < m_OpenedViews.Count; ++j)
                            {
                                if (m_LosingFocusView == m_OpenedViews[j])
                                {
                                    m_LosingFocusView = null;
                                }
                                m_ClosingViews.Add(m_OpenedViews[j]);
                            }
                        }
                    }
                    // If not in the queue, close/hide the other ones.
                    // We don't want to close view in the case we're just closing the top one.
                    else if (!string.IsNullOrEmpty(m_CurrentActionData.ViewId))
                    {
                        // If we are opening a popup, hide them.
                        if (m_CurrentActionData.IsPopup)
                        {
                            // If it's the top view.
                            if (topView != null && view.ViewData == topView.ViewData)
                            {
                                // Losing focus because we are opening a new view.
                                m_LosingFocusView = view;
                            }
                        }
                        // If we are not opening a popup, close everything.
                        else
                        {
                            m_ClosingViews.Add(view);
                        }
                    }
                }

                // If nothing is gaining focus, we open a new view.
                if (viewData != null && m_GainingFocusView == null)
                {
                    m_OpeningView = viewData;
                }

                // Display the loading screen if requested.
                if (m_OpeningView != null && m_CurrentActionData.UseLoadingScreen)
                {
                    m_LoadingScreen.transform.position = new Vector3(0.0f, 0.0f, (m_OpenedViews.Count + 1) * -m_ActionController.ViewDepth);
                    m_LoadingScreen.SetActive(true);
                }

                TriggerNextView();
            }
            else
            {
                Debug.LogError("FlowManager, TriggerNextAction: Cannot trigger '" + m_CurrentActionData.ActionName + "' in current scene (" + (viewData == null ? "NONE" : viewData.ViewId) + ").");
                TriggerNextAction();
            }
        }
    }
예제 #18
0
    private void OnDestroy()
    {
        StopAllCoroutines();

        if (m_LoadingScreen != null)
        {
            Destroy(m_LoadingScreen);
            m_LoadingScreen = null;
        }
        if (m_Overlay != null)
        {
            Destroy(m_Overlay);
            m_Overlay = null;
        }

        m_Instance = null;
        m_ActionController = null;
        m_OpenedViews.Clear();
        m_OpenedViews = null;
        m_ClosedViews.Clear();
        m_ClosedViews = null;
        m_OpeningView = null;
        m_ClosingViews.Clear();
        m_ClosingViews = null;
        m_GainingFocusView = null;
        m_LosingFocusView = null;
        m_CurrentActionData = null;
        m_QueuedActions.Clear();
        m_QueuedActions = null;
    }
예제 #19
0
 protected virtual void OnDestroy()
 {
     m_ViewData = null;
 }
예제 #20
0
    public override void OpenView(FlowViewData viewData, FlowActionData actionData)
    {
        base.OpenView(viewData, actionData);

        object levelIdObj = actionData.GetParameterValue("LEVEL_ID");
        if (levelIdObj != null)
        {
            LoadLevelList(int.Parse(levelIdObj.ToString()));
        }
        else
        {
            LoadLevelList();
        }

        LoadNextLevel(true);
    }