public void ExecuteStepComplete(TutorialStepData stepData)
        {
            if (stepData.id == TutorialProxy.instance.CurrentTutorialStepData.id)
            {
                if (TutorialProxy.instance.IsCompleteStep())
                {
                    int      nextChapterID = TutorialProxy.instance.CurrentTutorialChapterData.nextID;
                    GuideReq guideReq      = new GuideReq();
                    guideReq.no       = nextChapterID;
                    guideReq.guideNo2 = 0;
                    Logic.Protocol.ProtocolProxy.instance.SendProtocol(guideReq);
                }
                else if (!TutorialProxy.instance.IsAfterCompleteStep())
                {
                    GuideReq guideReq = new GuideReq();
                    guideReq.no       = TutorialProxy.instance.CurrentTutorialChapterData.id;
                    guideReq.guideNo2 = TutorialProxy.instance.CurrentTutorialChapterData.isBackup ? stepData.id + 100000 : stepData.id;
                    Logic.Protocol.ProtocolProxy.instance.SendProtocol(guideReq);
                }

                if (TutorialProxy.instance.HasNextStep())
                {
                    TutorialProxy.instance.MoveToNextStep(stepData);
                    TutorialView.Open(TutorialProxy.instance.CurrentTutorialChapterData, TutorialProxy.instance.CurrentTutorialStepData);
                    Observers.Facade.Instance.SendNotification(TUTORIAL_STEP_COMPLETE_MSG);
                }
                else if (TutorialProxy.instance.HasNextChapter())
                {
                    TutorialProxy.instance.MoveToNextChapter();
                    CheckIfShouldOpenCurrentChapterOrCurrentBackupChapter();
                }
            }
        }
Exemple #2
0
 private void ReadNextStep()
 {
     if (_currentTutorialData != null && _tutorialState != TutorialState.Finished)
     {
         TutorialStepData currentStep = _currentTutorialData.GetStep(_currentStepIndex);
         if (currentStep != null)
         {
             _tutorialState = TutorialState.Started;
             _tutorialView.gameObject.SetActive(true);
             _tutorialView.SetText(currentStep.requestText);
             if (currentStep.conditions.All(x => x.IsConditionVerified()))
             {
                 _currentStepIndex++;
                 if (_currentTutorialData.GetStepCount() == _currentStepIndex)
                 {
                     //tutorial is finished
                     _tutorialState = TutorialState.Finished;
                     _tutorialView.gameObject.SetActive(false);
                 }
                 else
                 {
                     ReadNextStep();
                 }
             }
         }
     }
 }
Exemple #3
0
        public static TutorialView Open(TutorialChapterData tutorialChapterData, TutorialStepData tutorialStepData)
        {
            TutorialView.Close();
            TutorialView tutorialView = UIMgr.instance.Open <TutorialView>(PREFAB_PATH, EUISortingLayer.Tutorial, UIOpenMode.Replace);

            tutorialView.SetData(tutorialChapterData, tutorialStepData);
            return(tutorialView);
        }
Exemple #4
0
    public TutorialStepData GetStep(int index)
    {
        TutorialStepData returnStep = null;

        if (index < _tutorialSetps.Count)
        {
            returnStep = _tutorialSetps[index];
        }
        return(returnStep);
    }
 public void Init(TutorialStepData tutorialStepData, Action <int> tutorialIndexChanged)
 {
     _tutorialStepData      = tutorialStepData;
     _tutorialIndexChanged  = tutorialIndexChanged;
     _tutorialIndexChanged += OnTutorialIndexChanged;
 }
Exemple #6
0
 public void Init(TutorialStepData tutorialStepData)
 {
     _tutorialStepPresentation = GetComponent <TutorialStepPresentation>();
 }
