Ejemplo n.º 1
0
 private void SetName(StoryAction action)
 {
     m_logInfos.Add(new LogInfo()
     {
         LogType = LogType.Talk, Name = action.Content
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// The trigger story.
        /// </summary>
        /// <param name="action">
        /// The action.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown when a wrong number of arguments are passed
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// Thrown when story action is not supported
        /// </exception>
        private void triggerStory(StoryAction action, params int[] args)
        {
            switch (action)
            {
            case StoryAction.EnterDefaultStory:
                this.EnterDefaultStory(args[0]);
                break;

            case StoryAction.ListInfo:
                if (args == null || args.Length != 1)
                {
                    throw new ArgumentException("ListInfo expects one parameter");
                }

                break;

            case StoryAction.Expand:
                if (args == null || args.Length != 1)
                {
                    throw new ArgumentException("Expand expects one parameter");
                }

                this.AudioSource.PlayOneShot(ExpandGraphSound);
                this.Expand(this.mapManager.getCurrentCaseObject().NodeObject[args[0]].transform);
                break;

            case StoryAction.ResetStory:
                this.ResetStory();
                break;

            default:
                throw new NotSupportedException("Story Action not supported");
            }
        }
Ejemplo n.º 3
0
 public Event(StoryAction type, int index, T value, T cvalue, bool link = false)
 {
     Type  = type;
     Index = index;
     Value = new T[] { value, cvalue };
     Link  = link;
 }
Ejemplo n.º 4
0
 private void SetShowEvidence(StoryAction action)
 {
     m_logInfos.Add(new LogInfo()
     {
         LogType = LogType.ShowEvidence, Content = action.Content
     });
 }
Ejemplo n.º 5
0
    /// <summary>
    /// Диалоговое действие
    /// </summary>
    public void SpeechAction(StoryAction _action)
    {
        Dialog _dialog = null;

        if (_action.argument > 0)
        {
            _dialog = dialogs[_action.argument];
        }
        else
        {
            _dialog = dialogs.Find(x => (x.dialogName == _action.id2));
        }
        if (_dialog != null)
        {
            if (_action.id1 == "change speech")
            {
                dialogs[0] = _dialog;
            }
            else if (_action.id1 == "talk")
            {
                dialogs[0] = _dialog;
                Talk();
            }
        }
    }
Ejemplo n.º 6
0
        public void PushLog(StoryAction action, string selectID = null)
        {
            if (m_logInfos.Count >= MAXLogNum && action.Type != StoryActionType.Content)
            {
                m_logInfos.RemoveAt(0);
            }
            switch (action.Type)
            {
            case StoryActionType.Name:
                SetName(action);
                break;

            case StoryActionType.Content:
                SetContent(action);
                break;

            case StoryActionType.Jump:
                SetJump(action, selectID);
                break;

            case StoryActionType.ShowEvidence:
                SetShowEvidence(action);
                break;
            }
        }
Ejemplo n.º 7
0
        private void SetJump(StoryAction action, string selectID)
        {
            var jumpAction = action as StoryJumpAction;

            m_logInfos.Add(new LogInfo()
            {
                LogType = LogType.Jump, Content = jumpAction.Options.Find(x => x.ID.Equals(selectID)).Content
            });
        }
Ejemplo n.º 8
0
 public void TriggerAction(StoryAction inAction, Character inCharacter)
 {
     if (runningAction == null)
     {
         runningAction = inAction;
         runningAction.StartAction(inCharacter);
         IsInteractive = false;
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    /// Убрать объект
    /// </summary>
    public void RemoveHistoryObject(StoryAction _action)
    {
        GameObject dObj = GameObject.Find(_action.id1);

        if (dObj != null)
        {
            dObj.SetActive(false);
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Изменить данные о квестах
    /// </summary>
    public void ChangeQuestData(StoryAction _action)
    {
        Quest _quest = null;

        if ((_quest = SpecialFunctions.statistics.GetQuest(_action.id2)) != null)
        {
            switch (_action.id1)
            {
            case "add":
            {
                if (!ContainsQuest(_quest))
                {
                    activeQuests.Add(new Quest(_quest));
                }
                break;
            }

            case "continue":
            {
                if (ContainsQuest(_quest))
                {
                    Quest quest1     = activeQuests.Find(x => (x.questName == _quest.questName));
                    int   questStage = quest1.stage++;
                    if (questStage >= quest1.questLine.Count)
                    {
                        activeQuests.Remove(quest1);
                    }
                }
                break;
            }

            case "complete":
            {
                if (ContainsQuest(_quest))
                {
                    activeQuests.Remove(activeQuests.Find(x => (x.questName == _quest.questName)));
                }
                break;
            }

            default:
            {
                if (ContainsQuest(_quest))
                {
                    Quest quest1 = activeQuests.Find(x => (x.questName == _quest.questName));
                    if (quest1.questLine.Contains(_action.id1))
                    {
                        quest1.stage = quest1.questLine.IndexOf(_action.id1);
                    }
                }
                break;
            }
            }
            SpecialFunctions.gameUI.ConsiderQuests(activeQuests.ConvertAll <string>(x => x.questLine[x.stage]));
            HandleStatisticCountEvent(this, new StoryEventArgs("", 0));
        }
    }
Ejemplo n.º 11
0
        private void SetContent(StoryAction action)
        {
            var lastLog = m_logInfos[m_logInfos.Count - 1];

            if (string.IsNullOrEmpty(lastLog.Content))
            {
                lastLog.Content = "";
            }
            lastLog.Content += action.Content;
        }
Ejemplo n.º 12
0
    // If we ever want it voice acted we can just add that file here.

    public StorySection(int ID, string Identity, string Section, int Order, string Name = "", string Text = "", Sprite CharacterArt = null, StoryAction Action = StoryAction.Enter, StoryCharacterPosition Focus = StoryCharacterPosition.Left, StoryCharacterEmotion Emotion = StoryCharacterEmotion.None)
    {
        this.ID       = ID;
        this.Identity = Identity;

        this.Section = Section;
        this.Order   = Order;

        this.Name         = Name;
        this.Text         = Text;
        this.CharacterArt = CharacterArt;

        this.Action  = Action;
        this.Focus   = Focus;
        this.Emotion = Emotion;
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Проверить, соответствует ли текущее сюжетное действие объекту, над которым это действие совершается
    /// </summary>
    public void CheckGameObjectActions(StoryAction sAction, int actionIndex)
    {
        if (actionNamesIndexes.Count < actionIndex)
        {
            return;
        }

        else if (actionNamesIndexes.Count == actionIndex)
        {
            ChangeActionIndexesCount(1);
        }

        GameObject actionObject = sAction.gameObj;

        if (actionObject == null)
        {
            actionNamesIndexes[actionIndex] = -1;
            actionID1Indexes[actionIndex]   = -1;
            actionID2Indexes[actionIndex]   = -1;
        }
        else
        {
            IHaveStory storyObject = actionObject.GetComponent <IHaveStory>();
            if (storyObject == null)
            {
                actionNamesIndexes[actionIndex] = -1;
                actionID1Indexes[actionIndex]   = -1;
                actionID2Indexes[actionIndex]   = -1;
            }
            else
            {
                if (storyObject.actionNames().Contains(sAction.actionName))
                {
                    actionNamesIndexes.Add(storyObject.actionNames().IndexOf(sAction.actionName));
                    List <string> id1List = storyObject.actionIDs1()[sAction.actionName], id2List = storyObject.actionIDs2()[sAction.actionName];
                    if (id1List.Contains(sAction.id1))
                    {
                        actionID1Indexes[actionIndex] = id1List.IndexOf(sAction.id1);
                    }
                    else if (id1List.Count > 0)
                    {
                        actionID1Indexes[actionIndex] = -1;
                        sAction.id1 = string.Empty;
                    }

                    if (id2List.Contains(sAction.id2))
                    {
                        actionID2Indexes[actionIndex] = id2List.IndexOf(sAction.id2);
                    }
                    else if (id2List.Count > 0)
                    {
                        actionID2Indexes[actionIndex] = -1;
                        sAction.id2 = string.Empty;
                    }
                }
                else
                {
                    actionNamesIndexes[actionIndex] = -1;
                    actionID1Indexes[actionIndex]   = -1;
                    actionID2Indexes[actionIndex]   = -1;
                    sAction.actionName = string.Empty;
                    sAction.id1        = string.Empty;
                    sAction.id2        = string.Empty;
                }
            }
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Подписка всех событий происходит здесь. Сделав правильную подписку, мы реализуем историю игры
    /// </summary>
    public void InitializeScript(Story _story)
    {
        GameObject storyTarget = null;

        StoryInitializer init = FindInitializer(_story);

        if (init == null)
        {
            return;
        }

        storyTarget = init.eventReason;

        if (storyTarget == null)
        {
            return;
        }

        //В первую очередь, подпишемся на сюжетные объекты объекты
        if (storyInitBase.ContainsKey(_story.storyCondition.storyConditionName))
        {
            string s = _story.storyCondition.storyConditionName;
            storyInitBase[s].Invoke(_story, storyTarget);
        }

        for (int i = 0; i < _story.storyActions.Count; i++)
        {
            if (i >= init.eventObjects.Count)
            {
                break;
            }
            StoryAction _action = _story.storyActions[i];

            GameObject obj = init.eventObjects[i];
            if (obj == null)
            {
                continue;
            }
            if (obj.GetComponent <GameHistory>() != null)
            {
                if (storyActionBase.ContainsKey(_action.actionName))
                {
                    string s = _action.actionName;
                    _action.storyAction = storyActionBase[s].Invoke;
                }
            }
            else if (obj.GetComponent <NPCController>() != null)
            {
                NPCController npc = obj.GetComponent <NPCController>();
                if (npc.StoryActionBase.ContainsKey(_action.actionName))
                {
                    string s = _action.actionName;
                    _action.storyAction = npc.StoryActionBase[s].Invoke;
                }
            }
            else if (obj.GetComponent <CharacterController>() != null)
            {
                CharacterController character = obj.GetComponent <CharacterController>();
                if (character.StoryActionBase.ContainsKey(_action.actionName))
                {
                    string s = _action.actionName;
                    _action.storyAction = character.StoryActionBase[s].Invoke;
                }
            }
        }

        if (storyConditionBase.ContainsKey(_story.storyCondition.conditionName))
        {
            string s = _story.storyCondition.conditionName;
            _story.storyCondition.storyCondition = storyConditionBase[s].Invoke;
        }
        else
        {
            _story.storyCondition.storyCondition = Empty;
        }
    }
Ejemplo n.º 15
0
        private void SetNextAction(StoryAction storyAction)
        {
            if (storyAction == null)
            {
                EventManager.Instance.SendEvent(new LabelEndEvent()
                {
                    LabelID = m_currentID
                });
                m_currentID = null;
                SetActionState(ActionState.Waiting);
                if (m_nextIDQueue.Count > 0)
                {
                    return;
                }
                if (RecoverRecord())
                {
                    return;
                }
                InvokeHidePanel();
                UIPanelDataProvider.OnTalkEnd?.Invoke();
                return;
            }
            m_actionType = storyAction.Type;
            m_curAction  = storyAction;
            SetActionState(ActionState.Actioning);
            Debug.LogWarning($"当前行为:{m_actionType}");

            switch (storyAction.Type)
            {
            case StoryActionType.WaitClick:
                WaitClickEnd();
                break;

            case StoryActionType.Name:
                SetNameContent(storyAction.Content);
                break;

            case StoryActionType.Content:
                if (m_typewriterCoroutine != null)
                {
                    StopCoroutine(m_typewriterCoroutine);
                }
                m_typewriterCoroutine = StartCoroutine(Typewriter(storyAction.Content));
                break;

            case StoryActionType.Color:
                m_textHelp.PushColor(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Font:
                m_textHelp.PushFont(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Jump:
                var jumpAction = storyAction as StoryJumpAction;
                if (jumpAction == null)
                {
                    Debug.LogError("JumpAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }
                Debug.Log($"=== options:{jumpAction.Options}");
                ShowJumpOption(jumpAction.Options);
                break;

            case StoryActionType.Picture:
                var pictureAction = storyAction as StoryShowPictureAction;
                if (pictureAction == null)
                {
                    Debug.LogError("pictureAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }

                ShowPicture(pictureAction.Content, pictureAction.Pos);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Waiting:
                SetActionState(ActionState.Actioning);
                if (m_skip == false)
                {
                    CallbackTime(float.Parse(storyAction.Content), () => { SetActionState(ActionState.End); });
                }
                else
                {
                    SetActionState(ActionState.End);
                }
                break;

            case StoryActionType.PictureMove:
                var pictureMoveAction = storyAction as StoryPictureMoveAction;
                MovePicture(pictureMoveAction.PicID, pictureMoveAction.StartX, pictureMoveAction.StartY, pictureMoveAction.EndX, pictureMoveAction.EndY, pictureMoveAction.Ease, pictureMoveAction.Duration);
                break;

            case StoryActionType.FontSize:
                m_textHelp.PushFontSize(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Bold:
                m_textHelp.PushBold();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBGM:
                SetBgm(storyAction.Content);
                break;

            case StoryActionType.ChangeEffectMusic:
                PlayEffectMusic(storyAction.Content);
                break;

            case StoryActionType.TypewriterInterval:
                m_textHelp.TypewriterInterval = float.Parse(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ShowEvidence:
                InvokeShowPanel(UIPanelType.UICommonDetectiveNotesPanel, new EvidenceDataProvider()
                {
                    OnShowEvidence  = OnSelectEvidenceEnd,
                    IsOnEvidence    = true,
                    CurState        = CommonMapsTipsEvidencesPanel.ShowState.Evidences,
                    IsShowSelectBtn = true
                });
                return;

            case StoryActionType.LoadGameScene:
                GameSceneManager.Instance.LoadScene(SceneLookup.GetEnum(m_curAction.Content, false));
                bool result = MissionSceneManager.Instance.LoadCurrentMissionScene();
                if (result == false)
                {
                    Debug.LogError("Current Game Scene: " + m_curAction.Content + " doesn`t contain Mission Scene " +
                                   MissionSceneManager.Instance.GetCurrentMissionEnum().ToString());
                }
                SetActionState(ActionState.End);
                break;

            case StoryActionType.LoadMission:
                var action = m_curAction as StoryLoadMissionAction;
                MissionSceneManager.Instance.SetCurrentMission(action.Mission);
                MissionSceneManager.Instance.LoadCurrentMissionScene();
                //if (MissionSceneManager.Instance.IsMissionSceneExist(action.Mission))
                //{
                //    MissionSceneManager.Instance.LoadMissionScene(action.Mission);
                //}
                //else
                //{
                //    MissionSceneManager.Instance.LoadMissionScene(MissionEnum.None);
                //}
                SetActionState(ActionState.End);
                break;

            case StoryActionType.LoadCgScene:
                UI.UIManager.Instance().ShowStaticPanel(UIPanelType.UICommonCgscenePanel, new CGSceneDataProvider()
                {
                    CGSceneID = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.CloseCgScene:
                if (UIManager.Instance().IsPanelShow(UIPanelType.UICommonCgscenePanel))
                {
                    StarPlatinum.TimerService.Instance.AddTimer(0.01f, () =>
                    {
                        EventManager.Instance.SendEvent(new CGSceneCloseEvent()
                        {
                            m_cgSceneId = m_curAction.Content
                        });
                    });
                }
                SetActionState(ActionState.End);
                break;

            case StoryActionType.TriggerEvent:
                var triggerAction = m_curAction as StoryEventAction;
                EventManager.Instance.SendEvent(triggerAction.Event);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.PlayAnimation:
                SetActionState(ActionState.End);
                //TODO:播放动画
                break;

            case StoryActionType.PlayInteractionAnimation:
                EventManager.Instance.SendEvent(new PlayInteractionAnimationEvent()
                {
                    m_itemName = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBackground:
                ShowBG(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Wrap:
                m_txtPro_content_TextMeshProUGUI.text += '\n';
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeSoundVolume:
                int volume = int.Parse(m_curAction.Content);
                SoundService.Instance.SetVolumePercentage(volume);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.EnterControversy:
                UIManager.Instance().ShowPanel(UIPanelType.UIJudgmentControversyPanel, new ControversyDataProvider()
                {
                    ID = m_curAction.Content
                });
                SetActionState(ActionState.End);
                break;

            case StoryActionType.CutIn:
                UIManager.Instance().ShowPanel(UIPanelType.UICommonBreaktheoryPanel, new BreakTheoryDataProvider()
                {
                    Type = EnumBreakTheoryType.CutIn, ImgKey = m_curAction.Content, CloseCallback =
                        () =>
                    {
                        SetActionState(ActionState.End);
                    }
                });
                break;

            case StoryActionType.LoadSkybox:
            {
                StoryLoadSkyboxAction skyboxAction = m_curAction as StoryLoadSkyboxAction;
                SkyboxManager.Instance().UpdateSkybox(skyboxAction.m_skyEnum);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.ChangeTalkPanelType:
                SetTalkPanelType(m_curAction.Content);
                break;

            case StoryActionType.ChangeFrontImg:
                SetFrontImg(m_curAction.Content);
                break;

            case StoryActionType.RemoveAllExhibit:
                EvidenceDataManager.Instance.RemoveAllEvidence();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.TimeLine:
                PrefabManager.Instance.LoadAssetAsync <TimelineAsset>(m_curAction.Content, (res) =>
                {
                    if (res.status != RequestStatus.FAIL)
                    {
                        gameObject.SetActive(false);
                        TimelineManager.Instance().PlayTimeline(res.result as TimelineAsset, null, () =>
                        {
                            gameObject.SetActive(true);
                            SetActionState(ActionState.End);
                        });
                    }
                    else
                    {
                        SetActionState(ActionState.End);
                    }
                });
                break;

            case StoryActionType.AddEvidence:
                EvidenceDataManager.Instance.AddEvidence(m_curAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.RemoveEvidence:
                EvidenceDataManager.Instance.RemoveEvidence(m_curAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.AddTip:
                Tips.TipsManager.Instance.UnlockTip(m_curAction.Content, Tips.TipsManager.ConvertDateTimeToLong(System.DateTime.Now));      // 添加tip 数据
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Position:
            {
                StoryVector3Action vector3Action = m_curAction as StoryVector3Action;
                CoreContainer.Instance.SetPlayerPosition(vector3Action.m_vector);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.Rotation:
            {
                StoryVector3Action vector3Action = m_curAction as StoryVector3Action;
                VMCameraManager.Instance().SetLookAtRotation(vector3Action.m_vector.x, vector3Action.m_vector.y, vector3Action.m_vector.z);
                SetActionState(ActionState.End);
            }
            break;

            case StoryActionType.GameEvent:
            {
                EventManager.Instance.SendEvent(new GameEvent()
                    {
                        EventName = m_curAction.Content
                    });
                SetActionState(ActionState.End);
            }
            break;

            default:
                Debug.LogError($"未处理对话行为:{storyAction.Type}");
                break;
            }
        }
Ejemplo n.º 16
0
        private void SetNextAction(StoryAction storyAction)
        {
            if (storyAction == null)
            {
                SetActionState(ActionState.Waiting);
                m_characterTalkEnd = true;
                if (m_autoPlay || m_skip)
                {
                    EndCharacterTalk();
                }
                print($"TalkEnd");
                return;
            }
            print($"CurrentAction:{storyAction.Type}");
            m_actionType = storyAction.Type;
            SetActionState(ActionState.Actioning);
            switch (storyAction.Type)
            {
            case StoryActionType.Name:
                AddNewTalker(storyAction.Content);
                break;

            case StoryActionType.Content:
                StartCoroutine(Typewriter(storyAction.Content));
                break;

            case StoryActionType.Color:
                m_textHelp.PushColor(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Font:
                m_textHelp.PushFont(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Jump:
                var jumpAction = storyAction as StoryJumpAction;
                if (jumpAction == null)
                {
                    Debug.LogError("JumpAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }
                ShowJumpOption(jumpAction.Options);
                break;

            case StoryActionType.Picture:
                var pictureAction = storyAction as StoryShowPictureAction;
                if (pictureAction == null)
                {
                    Debug.LogError("pictureAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }

                ShowPicture(pictureAction.Content, pictureAction.Pos);
                break;

            case StoryActionType.Waiting:
                SetActionState(ActionState.Actioning);
                if (m_skip == false)
                {
                    CallbackTime(float.Parse(storyAction.Content), () => { SetActionState(ActionState.End); });
                }
                else
                {
                    SetActionState(ActionState.End);
                }
                break;

            case StoryActionType.PictureMove:
                break;

            case StoryActionType.FontSize:
                m_textHelp.PushFontSize(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Bold:
                m_textHelp.PushBold();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBGM:
                SetBgm(storyAction.Content);
                break;

            case StoryActionType.ChangeEffectMusic:
                PlayEffectMusic(storyAction.Content);
                break;

            default:
                Debug.LogError($"未处理对话行为:{storyAction.Type}");
                break;
            }
        }
Ejemplo n.º 17
0
        private void SetNextAction(StoryAction storyAction)
        {
            if (storyAction == null)
            {
                EventManager.Instance.SendEvent(new LabelEndEvent()
                {
                    LabelID = m_currentID
                });
                m_currentID = null;
                SetActionState(ActionState.Waiting);
                if (m_nextIDQueue.Count > 0)
                {
                    return;
                }
                if (RecoverRecord())
                {
                    return;
                }
                InvokeHidePanel();
                UIPanelDataProvider.OnTalkEnd?.Invoke();
                return;
            }
            m_actionType = storyAction.Type;
            m_curAction  = storyAction;
            SetActionState(ActionState.Actioning);
            Debug.LogWarning($"当前行为:{m_actionType}");

            switch (storyAction.Type)
            {
            case StoryActionType.WaitClick:
                WaitClickEnd();
                break;

            case StoryActionType.Name:
                SetNameContent(storyAction.Content);
                break;

            case StoryActionType.Content:
                if (m_typewriterCoroutine != null)
                {
                    StopCoroutine(m_typewriterCoroutine);
                }
                m_typewriterCoroutine = StartCoroutine(Typewriter(storyAction.Content));
                break;

            case StoryActionType.Color:
                m_textHelp.PushColor(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Font:
                m_textHelp.PushFont(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Jump:
                var jumpAction = storyAction as StoryJumpAction;
                if (jumpAction == null)
                {
                    Debug.LogError("JumpAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }
                Debug.Log($"=== options:{jumpAction.Options}");
                ShowJumpOption(jumpAction.Options);
                break;

            case StoryActionType.Picture:
                var pictureAction = storyAction as StoryShowPictureAction;
                if (pictureAction == null)
                {
                    Debug.LogError("pictureAction null!!!!!!!Please check");
                    SetActionState(ActionState.End);
                    return;
                }

                ShowPicture(pictureAction.Content, pictureAction.Pos);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Waiting:
                SetActionState(ActionState.Actioning);
                if (m_skip == false)
                {
                    CallbackTime(float.Parse(storyAction.Content), () => { SetActionState(ActionState.End); });
                }
                else
                {
                    SetActionState(ActionState.End);
                }
                break;

            case StoryActionType.PictureMove:
                var pictureMoveAction = storyAction as StoryPictureMoveAction;
                MovePicture(pictureMoveAction.PicID, pictureMoveAction.StartX, pictureMoveAction.StartY, pictureMoveAction.EndX, pictureMoveAction.EndY, pictureMoveAction.Ease, pictureMoveAction.Duration);
                break;

            case StoryActionType.FontSize:
                m_textHelp.PushFontSize(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Bold:
                m_textHelp.PushBold();
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeBGM:
                SetBgm(storyAction.Content);
                break;

            case StoryActionType.ChangeEffectMusic:
                PlayEffectMusic(storyAction.Content);
                break;

            case StoryActionType.TypewriterInterval:
                m_textHelp.TypewriterInterval = float.Parse(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ShowEvidence:
                InvokeShowPanel(UIPanelType.UICommonMapsTipsEvidencesPanel, new EvidenceDataProvider()
                {
                    OnShowEvidence = OnSelectEvidenceEnd,
                    IsOnEvidence   = true,
                    CurState       = CommonMapsTipsEvidencesPanel.ShowState.Evidences
                });
                return;

            case StoryActionType.LoadGameScene:
                GameSceneManager.Instance.LoadScene(SceneLookup.GetEnum(m_curAction.Content, false));
                bool result = MissionSceneManager.Instance.LoadCurrentMissionScene();
                if (result == false)
                {
                    Debug.LogError("Current Game Scene: " + m_curAction.Content + " doesn`t contain Mission Scene " +
                                   MissionSceneManager.Instance.GetCurrentMission().ToString());
                }
                break;

            case StoryActionType.LoadMission:
                var action = m_curAction as StoryLoadMissionAction;
                MissionSceneManager.Instance.LoadMissionScene(action.Mission);
                break;

            case StoryActionType.TriggerEvent:
                var triggerAction = m_curAction as StoryEventAction;
                EventManager.Instance.SendEvent(triggerAction.Event);
                SetActionState(ActionState.End);
                return;

            case StoryActionType.PlayAnimation:
                SetActionState(ActionState.End);
                //TODO:播放动画
                return;

            case StoryActionType.ChangeBackground:
                ShowBG(storyAction.Content);
                SetActionState(ActionState.End);
                break;

            case StoryActionType.Wrap:
                m_content.text += '\n';
                SetActionState(ActionState.End);
                break;

            case StoryActionType.ChangeSoundVolume:
                int volume = int.Parse(m_curAction.Content);
                SoundService.Instance.SetVolumePercentage(volume);
                SetActionState(ActionState.End);
                break;

            default:
                Debug.LogError($"未处理对话行为:{storyAction.Type}");
                break;
            }
        }
Ejemplo n.º 18
0
 public void TriggerStoryWithNetworking(StoryAction action, params int[] args)
 {
     this.triggerStory(action, args);
     NetworkMessages.Instance.SendStoryControl((byte)action, args);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Выйти вперёд
 /// </summary>
 public void MoveForwardAction(StoryAction _action)
 {
     //Animate(new AnimationEventArgs("moveForward"));
     StartCoroutine(MoveForwardProcess());
 }
Ejemplo n.º 20
0
 public TimeableAction(StoryAction action, int repeatTicks = 0)
 {
     this.action      = action;
     this.repeatTicks = repeatTicks;
 }
Ejemplo n.º 21
0
 public StoryEventArgs(int index, StoryAction action)
 {
     Index  = index;
     Action = action;
 }
Ejemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        story.storyName = EditorGUILayout.TextField("story name", story.storyName);

        story.sceneName = EditorGUILayout.TextField("scene name", story.sceneName);

        EditorGUILayout.Space();

        #region storyActions

        EditorGUILayout.HelpBox("story actions", MessageType.Info);

        actionSize = story.storyActions.Count;
        actionSize = EditorGUILayout.IntField("action size", actionSize);
        if (actionSize != story.storyActions.Count)
        {
            int m = story.storyActions.Count;
            for (int i = m; i < actionSize; i++)
            {
                story.storyActions.Add(new StoryAction());
                CheckGameObjectActions(story.storyActions[i], i);
            }
            for (int i = m - 1; i >= actionSize; i--)
            {
                story.storyActions.RemoveAt(i);
                ChangeActionIndexesCount(-1);
            }
        }

        if (init != null? init.eventObjects.Count != story.storyActions.Count:false)
        {
            int m = init.eventObjects.Count;
            for (int i = m; i < story.storyActions.Count; i++)
            {
                init.eventObjects.Add(null);
            }
            for (int i = m - 1; i >= story.storyActions.Count; i--)
            {
                init.eventObjects.RemoveAt(i);
            }
        }

        for (int i = 0; i < story.storyActions.Count; i++)
        {
            StoryAction _action = story.storyActions[i];
            _action.storyActionName = EditorGUILayout.TextField("story action name", _action.storyActionName);

            GameObject actionObject = _action.gameObj;
            IHaveStory storyObject  = null;

            if (actionObject != null)
            {
                storyObject = actionObject.GetComponent <IHaveStory>();
            }

            if (storyObject != null)
            {
                int newActionIndex = EditorGUILayout.Popup(actionNamesIndexes[i], storyObject.actionNames().ToArray());
                if (newActionIndex != actionNamesIndexes[i])
                {
                    actionNamesIndexes[i] = newActionIndex;
                    _action.actionName    = storyObject.actionNames()[newActionIndex];

                    actionID1Indexes[i] = -1;
                    actionID2Indexes[i] = -1;
                    _action.id1         = string.Empty;
                    _action.id2         = string.Empty;
                }
            }
            _action.actionName = EditorGUILayout.TextField("action name", _action.actionName);

            if (storyObject != null? storyObject.actionIDs1().ContainsKey(_action.actionName):false)
            {
                List <string> IDs = storyObject.actionIDs1()[_action.actionName];
                if (IDs.Count > 0)
                {
                    int newIDIndex = EditorGUILayout.Popup(actionID1Indexes[i], IDs.ToArray());
                    if (newIDIndex != actionID1Indexes[i])
                    {
                        actionID1Indexes[i] = newIDIndex;
                        _action.id1         = IDs[newIDIndex];
                    }
                }
            }
            _action.id1 = EditorGUILayout.TextField("id1", _action.id1);

            if (storyObject != null ? storyObject.actionIDs2().ContainsKey(_action.actionName) : false)
            {
                List <string> IDs = storyObject.actionIDs2()[_action.actionName];
                if (IDs.Count > 0)
                {
                    int newIDIndex = EditorGUILayout.Popup(actionID2Indexes[i], IDs.ToArray());
                    if (newIDIndex != actionID2Indexes[i])
                    {
                        actionID2Indexes[i] = newIDIndex;
                        _action.id2         = IDs[newIDIndex];
                    }
                }
            }
            _action.id2 = EditorGUILayout.TextField("id2", _action.id2);

            _action.argument = EditorGUILayout.IntField("argument", _action.argument);

            GameObject newObj = (GameObject)EditorGUILayout.ObjectField("action object", _action.gameObj, typeof(GameObject), true);//с каким игровым объектом произвести действие
            if (newObj != null ? newObj != _action.gameObj : _action.gameObj != null)
            {
                _action.gameObj = newObj;
                CheckGameObjectActions(_action, i);

                if ((sceneName == story.sceneName) && (_action.gameObj != null))
                {
                    if (init != null)
                    {
                        init.eventObjects[story.storyActions.IndexOf(_action)] = _action.gameObj;
                    }
                }
            }

            if (GUILayout.Button("Delete"))
            {
                if (sceneName == story.sceneName)
                {
                    if (init != null)
                    {
                        init.eventObjects.RemoveAt(story.storyActions.IndexOf(_action));
                    }
                }
                story.storyActions.Remove(_action);
                actionNamesIndexes.RemoveAt(i);
                actionID1Indexes.RemoveAt(i);
                actionID2Indexes.RemoveAt(i);
            }

            EditorGUILayout.Space();
        }

        #endregion //storyActions

        EditorGUILayout.Space();

        #region presequences

        EditorGUILayout.HelpBox("presequences", MessageType.Info);
        EditorGUILayout.Space();

        presequencesSize = story.presequences.Count;
        presequencesSize = EditorGUILayout.IntField("presequences size", presequencesSize);
        if (presequencesSize != story.presequences.Count)
        {
            int m = story.presequences.Count;
            for (int i = m; i < presequencesSize; i++)
            {
                story.presequences.Add(null);
            }
            for (int i = m - 1; i >= presequencesSize; i--)
            {
                story.storyActions.RemoveAt(i);
            }
        }

        for (int i = 0; i < story.presequences.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            {
                story.presequences[i] = (Story)EditorGUILayout.ObjectField(story.presequences[i], typeof(Story));
                Story _presequence = story.presequences[i];
                if (_presequence != null)
                {
                    if (!_presequence.consequences.Contains(story))
                    {
                        _presequence.consequences.Add(story);
                    }
                    if (story.presequences.FindAll(x => (story.presequences.IndexOf(x) != i)).Contains(_presequence))
                    {
                        _presequence          = null;
                        story.presequences[i] = null;
                    }
                }
                if (GUILayout.Button("Delete"))
                {
                    if (_presequence != null)
                    {
                        DeletePresequence(story, _presequence);
                    }
                    else
                    {
                        story.presequences.RemoveAt(i);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.Space();

        #endregion //presequences

        #region consequences

        EditorGUILayout.HelpBox("consequences", MessageType.Info);
        EditorGUILayout.Space();

        consequencesSize = story.consequences.Count;
        consequencesSize = EditorGUILayout.IntField("consequences size", consequencesSize);
        if (consequencesSize != story.consequences.Count)
        {
            int m = story.consequences.Count;
            for (int i = m; i < consequencesSize; i++)
            {
                story.consequences.Add(null);
            }
            for (int i = m - 1; i >= consequencesSize; i--)
            {
                story.consequences.RemoveAt(i);
            }
        }

        for (int i = 0; i < story.consequences.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            {
                story.consequences[i] = (Story)EditorGUILayout.ObjectField(story.consequences[i], typeof(Story));
                Story _consequence = story.consequences[i];
                if (_consequence != null)
                {
                    if (story.nonConsequences.Contains(_consequence))
                    {
                        story.nonConsequences.Remove(_consequence);
                    }
                    if (!_consequence.presequences.Contains(story))
                    {
                        _consequence.presequences.Add(story);
                    }
                    if (story.consequences.FindAll(x => (story.consequences.IndexOf(x) != i)).Contains(_consequence))
                    {
                        story.consequences[i] = null;
                        _consequence          = null;
                    }
                }
                if (GUILayout.Button("Delete"))
                {
                    if (_consequence != null)
                    {
                        DeleteConsequence(story, _consequence);
                    }
                    else
                    {
                        story.consequences.RemoveAt(i);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();

        #endregion //consequences

        #region nonsequences

        EditorGUILayout.HelpBox("nonsequences", MessageType.Info);
        EditorGUILayout.Space();

        nonsequencesSize = story.nonConsequences.Count;
        nonsequencesSize = EditorGUILayout.IntField("nonConsequences size", nonsequencesSize);
        if (nonsequencesSize != story.nonConsequences.Count)
        {
            int m = story.nonConsequences.Count;
            for (int i = m; i < nonsequencesSize; i++)
            {
                story.nonConsequences.Add(null);
            }
            for (int i = m - 1; i >= nonsequencesSize; i--)
            {
                story.nonConsequences.RemoveAt(i);
            }
        }

        for (int i = 0; i < story.nonConsequences.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            {
                story.nonConsequences[i] = (Story)EditorGUILayout.ObjectField(story.nonConsequences[i], typeof(Story));
                Story _nonsequence = story.nonConsequences[i];
                if (_nonsequence != null)
                {
                    if (story.consequences.Contains(_nonsequence))
                    {
                        DeleteConsequence(story, _nonsequence);
                    }
                    if (story.nonConsequences.FindAll(x => (story.nonConsequences.IndexOf(x) != i)).Contains(_nonsequence))
                    {
                        story.nonConsequences[i] = null;
                        _nonsequence             = null;
                    }
                }
                if (GUILayout.Button("Delete"))
                {
                    story.nonConsequences.RemoveAt(i);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();

        #endregion //nonsequences

        #region storyCondition

        EditorGUILayout.HelpBox("story condition", MessageType.Info);
        EditorGUILayout.Space();

        StoryCondition _condition = story.storyCondition;


        if (_condition.obj != null)
        {
            int newIndex = EditorGUILayout.Popup(initNameIndex, initNames.ToArray());
            if (newIndex != initNameIndex)
            {
                initNameIndex = newIndex;
                _condition.storyConditionName = initNames[newIndex];

                _condition.conditionName = string.Empty;
                _condition.id            = string.Empty;
                conditionIDIndex         = -1;
                conditionNameIndex       = -1;
            }
        }
        _condition.storyConditionName = EditorGUILayout.TextField("story condition name", _condition.storyConditionName);

        if (_condition.obj != null)
        {
            int newIndex = EditorGUILayout.Popup(conditionNameIndex, conditionNames.ToArray());
            if (newIndex != conditionNameIndex)
            {
                conditionNameIndex       = newIndex;
                _condition.conditionName = conditionNames[newIndex];

                _condition.id    = string.Empty;
                conditionIDIndex = -1;

                List <string> conditionTypes = SpecialFunctions.history.storyTypes;
                for (int i = 0; i < conditionTypes.Count; i++)
                {
                    Type conditionType = Type.GetType(conditionTypes[i]);
                    var  component     = _condition.obj.GetComponent(conditionType);
                    if (component != null && (component is IHaveStory))
                    {
                        IHaveStory storyObject = (IHaveStory)component;
                        if (storyObject.conditionIDs().ContainsKey(_condition.conditionName))
                        {
                            conditionIDs           = storyObject.conditionIDs()[_condition.conditionName];
                            currentConditionObject = storyObject;
                            break;
                        }
                    }
                }
            }
        }
        _condition.conditionName = EditorGUILayout.TextField("condition name", _condition.conditionName);

        if (_condition.obj != null && currentConditionObject != null)
        {
            int newIndex = EditorGUILayout.Popup(conditionIDIndex, conditionIDs.ToArray());
            if (newIndex != conditionIDIndex && conditionIDs.Count > 0)
            {
                conditionIDIndex = newIndex;
                _condition.id    = conditionIDs[newIndex];
            }
        }
        _condition.id = EditorGUILayout.TextField("id", _condition.id);

        _condition.argument = EditorGUILayout.IntField("argument", _condition.argument);

        GameObject newObj1 = (GameObject)EditorGUILayout.ObjectField("condition object", _condition.obj, typeof(GameObject), true);
        if (newObj1 != null ? newObj1 != _condition.obj : _condition.obj != null)
        {
            _condition.obj = newObj1;
            CheckGameObjectCondition(_condition);

            if ((sceneName == story.sceneName) && (_condition.obj != null))
            {
                if (init != null)
                {
                    init.eventReason = _condition.obj;
                }
            }
        }
        #endregion//storyCondition

        story.SetDirty();
        if (history != null)
        {
            EditorUtility.SetDirty(SpecialFunctions.gameController.GetComponent <GameHistory>());
        }
    }
Ejemplo n.º 23
0
    // Update is called once per frame
    void Update()
    {
        // Increment the world time by our real time factor
        world.time += Time.deltaTime * realTimeToGameTimeMultiplier;

        // Calculate elapsed time since last update
        float timeIncrement = world.time - elapsedTime;

        elapsedTime = world.time;

        // Update the stats of every object
        foreach (Character c in characters)
        {
            c.UpdateStats(timeIncrement);
        }

        // Update any in flight events
        for (int i = 0; i < runningTriggeredEvents.Count;)
        {
            StoryEvent e = runningTriggeredEvents[i];
            if (!e.UpdateEvent())
            {
                // The event has finished, remove it from the running event list.
                runningTriggeredEvents.RemoveAt(i);

                // If it can be run again, add it back to the onTriggered list
                if (e.IsRepeat())
                {
                    onTriggerEvents.Add(e);
                }
            }
            else
            {
                i++;
            }
        }

        // Ditto for random event
        if (runningRandomEvent != null)
        {
            if (!runningRandomEvent.UpdateEvent())
            {
                if (runningRandomEvent.IsRepeat())
                {
                    randomEvents.Add(runningRandomEvent);
                    runningRandomEvent = null;
                }
            }
        }

        // Check for any triggered events.
        // Do this before checking random events, because onTrigger events have higher priority
        for (int i = onTriggerEvents.Count - 1; i >= 0; i--)
        {
            StoryEvent e = onTriggerEvents[i];
            if (e.IsTriggered())
            {
                e.StartEvent();
                onTriggerEvents.RemoveAt(i);
                runningTriggeredEvents.Add(e);
            }
        }

        // Check for any random events
        if (runningRandomEvent == null && randomEvents.Count > 0)
        {
            // Don't accumulate time while an event is running - we don't want to keep triggering these.
            accumulatedRandomEventTime += timeIncrement;
            if (accumulatedRandomEventTime > randomEventInterval)
            {
                accumulatedRandomEventTime -= randomEventInterval;

                // Grab a random event
                int index = Random.Range(0, randomEvents.Count);
                runningRandomEvent = randomEvents[index];
                randomEvents.RemoveAt(index);

                // And start it
                runningRandomEvent.StartEvent();
            }
        }

        // Update the action state
        if (runningAction != null)
        {
            runningAction.UpdateAction();
            switch (runningAction.GetState())
            {
            case StoryAction.State.kInactive:
                // Finished, remove
                runningAction = null;
                IsInteractive = true;

                // Can skip transition out state, so make sure to reset clocks too.
                foreach (ClockSpinner clock in clocks)
                {
                    clock.speedMultiplier = clockMultiplierSlow;
                }
                break;

            case StoryAction.State.kTransitionIn:
                // Starting, but needs transition period
                break;

            case StoryAction.State.kAct:
                // Acting
                foreach (ClockSpinner clock in clocks)
                {
                    clock.speedMultiplier = clockMultiplierFast;
                }
                break;

            case StoryAction.State.kTransitionOut:
                // Action finished, returning to normal
                foreach (ClockSpinner clock in clocks)
                {
                    clock.speedMultiplier = clockMultiplierSlow;
                }
                break;
            }
        }
    }