Example #1
0
 public EzGetMoldModelResult(
     GetMoldModelResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzMoldModel(result.item);
     }
 }
Example #2
0
        public IEnumerator Run(
            Client client,
            GameSession session,
            string formationNamespaceName,
            string moldModelName,
            GetMoldModelEvent onGetMoldModel,
            GetFormEvent onGetForm,
            UpdateFormEvent onUpdateForm,
            ErrorEvent onError
            )
        {
            if (_watching)
            {
                throw new InvalidOperationException("already started");
            }

            _watching = true;

            _client  = client;
            _session = session;
            _formationNamespaceName = formationNamespaceName;
            _moldModelName          = moldModelName;
            _onGetMoldModel         = onGetMoldModel;
            _onGetForm    = onGetForm;
            _onUpdateForm = onUpdateForm;
            _onError      = onError;

            void GetMoldModelAction(
                string formationNamespaceNameTmp,
                EzMoldModel moldModel
                )
            {
                if (formationNamespaceNameTmp != _formationNamespaceName)
                {
                    return;
                }

                _moldModel = moldModel;

                _onGetMoldModel.RemoveListener(GetMoldModelAction);
            }

            _onGetMoldModel.AddListener(GetMoldModelAction);

            yield return(FormationController.GetMoldModel(
                             _client,
                             formationNamespaceName,
                             moldModelName,
                             onGetMoldModel,
                             onError
                             ));

            _onGetForm.AddListener(GetFormAction);

            yield return(Refresh());
        }
 public EzGetMoldResult(
     GetMoldResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzMold(result.item);
     }
     if (result.moldModel != null)
     {
         MoldModel = new EzMoldModel(result.moldModel);
     }
 }
Example #4
0
 public void OnChangeFormation(
     EzMoldModel moldModel,
     int index,
     EzForm form
     )
 {
     _rows[index].Initialize(
         _inventoryWatcher,
         _formationWatcher,
         index,
         false,
         onChoiceParty,
         new ChoiceSlotEvent()
         );
 }
Example #5
0
        public static IEnumerator ListForms(
            Client client,
            GameSession session,
            string formationNamespaceName,
            EzMoldModel moldModel,
            GetFormEvent onGetForm,
            ErrorEvent onError
            )
        {
            var    forms     = new List <EzForm>();
            string pageToken = null;

            while (true)
            {
                AsyncResult <EzListFormsResult> result = null;
                yield return(client.Formation.ListForms(
                                 r =>
                {
                    result = r;
                },
                                 session,
                                 formationNamespaceName,
                                 moldModel.Name,
                                 pageToken
                                 ));

                if (result.Error != null)
                {
                    onError.Invoke(
                        result.Error
                        );
                    yield break;
                }

                forms.AddRange(result.Result.Items);
                pageToken = result.Result.NextPageToken;

                if (pageToken == null)
                {
                    break;
                }
            }

            for (var i = 0; i < forms.Count; i++)
            {
                onGetForm.Invoke(moldModel, i, forms[i]);
            }
        }
Example #6
0
        void OnChangeFormation(
            EzMoldModel moldModel,
            int moldIndex,
            EzForm form
            )
        {
            if (_form.Index != form.Index)
            {
                return;
            }

            OnChangeInventory(
                _unitWatcher.Inventory,
                _unitWatcher.ItemSets
                );
        }
Example #7
0
        private void GetFormAction(
            EzMoldModel moldModelTemp,
            int index,
            EzForm form
            )
        {
            if (moldModelTemp.Name != _moldModel.Name)
            {
                return;
            }

            while (_forms.Count <= index)
            {
                _forms.Add(null);
            }
            _forms[index] = form;

            onWatchFormation.Invoke(_moldModel, index, form);
        }
Example #8
0
        public static IEnumerator SetForm(
            Client client,
            GameSession session,
            string formationNamespaceName,
            EzMoldModel moldModel,
            int index,
            List <EzSlotWithSignature> slots,
            string signatureKeyId,
            GetFormEvent onGetForm,
            UpdateFormEvent onUpdateForm,
            ErrorEvent onError
            )
        {
            AsyncResult <EzSetFormResult> result = null;

            yield return(client.Formation.SetForm(
                             r =>
            {
                result = r;
            },
                             session,
                             formationNamespaceName,
                             moldModel.Name,
                             index,
                             slots,
                             signatureKeyId
                             ));

            if (result.Error != null)
            {
                onError.Invoke(
                    result.Error
                    );
                yield break;
            }

            var form = result.Result.Item;

            onUpdateForm.Invoke(moldModel, index, form);
            onGetForm.Invoke(moldModel, index, form);
        }
 public EzGetFormResult(
     GetFormResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzForm(result.item);
     }
     if (result.mold != null)
     {
         Mold = new EzMold(result.mold);
     }
     if (result.moldModel != null)
     {
         MoldModel = new EzMoldModel(result.moldModel);
     }
     if (result.formModel != null)
     {
         FormModel = new EzFormModel(result.formModel);
     }
 }