Exemple #7
0
        public void SetData(TutorialChapterData tutorialChapterData, TutorialStepData tutorialStepData)
        {
            _tutorialChapterData = tutorialChapterData;
            _tutorialStepData    = tutorialStepData;
            _waitMSGIDList       = new List <string>(_tutorialStepData.waitMSGIDList);
            for (int index = 0, count = _waitMSGIDList.Count; index < count; index++)
            {
                Observers.Facade.Instance.RegisterObserver(_waitMSGIDList[index].ToString(), OnReceiveWaitMSG);
            }

            if (_tutorialStepData.forceCompleteMSGIDList.Count > 0)
            {
                _forceCompleteMSGIDList = new List <string>(_tutorialStepData.forceCompleteMSGIDList);
                for (int index = 0, count = _forceCompleteMSGIDList.Count; index < count; index++)
                {
                    Observers.Facade.Instance.RegisterObserver(_forceCompleteMSGIDList[index].ToString(), OnReceiveForceCompleteMSG);
                }
            }
            else
            {
                _forceCompleteMSGIDList = null;
            }

            _handRootOffset  = tutorialStepData.handIndicatorOffset;
            _arrowRootOffset = tutorialStepData.arrowIndicatorOffset;

            maskImage.gameObject.SetActive(_tutorialStepData.enableMask);
            maskImage.GetComponent <UnityEngine.UI.Mask>().showMaskGraphic = _tutorialStepData.showMask;
            nextStepButton.gameObject.SetActive(_tutorialStepData.enableNextStepButton);
            if (_tutorialStepData.showDialog)
            {
                AnchorType dialogAnchorType = (AnchorType)Enum.Parse(typeof(AnchorType), _tutorialStepData.dialogAnchor);
                dialogRootRectTransform.anchorMin        = GetAnchoredVector2(dialogAnchorType);
                dialogRootRectTransform.anchorMax        = GetAnchoredVector2(dialogAnchorType);
                dialogRootRectTransform.pivot            = GetAnchoredVector2(dialogAnchorType);
                dialogRootRectTransform.anchoredPosition = _tutorialStepData.dialogOffset;
                dialogText.text = Localization.Get(_tutorialStepData.dialogContentID);
            }
            if (_tutorialStepData.showNPC)
            {
                NPCShowData npcShowData = NPCShowData.GetNPCShowData(_tutorialStepData.npcShowID);
                string      npcBodyPath = ResPath.GetNPCTexturePath(npcShowData.npc_name);
                string      npcFacePath = ResPath.GetNPCTexturePath(npcShowData.faceDic[_tutorialStepData.npcFace]);
                npcBodyRawImage.texture = ResMgr.instance.Load <Texture>(npcBodyPath);
                npcBodyRawImage.SetNativeSize();
                npcBodyRawImage.transform.localScale = new Vector3(_tutorialStepData.npcFlip ? -1 : 1, 1, 1);
                npcFaceRawImage.texture = ResMgr.instance.Load <Texture>(npcFacePath);
                npcFaceRawImage.SetNativeSize();
                npcFaceRawImage.rectTransform.anchorMin        = Vector2.zero;
                npcFaceRawImage.rectTransform.anchorMax        = Vector2.zero;
                npcFaceRawImage.rectTransform.pivot            = Vector2.zero;
                npcFaceRawImage.rectTransform.anchoredPosition = npcShowData.facePosition;

                AnchorType npcAnchorType = (AnchorType)Enum.Parse(typeof(AnchorType), _tutorialStepData.npcAnchor);
                npcBodyRawImage.rectTransform.anchorMin        = GetAnchoredVector2(npcAnchorType);
                npcBodyRawImage.rectTransform.anchorMax        = GetAnchoredVector2(npcAnchorType);
                npcBodyRawImage.rectTransform.pivot            = GetAnchoredVector2(npcAnchorType);
                npcBodyRawImage.rectTransform.anchoredPosition = _tutorialStepData.npcOffset;
            }
            if (_tutorialStepData.showIllustrateImage)
            {
                illustrateRawImage.texture = ResMgr.instance.Load <Texture>(ResPath.GetTutorialIllustrateImagePath(_tutorialStepData.illustrateImageName));
                illustrateRawImage.SetNativeSize();
                illustrateRawImage.rectTransform.anchoredPosition = _tutorialStepData.illustrateImageAnchoredPosition;
            }
            illustrateRawImage.gameObject.SetActive(_tutorialStepData.showIllustrateImage);
            dialogRootRectTransform.gameObject.SetActive(_tutorialStepData.showDialog);
            npcBodyRawImage.gameObject.SetActive(_tutorialStepData.showNPC);

            // Add for masked ui path
            Transform maskedTarget    = null;
            Transform maskedTransform = null;

            for (int index = 0, count = _tutorialStepData.maskedUIPathList.Count; index < count; index++)
            {
                maskedTarget = UIMgr.instance.GetParticularUITransform(_tutorialStepData.maskedUIPathList[index][0], _tutorialStepData.maskedUIPathList[index][1]);
                _maskedTargetTransformList.Add(maskedTarget);
                maskedTransform = Instantiate(maskedTarget);
                DestroyImmediate(maskedTransform.GetComponent <Button>());
                DestroyImmediate(maskedTransform.GetComponent <Toggle>());

                Image[] images = maskedTransform.GetComponentsInChildren <Image>();
                for (int i = 0, imagesCount = images.Length; i < imagesCount; i++)
                {
                    images[i].color = new Color(0, 0, 0, 0);
                }
                RawImage[] rawImages = maskedTransform.GetComponentsInChildren <RawImage>();
                for (int i = 0, rawImagesCount = rawImages.Length; i < rawImagesCount; i++)
                {
                    rawImages[i].color = new Color(0, 0, 0, 0);
                }

                maskedTransform.SetParent(maskedGameObjectsRoot, false);
                maskedTransform.position = new Vector3(maskedTarget.position.x, maskedTarget.position.y, 0);
                maskedTransform.SetAsFirstSibling();
                _maskedTransformList.Add(maskedTransform);
            }
            // Add for masked ui path

            skipButton.gameObject.SetActive(_tutorialChapterData.isSkippable);
            SetTargetTransform();
        }