Example #1
0
        public void Deactivate()
        {
            if (!IsLock)
            {
                return;
            }
            //if (m_dialogView == null)
            //    return;

            if (ModeInfo == DialogSceneInfo.ModeInfo.Person)
            {
                //m_dialogView = Dialog.GetComponent<DialogSceneInfo>();
                var caseTarget = m_dialogView.CaseDialogTarget;
                if (caseTarget != null && caseTarget.IsLock)
                {
                    //Debug.Log(Storage.EventsUI.ListLogAdd = "+++ Deactivate ...." + caseTarget.ModelViewTarget);

                    caseTarget.ModeInfo = DialogSceneInfo.ModeInfo.Target;
                    caseTarget.Deactivate();
                }
                //m_dialogView.Deactivate();

                //TEST
                //if (caseTarget == null)
                //{
                //    Debug.Log(Storage.EventsUI.ListLogAdd = "#### Deactivate() CaseDialogTarget -- EMPTY");
                //}
            }
            m_dialogView.Deactivate();

            if (Dialog != null)
            {
                Dialog.name = "DialogPerson_empty";
                Dialog.transform.position = Vector3.zero;
                Dialog.SetActive(false);
            }
            else
            {
                Debug.Log(Storage.EventsUI.ListLogAdd = "#### Deactivate Dialog -- EMPTY");
            }


            ModeInfo = DialogSceneInfo.ModeInfo.Person;
            IsLock   = false;
        }
Example #2
0
        public void Activate(SceneDialogPerson p_Data, bool isTarget = false)
        {
            IsLock = true;
            Person = p_Data;
            if (Dialog != null)
            {
                if (Person.Data != null)
                {
                    if (isTarget)
                    {
                        Dialog.transform.position = p_Data.TargetPosition;
                    }
                    else
                    {
                        Dialog.transform.position = p_Data.Position;
                    }


                    Dialog.SetActive(true);
                    if (isTarget)
                    {
                        Dialog.name = "Dialog_Target_" + ModelViewTarget + "_" + p_Data.NameObject;
                    }
                    else
                    {
                        Dialog.name = "Dialog_" + p_Data.NameObject;
                    }

                    //if (m_dialogView == null)
                    m_dialogView = Dialog.GetComponent <DialogSceneInfo>();

                    ModeInfo = isTarget ? DialogSceneInfo.ModeInfo.Target : DialogSceneInfo.ModeInfo.Person;
                    m_dialogView.DialogModelViewTarget = ModelViewTarget;
                    //IsLock = true;
                    m_dialogView.InitDialogView(this, ModeInfo);
                }
            }
            else
            {
                Debug.Log("######### CaseSceneDialogPerson Dialog is NULL");
            }
            TimeCreate = Time.time;
            //IsLock = true;
        }
Example #3
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);
    }