Пример #1
0
        private UniTask DeserializeState(GameStateMap stateMap)
        {
            var state = stateMap.GetState <GameState>(name);

            if (state is null)
            {
                return(UniTask.CompletedTask);
            }

            var existingButtonIds = choiceButtons.Select(b => b.ChoiceState.Id).ToList();

            foreach (var buttonId in existingButtonIds)
            {
                if (!state.Buttons.Any(s => s.Id == buttonId))
                {
                    RemoveChoiceButton(buttonId);
                }
            }

            foreach (var buttonState in state.Buttons)
            {
                if (!choiceButtons.Any(b => b.ChoiceState == buttonState))
                {
                    AddChoiceButton(buttonState);
                }
            }

            removeAllButtonsPending = state.RemoveAllButtonsPending;

            return(UniTask.CompletedTask);
        }
Пример #2
0
        protected override async UniTask DeserializeState(GameStateMap stateMap)
        {
            await base.DeserializeState(stateMap);

            var state = stateMap.GetState <GameState>(name);

            if (state is null)
            {
                return;
            }

            var existingButtonIds = choiceButtons.Select(b => b.ChoiceState.Id).ToList();

            foreach (var buttonId in existingButtonIds)
            {
                if (state.Buttons.All(s => s.Id != buttonId))
                {
                    RemoveChoiceButton(buttonId);
                }
            }

            foreach (var buttonState in state.Buttons)
            {
                if (choiceButtons.All(b => b.ChoiceState != buttonState))
                {
                    AddChoiceButton(buttonState);
                }
            }

            removeAllButtonsPending = state.RemoveAllButtonsPending;
        }
Пример #3
0
        protected override async UniTask DeserializeState(GameStateMap stateMap)
        {
            // Invoked when the game is loaded.

            await base.DeserializeState(stateMap);

            RemoveAllItems();

            var state = stateMap.GetState <GameState>();

            if (state is null)
            {
                return;                // empty state, do nothing
            }
            // Restore UI state.
            if (state.Slots?.Length > 0)
            {
                var tasks = new List <UniTask>();
                for (int i = 0; i < state.Slots.Length; i++)
                {
                    if (!string.IsNullOrEmpty(state.Slots[i].ItemId))
                    {
                        tasks.Add(AddItemAtAsync(state.Slots[i].ItemId, i, state.Slots[i].StackCount));
                    }
                }
                await UniTask.WhenAll(tasks);
            }
            content.transform.position = state.Position;
        }
Пример #4
0
        private Task DeserializeState(GameStateMap stateMap)
        {
            var state = stateMap.GetState <GameState>(name);

            if (state is null)
            {
                return(Task.CompletedTask);
            }
            removeAllButtonsPending = state.RemoveAllButtonsPending;
            return(Task.CompletedTask);
        }
Пример #5
0
 protected virtual Task DeserializeState(GameStateMap stateMap)
 {
     if (saveVisibilityState)
     {
         var state = stateMap.GetState <GameState>(name);
         if (state is null)
         {
             return(Task.CompletedTask);
         }
         IsVisible = state.IsVisible;
     }
     return(Task.CompletedTask);
 }
Пример #6
0
        protected override async UniTask DeserializeState(GameStateMap stateMap)
        {
            await base.DeserializeState(stateMap);

            var state = stateMap.GetState <GameState>();

            if (state is null)
            {
                return;
            }

            variableName = state.VariableName;
            SetSummary(state.SummaryText);
            InputField.text = state.InputFieldText;
            playOnSubmit    = state.PlayOnSubmit;
        }
        protected override async UniTask DeserializeState(GameStateMap stateMap)
        {
            await base.DeserializeState(stateMap);

            var state = stateMap.GetState <GameState>();

            if (state is null)
            {
                return;
            }

            variableName     = state.VariableName;
            summaryText.text = state.SummaryText;
            summaryText.gameObject.SetActive(!string.IsNullOrWhiteSpace(state.SummaryText));
            inputField.text = state.InputFieldText;
            playOnSubmit    = state.PlayOnSubmit;
        }
Пример #8
0
        protected override UniTask DeserializeState(GameStateMap stateMap)
        {
            base.DeserializeState(stateMap);

            var state = stateMap.GetState <GameState>();

            if (state is null)
            {
                return(UniTask.CompletedTask);
            }

            varMan.SetVariableValue(date, state.CurrentDate);
            ConvertDate();
            UpdateDate();

            return(UniTask.CompletedTask);
        }
        protected virtual UniTask DeserializeState(GameStateMap stateMap)
        {
            var state = stateMap.GetState <GameState>(name);

            if (state is null)
            {
                return(UniTask.CompletedTask);
            }

            Hide();

            if (state.Visible) // TODO: Serialize onClick action.
            {
                Show(state.HideOnClick, null, state.AllowedSamplers);
            }

            return(UniTask.CompletedTask);
        }
Пример #10
0
        protected override async Task DeserializeState(GameStateMap stateMap)
        {
            await base.DeserializeState(stateMap);

            Clear();

            var state = stateMap.GetState <GameState>();

            if (state is null)
            {
                return;
            }

            if (state.Messages?.Count > 0)
            {
                foreach (var messageState in state.Messages)
                {
                    SpawnMessage(messageState.MessageText, messageState.ActorNameText, messageState.VoiceClipNames);
                }
            }
        }