Beispiel #1
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());
        }
Beispiel #2
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);
        }