Example #10
0
 public EzSetFormResult(
     SetFormWithSignatureResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzForm(result.item);
     }
     if (result.mold != null)
     {
         Mold = new EzMold(result.mold);
     }
     if (result.moldModel != null)
     {
         MoldModel = new EzMoldModel(result.moldModel);
     }
     if (result.formModel != null)
     {
         FormModel = new EzFormModel(result.formModel);
     }
 }
Example #11
0
 public EzGetFormWithSignatureResult(
     GetFormWithSignatureResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzForm(result.item);
     }
     Body      = result.body;
     Signature = result.signature;
     if (result.mold != null)
     {
         Mold = new EzMold(result.mold);
     }
     if (result.moldModel != null)
     {
         MoldModel = new EzMoldModel(result.moldModel);
     }
     if (result.formModel != null)
     {
         FormModel = new EzFormModel(result.formModel);
     }
 }
Example #12
0
        public void OnChangeFormation(
            EzMoldModel moldModel,
            int moldIndex,
            EzForm form
            )
        {
            if (_index != moldIndex)
            {
                return;
            }

            var unitGameObjects = new List <MonoBehaviour>();

            void ClearChoicePanel()
            {
                foreach (var unitGameObject in unitGameObjects)
                {
                    for (var i = 0; i < unitGameObject.transform.childCount; i++)
                    {
                        var childGameObject = unitGameObject.transform.GetChild(i);
                        if (childGameObject.name.StartsWith("Choice"))
                        {
                            Destroy(childGameObject.gameObject);
                        }
                    }
                }
            }

            for (var i = 0; i < horizontalLayoutGroup.transform.childCount; i++)
            {
                Destroy(horizontalLayoutGroup.transform.GetChild(i).gameObject);
            }

            for (var i = 0; i < moldModel.FormModel.Slots.Count; i++)
            {
                var slot = form?.Slots?.FirstOrDefault(v => v?.Name == i.ToString());

                MonoBehaviour item;
                if (slot?.PropertyId == null)
                {
                    item = Instantiate(unitItemEmptyPrefab, horizontalLayoutGroup.transform);
                }
                else
                {
                    var unitItem = Instantiate(unitItemPrefab, horizontalLayoutGroup.transform);
                    unitItem.Initialize(
                        _inventoryWatcher.ItemModels.FirstOrDefault(itemModel =>
                                                                    itemModel.Name == ItemSet.GetItemNameFromGrn(slot.PropertyId)),
                        _inventoryWatcher.ItemSets.FirstOrDefault(itemSet => itemSet.ItemSetId == slot.PropertyId)
                        );
                    item = unitItem;
                }

                var i1 = i;
                item.GetComponent <Button>().onClick.AddListener(() =>
                {
                    ClearChoicePanel();
                    Instantiate(choiceUnitPrefab, item.transform);
                    _onChoiceSlot.Invoke(form, i1, slot);
                });
                item.gameObject.SetActive(true);
                item.GetComponent <Image>().raycastTarget = _enableSelectUnit;
                item.GetComponent <Button>().enabled      = _enableSelectUnit;
                unitGameObjects.Add(item);
            }
        }
Example #13
0
        public void OnChoiceParty(
            EzMoldModel moldModel,
            int index,
            EzForm form
            )
        {
            Debug.Log("PartyDirector::OnChoiceParty");

            _selectedMoldModel = moldModel;
            _selectedMoldIndex = index;
            if (form == null)
            {
                var slots = new List <EzSlot>();
                foreach (var slot in _selectedMoldModel.FormModel.Slots)
                {
                    slots.Add(
                        new EzSlot
                    {
                        Name = slot.Name,
                    }
                        );
                }
                _selectedForm = new EzForm
                {
                    Index = index,
                    Slots = slots,
                };
            }
            else
            {
                _selectedForm = form;
            }

            void OnChoiceSlot(
                EzForm _,
                int slotIndex,
                EzSlot __
                )
            {
                Debug.Log("PartyDirector::OnChoiceSlot");

                _selectedSlotIndex = slotIndex;
            }

            var onChoiceSlot = new ChoiceSlotEvent();

            onChoiceSlot.AddListener(OnChoiceSlot);
            partyInformationWidget.Initialize(
                _unitInventoryWatcher,
                _formationWatcher,
                index,
                onChoiceSlot
                );

            partyUnitListWidget.Initialize(
                _unitInventoryWatcher,
                _formationWatcher,
                _selectedMoldIndex,
                _selectedForm
                );

            partyListWidget.gameObject.SetActive(false);
            partyUnitListWidget.gameObject.SetActive(true);
        }