예제 #1
0
        // -------------------------------------------

        /*
         * DestroySlots
         */
        public static void DestroySlots(List <GameObject> _list)
        {
            if (_list != null)
            {
                for (int i = 0; i < _list.Count; i++)
                {
                    if (_list[i] != null)
                    {
                        SlotRequestView sView = _list[i].GetComponent <SlotRequestView>();
                        if (sView != null)
                        {
                            sView.Destroy();
                        }
                    }
                }
                _list.Clear();
            }
        }
        // -------------------------------------------

        /*
         * OnBasicEvent
         */
        private void OnBasicEvent(string _nameEvent, params object[] _list)
        {
            if (!this.gameObject.activeSelf)
            {
                return;
            }

            if (_nameEvent == EVENT_SCREENPROVIDERPROFILE_CLICK_PROPERTY)
            {
                GameObject panelClicked = (GameObject)_list[0];
                int        newValue     = (int)_list[1];
                string     nameProperty = (string)_list[2];
                m_userData.UpdateSingleSkill(nameProperty, newValue);
                for (int i = 0; i < m_skillsPanels.Count; i++)
                {
                    if (panelClicked == m_skillsPanels[i])
                    {
                        m_skillsPanels[i].GetComponent <PanelRatingView>().SetScore(newValue + 1, 1);
                    }
                }
                HasBeenModified = true;
            }
            if (_nameEvent == UsersController.EVENT_USER_RESULT_FORMATTED_SINGLE_RECORD)
            {
                UserModel sUser = (UserModel)_list[0];
                if (sUser != null)
                {
                    m_userData.Copy(sUser);
                    LoadUserData();
                }
            }
            if (_nameEvent == EVENT_SCREENPROVIDERPROFILE_LOAD_USER_DATA_EXPERIENCE)
            {
                // CREATE THE LIST OF EXPERIENCE IMAGES
                SlotRequestView.DestroySlots(m_imagesExperience);
                for (int i = 0; i < m_userData.ImageReferencesExperience.Count; i++)
                {
                    GameObject newImageRequest  = Utilities.AddChild(m_imagesContainer, MenusScreenController.Instance.SlotImage);
                    long       idImageReference = m_userData.ImageReferencesExperience[i].Id;
                    string     urlReference     = m_userData.ImageReferencesExperience[i].Url;
                    m_imagesExperience.Add(newImageRequest);
                    if (m_imageLoadingExperience != null)
                    {
                        m_imageLoadingExperience.gameObject.SetActive(false);
                    }
                    newImageRequest.GetComponent <SlotImageView>().InitializeFromServerData(m_userData.Id, idImageReference, m_isDisplayInfo, false, false, RequestModel.IMAGE_TYPE_REFERENCE, urlReference, false, (m_userData.IsBanned()));
                    newImageRequest.GetComponent <SlotImageView>().DisplayStar = false;
                }

                // LOAD WORKS DONE
                if (m_isDisplayInfo)
                {
                    UIEventController.Instance.DispatchUIEvent(RequestsController.EVENT_REQUEST_CALL_CONSULT_BY_PROVIDER, m_userData.Id, true);
                }
                else
                {
                    UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                }
            }
            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_RECORDS)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                List <RequestModel> data = (List <RequestModel>)_list[0];
                if (m_requestsContainer != null)
                {
                    if ((int)_list[1] == RequestsController.TYPE_CONSULT_BY_PROVIDER)
                    {
                        m_requestsContainer.GetComponent <SlotManagerView>().ClearCurrentGameObject();
                        m_requestsContainer.GetComponent <SlotManagerView>().ClearCurrentRequests();

                        if (data.Count > 0)
                        {
                            // ADD TOXIC AND BROKEN FIRST
                            for (int i = 0; i < data.Count; i++)
                            {
                                RequestModel item = data[i];
                                if ((item.Provider != -1) && item.IsBrokenDeal())
                                {
                                    m_requestsContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                                }
                            }

                            // ADD NORMAL REST
                            for (int i = 0; i < data.Count; i++)
                            {
                                RequestModel item = data[i];
                                if ((item.Provider != -1) && !item.IsBrokenDeal())
                                {
                                    m_requestsContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                                }
                            }
                        }
                        m_requestsContainer.GetComponent <SlotManagerView>().LoadCurrentPage();
                    }
                }
            }
            if (_nameEvent == SlotRequestView.EVENT_SLOTREQUEST_SELECTED_REQUEST)
            {
                GameObject slotClicked = (GameObject)_list[0];
                if (m_userData.IsBanned())
                {
                    string warning     = LanguageController.Instance.GetText("message.warning");
                    string description = LanguageController.Instance.GetText("message.show.nothing.of.user.banned");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
                else
                {
                    if (m_requestsContainer.GetComponent <SlotManagerView>().CheckSlotExisting(slotClicked))
                    {
                        SlotRequestView slotSelected = slotClicked.GetComponent <SlotRequestView>();
                        UIEventController.Instance.DispatchUIEvent(RequestsController.EVENT_REQUEST_CALL_CONSULT_SINGLE_RECORD, slotSelected.Request.Id);
                    }
                }
            }
            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                RequestModel request = (RequestModel)_list[0];
                if (request != null)
                {
                    MenusScreenController.Instance.CreateNewScreen(ScreenCreateRequestView.SCREEN_DISPLAY_REQUEST, UIScreenTypePreviousAction.HIDE_CURRENT_SCREEN, true, request);
                }
                else
                {
                    string warning     = LanguageController.Instance.GetText("message.error");
                    string description = LanguageController.Instance.GetText("message.request.not.found");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
            }
            if (_nameEvent == ScreenFileSystemNavitagorView.EVENT_SCREENSYSTEMNAVIGATOR_FINAL_SELECTION)
            {
                if (_list.Length > 0)
                {
                    if ((bool)_list[0])
                    {
                        string     filePathImage   = (string)_list[1];
                        float      scrollPosition  = 0;
                        GameObject newImageRequest = Utilities.AddChild(m_imagesContainer, MenusScreenController.Instance.SlotImage);
                        newImageRequest.GetComponent <SlotImageView>().Initialize(m_userData.Id, -1, filePathImage, false, false, RequestModel.IMAGE_TYPE_REFERENCE, scrollPosition);
                        newImageRequest.GetComponent <SlotImageView>().DisplayStar = false;
                        m_imagesExperience.Add(newImageRequest);
                    }
                    else
                    {
                        if (_list.Length > 1)
                        {
                            string     urlImage        = (string)_list[1];
                            GameObject newImageRequest = Utilities.AddChild(m_imagesContainer, MenusScreenController.Instance.SlotImage);
                            newImageRequest.GetComponent <SlotImageView>().InitializeWithURL(m_userData.Id, -1, MenusScreenController.Instance.ImageReferenceLink, false, false, RequestModel.IMAGE_TYPE_REFERENCE, urlImage);
                            newImageRequest.GetComponent <SlotImageView>().DisplayStar = false;
                            m_imagesExperience.Add(newImageRequest);
                        }
                    }
                    HasBeenModified = true;
                }
            }
            if (_nameEvent == ImagesController.EVENT_IMAGES_CALL_DELETE_IMAGE)
            {
                GameObject slotImage = (GameObject)_list[0];
                for (int i = 0; i < m_imagesExperience.Count; i++)
                {
                    if (slotImage == m_imagesExperience[i].gameObject)
                    {
                        m_imagesExperience[i].GetComponent <SlotImageView>().Destroy();
                        m_imagesExperience.RemoveAt(i);
                        HasBeenModified = true;
                        break;
                    }
                }
            }
            if (_nameEvent == ScreenController.EVENT_CONFIRMATION_POPUP)
            {
                string subEvent = (string)_list[2];
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                if (subEvent == SUB_EVENT_SCREENPROVIDERPROFILE_SAVE_CONFIRMATION)
                {
                    if ((bool)_list[1])
                    {
                        MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_WAIT, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, LanguageController.Instance.GetText("message.info"), LanguageController.Instance.GetText("message.please.wait"), null, "");
                        UIEventController.Instance.DispatchUIEvent(UsersController.EVENT_USER_UPDATE_PROFILE_REQUEST,
                                                                   UsersController.Instance.CurrentUser.Id.ToString(),
                                                                   UsersController.Instance.CurrentUser.PasswordPlain,
                                                                   UsersController.Instance.CurrentUser.Email,
                                                                   UsersController.Instance.CurrentUser.Nickname,
                                                                   UsersController.Instance.CurrentUser.Village,
                                                                   UsersController.Instance.CurrentUser.Mapdata,
                                                                   m_userData.Skills,
                                                                   m_userData.Description,
                                                                   UsersController.Instance.CurrentUser.PublicKey);
                    }
                    else
                    {
                        string warning     = LanguageController.Instance.GetText("message.warning");
                        string description = LanguageController.Instance.GetText("message.operation.canceled");
                        MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                    }
                }
                if (subEvent == SUB_EVENT_SCREENPROVIDERPROFILE_EXIT_WITHOUT_SAVING)
                {
                    UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                    if ((bool)_list[1])
                    {
                        UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMANAGER_DESTROY_SCREEN, this.gameObject);
                    }
                }
            }
            if (_nameEvent == UsersController.EVENT_USER_UPDATE_PROFILE_RESULT)
            {
                if ((bool)_list[0])
                {
                    if (m_imagesExperience.Count > 0)
                    {
                        m_imagesLeftToConfirmFromUpload = 0;
                        m_imagesExperience[m_imagesLeftToConfirmFromUpload].GetComponent <SlotImageView>().UploadImages(MenusScreenController.TABLE_USERS, (long)m_userData.Id, m_imagesLeftToConfirmFromUpload);
                    }
                    else
                    {
                        UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                        UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMANAGER_DESTROY_SCREEN, this.gameObject);
                    }
                }
                else
                {
                    string warning     = LanguageController.Instance.GetText("message.error");
                    string description = LanguageController.Instance.GetText("message.operation.canceled");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
            }
            if (_nameEvent == ImagesController.EVENT_IMAGES_UPLOAD_TO_SERVER_CONFIRMATION)
            {
                m_imagesLeftToConfirmFromUpload++;
                if (m_imagesLeftToConfirmFromUpload < m_imagesExperience.Count)
                {
                    m_imagesExperience[m_imagesLeftToConfirmFromUpload].GetComponent <SlotImageView>().UploadImages(MenusScreenController.TABLE_USERS, (long)m_userData.Id, m_imagesLeftToConfirmFromUpload);
                }
                else
                {
                    UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                    UIEventController.Instance.DispatchUIEvent(UIEventController.EVENT_SCREENMANAGER_DESTROY_SCREEN, this.gameObject);
                }
            }
            if (_nameEvent == UIEventController.EVENT_SCREENMANAGER_ANDROID_BACK_BUTTON)
            {
                if (m_isDisplayInfo)
                {
                    ExitPressed();
                }
                else
                {
                    ExitEditionPressed();
                }
            }
        }
        // -------------------------------------------

        /*
         * OnBasicEvent
         */
        private void OnBasicEvent(string _nameEvent, params object[] _list)
        {
            if (!this.gameObject.activeSelf)
            {
                return;
            }

            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_RECORDS)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                List <RequestModel> data = (List <RequestModel>)_list[0];
                if ((int)_list[1] == RequestsController.TYPE_CONSULT_BY_USER)
                {
                    m_requestsContainer.GetComponent <SlotManagerView>().ClearCurrentGameObject();
                    m_requestsContainer.GetComponent <SlotManagerView>().ClearCurrentRequests();
                    if (data.Count > 0)
                    {
                        // ADD TOXIC AND BROKEN FIRST
                        for (int i = 0; i < data.Count; i++)
                        {
                            RequestModel item = data[i];
                            if ((item.Customer == m_userData.Id) && (item.IsFlagged() || item.IsBrokenDeal()))
                            {
                                m_requestsContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                            }
                        }

                        // REST OF REQUESTS
                        for (int i = 0; i < data.Count; i++)
                        {
                            RequestModel item = data[i];
                            if ((item.Customer == m_userData.Id) && (!(item.IsFlagged() || item.IsBrokenDeal())))
                            {
                                m_requestsContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                            }
                        }
                    }
                    m_requestsContainer.GetComponent <SlotManagerView>().LoadCurrentPage();
                }
            }
            if (_nameEvent == SlotRequestView.EVENT_SLOTREQUEST_SELECTED_REQUEST)
            {
                GameObject slotClicked = (GameObject)_list[0];
                if (m_userData.IsBanned())
                {
                    string warning     = LanguageController.Instance.GetText("message.warning");
                    string description = LanguageController.Instance.GetText("message.show.nothing.of.user.banned");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
                else
                {
                    if (m_requestsContainer.GetComponent <SlotManagerView>().CheckSlotExisting(slotClicked))
                    {
                        SlotRequestView slotSelected = slotClicked.GetComponent <SlotRequestView>();
                        UIEventController.Instance.DispatchUIEvent(RequestsController.EVENT_REQUEST_CALL_CONSULT_SINGLE_RECORD, slotSelected.Request.Id);
                    }
                }
            }
            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                RequestModel request = (RequestModel)_list[0];
                if (request != null)
                {
                    MenusScreenController.Instance.CreateNewScreen(ScreenCreateRequestView.SCREEN_DISPLAY_REQUEST, UIScreenTypePreviousAction.HIDE_CURRENT_SCREEN, true, request);
                }
                else
                {
                    string warning     = LanguageController.Instance.GetText("message.error");
                    string description = LanguageController.Instance.GetText("message.request.not.found");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
            }
            if (_nameEvent == UIEventController.EVENT_SCREENMANAGER_ANDROID_BACK_BUTTON)
            {
                ExitPressed();
            }
        }
        // -------------------------------------------

        /*
         * OnBasicEvent
         */
        private void OnBasicEvent(string _nameEvent, params object[] _list)
        {
            if (!this.gameObject.activeSelf)
            {
                return;
            }

            if (_nameEvent == EVENT_SCREENOFFERS_LOAD_CURRENT_WORK_ACCEPTED)
            {
                UIEventController.Instance.DispatchUIEvent(RequestsController.EVENT_REQUEST_CALL_CONSULT_BY_PROVIDER, UsersController.Instance.CurrentUser.Id, false);
            }
            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_RECORDS)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                List <RequestModel> data = (List <RequestModel>)_list[0];
                if ((int)_list[1] == RequestsController.TYPE_CONSULT_BY_PROVIDER)
                {
                    m_slotWorksFollowingInfoContainer.GetComponent <SlotManagerView>().ClearCurrentGameObject();
                    m_slotWorksAcceptedInfoContainer.GetComponent <SlotManagerView>().ClearCurrentGameObject();
                    m_slotWorksFinishedInfoContainer.GetComponent <SlotManagerView>().ClearCurrentGameObject();

                    m_slotWorksFollowingInfoContainer.GetComponent <SlotManagerView>().ClearCurrentRequests();
                    m_slotWorksAcceptedInfoContainer.GetComponent <SlotManagerView>().ClearCurrentRequests();
                    m_slotWorksFinishedInfoContainer.GetComponent <SlotManagerView>().ClearCurrentRequests();

                    if (data.Count > 0)
                    {
                        for (int i = 0; i < data.Count; i++)
                        {
                            RequestModel item = data[i];
                            if (!item.IsFlagged())
                            {
                                if (item.Provider == -1)
                                {
                                    m_slotWorksFollowingInfoContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                                }
                                else
                                {
                                    if (item.Deliverydate == -1)
                                    {
                                        m_slotWorksAcceptedInfoContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                                    }
                                    else
                                    {
                                        m_slotWorksFinishedInfoContainer.GetComponent <SlotManagerView>().AddNewRequests(item);
                                    }
                                }
                            }
                        }
                    }
                    m_slotWorksFollowingInfoContainer.GetComponent <SlotManagerView>().LoadCurrentPage();
                    m_slotWorksAcceptedInfoContainer.GetComponent <SlotManagerView>().LoadCurrentPage();
                    m_slotWorksFinishedInfoContainer.GetComponent <SlotManagerView>().LoadCurrentPage();
                }
            }
            if (_nameEvent == SlotRequestView.EVENT_SLOTREQUEST_SELECTED_REQUEST)
            {
                GameObject slotClicked = (GameObject)_list[0];
                if (CheckSlotRequestExisting(slotClicked))
                {
                    SlotRequestView slotSelected = slotClicked.GetComponent <SlotRequestView>();
                    UIEventController.Instance.DispatchUIEvent(RequestsController.EVENT_REQUEST_CALL_CONSULT_SINGLE_RECORD, slotSelected.Request.Id);
                }
            }
            if (_nameEvent == RequestsController.EVENT_REQUEST_RESULT_FORMATTED_SINGLE_RECORD)
            {
                UIEventController.Instance.DispatchUIEvent(ScreenController.EVENT_FORCE_DESTRUCTION_POPUP);
                RequestModel request = (RequestModel)_list[0];
                if (request != null)
                {
                    MenusScreenController.Instance.CreateNewScreen(ScreenCreateRequestView.SCREEN_DISPLAY_REQUEST, UIScreenTypePreviousAction.HIDE_CURRENT_SCREEN, true, request);
                }
                else
                {
                    string warning     = LanguageController.Instance.GetText("message.error");
                    string description = LanguageController.Instance.GetText("message.request.not.found");
                    MenusScreenController.Instance.CreateNewInformationScreen(ScreenInformationView.SCREEN_INFORMATION, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, warning, description, null, "");
                }
            }
            if (_nameEvent == UIEventController.EVENT_SCREENMANAGER_ANDROID_BACK_BUTTON)
            {
                BackPressed();
            }
        }