Example #1
0
    private void LoadDialogs()
    {
        m_collectionPersonData = new Queue <SceneDialogPerson>();
        if (DialogPersonPrefab == null)
        {
            Debug.Log("########## LoadDialogs NOT set DialogPersonPrefab");
            return;
        }

        m_poolDialogPersonPrefabs = new List <CaseSceneDialogPerson>();
        foreach (var i in Enumerable.Range(0, m_maxPoolDialogs))
        {
            GameObject dialog = Instantiate(DialogPersonPrefab);
            dialog.transform.position = new Vector3(0, 0, 0);
            dialog.transform.SetParent(null);
            dialog.SetActive(false);
            dialog.name = "DialogPerson_" + i;

            CaseSceneDialogPerson caseDialog = new CaseSceneDialogPerson()
            {
                Dialog = dialog
            };
            m_poolDialogPersonPrefabs.Add(caseDialog);
        }
        ;
    }
Example #2
0
 public void UpdateTargetDialog(CaseSceneDialogPerson caseDialog, SceneDialogPerson data, string modelViewTarget)
 {
     if (data.Data == null)
     {
         return; //fix null:Data
     }
     //Storage.EventsUI.ListLogAdd = "UpdateTargetDialog...........";
     caseDialog.ModelViewTarget = modelViewTarget;
     caseDialog.Activate(data, true);
 }
Example #3
0
    public CaseSceneDialogPerson CreateTargetDialog(SceneDialogPerson data, string modelViewTarget)
    {
        //CaseSceneDialogPerson caseDialog = GetFreeDialog(new SceneDialogPerson());
        CaseSceneDialogPerson caseDialog = GetFreeDialog(data, isTarget: true);

        if (caseDialog == null)
        {
            caseDialog = GetFreeDialog(isForce: true);
        }
        if (caseDialog == null)
        {
            Storage.EventsUI.ListLogAdd = "#### CASE DEBUG -- EMPTY";
            Debug.Log("######### FillDialogsFromData caseDialog is empty");
            return(null);
        }
        caseDialog.ModelViewTarget = modelViewTarget;
        caseDialog.Activate(data, true);
        return(caseDialog);
    }
Example #4
0
    public void FillDialogsFromData()
    {
        if (!SettingsScene.AutoRefreshOn)
        {
            Storage.EventsUI.ListLogAdd = "IN DEBUG COUNT >>  " + m_collectionPersonData.Count;
        }

        while (m_collectionPersonData.Count > 0)
        {
            SceneDialogPerson data = m_collectionPersonData.Dequeue();
            if (data == null)
            {
                Debug.Log(Storage.EventsUI.ListLogAdd = "#### FillDialogsFromData -- data is EMPTY");
                break;
            }
            if (data.Data == null)
            {
                return; //fix null:Data
            }
            CaseSceneDialogPerson caseDialog = GetFreeDialog(data);
            if (caseDialog == null)
            {
                caseDialog = GetFreeDialog(isForce: true);
            }
            if (caseDialog == null)
            {
                Storage.EventsUI.ListLogAdd = "#### CASE DEBUG -- EMPTY";
                Debug.Log("######### FillDialogsFromData caseDialog is empty");
                break;
            }
            caseDialog.Activate(data);

            if (!SettingsScene.AutoRefreshOn)
            {
                Storage.EventsUI.ListLogAdd = "DEBUG ++ >> " + data.Data.NameObject;
            }
        }
    }
Example #5
0
    private CaseSceneDialogPerson GetFreeDialog(SceneDialogPerson p_Data = null, bool isForce = false, bool thisIsTarget = false, DialogSceneInfo.ModeInfo filerNot = DialogSceneInfo.ModeInfo.Target, bool isTarget = false)
    {
        bool isFindedMe = false;

        if (m_poolDialogPersonPrefabs == null || m_poolDialogPersonPrefabs.Count == 0)
        {
            return(null);
        }

        string _vip = VipID ?? "?";

        CaseSceneDialogPerson findCase = null;

        if (isForce)
        {
            Debug.Log(Storage.EventsUI.ListLogAdd = "#### GetFreeDialog isForce");
            findCase = m_poolDialogPersonPrefabs.OrderBy(p => p.TimeCreate).Where(p => p.Person.ID != _vip).FirstOrDefault();
        }
        else
        {
            if (p_Data != null)
            {
                //Find Exist
                if (!isTarget)
                {
                    findCase = m_poolDialogPersonPrefabs.Find(
                        p => p.Person != null &&
                        p.Person.Data != null &&
                        p.Person.ID == p_Data.ID &&
                        p.ModeInfo != filerNot);
                }
                else
                {
                    //find last view case
                    findCase = m_poolDialogPersonPrefabs.Find(
                        p => p.Person != null &&
                        p.Person.Data != null &&
                        p.Person.ID == p_Data.ID &&
                        p.ModeInfo != DialogSceneInfo.ModeInfo.Person);
                }
            }

            if (findCase != null)
            {
                isFindedMe = true;
            }
            else
            {
                //findCase = m_poolDialogPersonPrefabs.Where(p => !p.IsLock).FirstOrDefault();
                findCase = m_poolDialogPersonPrefabs.Where(p => !p.IsLock &&
                                                           p.ModeInfo != filerNot).FirstOrDefault();
            }

            if (findCase != null && findCase.Person != null && findCase.Person.ID == _vip)
            {
                try
                {
                    //!!!! NullReferenceException: Object reference not set to an instance of an object
                    return(m_poolDialogPersonPrefabs.Where(p => !p.IsLock && p.Person.ID != _vip).FirstOrDefault());
                }
                catch (System.Exception ex)
                {
                    Debug.Log(Storage.EventsUI.ListLogAdd = "### GetFreeDialog : " + ex.Message);
                    ClearTemplate();
                    DialogsClear();
                    RefreshDialogs();
                    return(null);
                }
            }
            if (findCase == null)//force
            {
                //Debug.Log(Storage.EventsUI.ListLogAdd = "#### GetFreeDialog isForce on time");
                //Storage.EventsUI.ListLogAdd = "#### GetFreeDialog isForce on time";
                //findCase = m_poolDialogPersonPrefabs.OrderBy(p => p.TimeCreate).Where(p => p.Person.ID != _vip).FirstOrDefault(); ;
                findCase = m_poolDialogPersonPrefabs.OrderBy(p => p.TimeCreate).Where(p => p.Person.ID != _vip &&
                                                                                      p.ModeInfo != filerNot).FirstOrDefault();
            }
        }

        if (findCase != null && findCase.IsLock && isFindedMe == false)
        {
            findCase.Deactivate();
        }

        return(findCase);
    }