Exemplo n.º 1
0
    public void SpawnAllLevels()
    {
        Vector2 startingPos = new Vector2(Screen.width / 2f, 0);
        int     i           = 1;

        foreach (ChapterPreview lp in chapterPreviews)
        {
            GameObject o = Instantiate(lp.chapterObject, chapterSelectContainer);
            o.GetComponent <RectTransform>().anchoredPosition = startingPos + new Vector2(spacingBetweenChapters * (i - 1), 0);
            ChapterPreview spawnedLP = lp;
            spawnedLP.chapterObject = o;

            if (i > 1 && i > completedChapter + 1)
            {
                Transform lockLevel = Instantiate(chapterLockedPrefab, o.transform);

                lockLevel.SetAsLastSibling();
                spawnedLP.lockObject = lockLevel;
            }

            spawnedChapters.Add(spawnedLP);

            i++;
        }
        //Can't seem to get correct values here, so must call somewhere else
        //GetAllXPos();

        RectTransform levelSelectRect = chapterSelectContainer.GetComponent <RectTransform>();

        levelSelectRect.sizeDelta = new Vector2(spacingBetweenChapters * (i - 1), 0);
    }
Exemplo n.º 2
0
    public void SelectClosestLevel()
    {
        GetAllXPos();

        float smallestDist       = Mathf.Infinity;
        int   index              = -1;
        float currentContentXPos = chapterSelectContainerRect.anchoredPosition.x;

        for (int i = 0; i < levelsXPos.Count; i++)
        {
            float levelXPos      = levelsXPos[i];
            float distFromCenter = Mathf.Abs(currentContentXPos - -(levelXPos - firstLevelXPos));
            //print(currentContentXPos.ToString() + " " + levelXPos.ToString() + " " + firstLevelXPos.ToString());
            if (smallestDist > distFromCenter)
            {
                smallestDist = distFromCenter;
                index        = i;
            }
        }

        currentChapterSelected = spawnedChapters[index];

        SelectChapterLerp(index + 1);
    }
Exemplo n.º 3
0
        public ScenesWindow(Rect rect, GUIStyle style, params GUILayoutOption[] options)
            : base(rect, new GUIContent(TC.get("Element.Name1")), style, options)
        {
            new RectangleComponentEditor(Rect.zero, new GUIContent(""), style);

            // Button
            ButtonContent = new GUIContent()
            {
                image = Resources.Load <Texture2D>("EAdventureData/img/icons/scenes"),
                text  = "Element.Name1"
            };

            sceneEditor = new SceneEditor();
            sceneEditor.onSelectElement += (element) =>
            {
                if (sceneEditor.SelectedElement == null)
                {
                    return;
                }

                switch (sceneEditor.SelectedElement.ToString())
                {
                case "uAdventure.Editor.ExitDataControl": this.OpenedWindow = ScenesWindowType.Exits; break;

                case "uAdventure.Editor.ElementReferenceDataControl": this.OpenedWindow = ScenesWindowType.ElementReference; break;

                case "uAdventure.Editor.BarrierDataControl": this.OpenedWindow = ScenesWindowType.Barriers; break;

                case "uAdventure.Editor.ActiveAreaDataControl": this.OpenedWindow = ScenesWindowType.ActiveAreas; break;
                }
            };

            // Chapter preview subwindow
            chapterPreview = new ChapterPreview(rect, new GUIContent(""), "Window")
            {
                OnRequestRepaint = () => Repaint(),
                BeginWindows     = () => BeginWindows(),
                EndWindows       = () => EndWindows()
            };
            chapterPreview.OnSelectElement += (scene) =>
            {
                var index = Controller.Instance.SelectedChapterDataControl.getScenesList().getScenes().FindIndex(s => s == scene as SceneDataControl);
                ShowItemWindowView(index);
            };

            // Windows
            CreateSceneEditorTab <ScenesWindowAppearance>(rect, new GUIContent(TC.get("Scene.LookPanelTitle")), "Window", ScenesWindowType.Appearance, sceneEditor);
            CreateSceneEditorTab <ScenesWindowDocumentation>(rect, new GUIContent(TC.get("Scene.DocPanelTitle")), "Window", ScenesWindowType.Documentation, sceneEditor);
            CreateSceneEditorTab <ScenesWindowElementReference>(rect, new GUIContent(TC.get("ItemReferencesList.Title")), "Window", ScenesWindowType.ElementReference, sceneEditor);
            CreateSceneEditorTab <ScenesWindowActiveAreas>(rect, new GUIContent(TC.get("ActiveAreasList.Title")), "Window", ScenesWindowType.ActiveAreas, sceneEditor);
            CreateSceneEditorTab <ScenesWindowExits>(rect, new GUIContent(TC.get("ExitsList.Title")), "Window", ScenesWindowType.Exits, sceneEditor);

            if (Controller.Instance.PlayerMode == DescriptorData.MODE_PLAYER_3RDPERSON)
            {
                CreateSceneEditorTab <ScenesWindowBarriers>(rect, new GUIContent(TC.get("BarriersList.Title")), "Window", ScenesWindowType.Barriers, sceneEditor);
                CreateSceneEditorTab <ScenesWindowPlayerMovement>(rect, new GUIContent(TC.get("Trajectory.Title")), "Window", ScenesWindowType.PlayerMovement, sceneEditor);
            }

            DefaultOpenedWindow = ScenesWindowType.Appearance;
            OpenedWindow        = ScenesWindowType.Appearance;
        }