Esempio n. 1
0
    public void Setup()
    {
        SETUP = MainTitleUI.getSetup();
        PLAYERDATA = GameObject.FindGameObjectWithTag("PlayerData").GetComponent<PlayerData>();
        PLAYERDATA.Launch();
        ThumbGO = new GameObject("Thumbnails");
        ThumbGO.transform.parent = gameObject.transform;
        ThumbGO.transform.localPosition = new Vector3(0f,0f,0f);
        levelName = FETool.findWithinChildren(gameObject, "LevelTitle/LEVEL_NAME").GetComponent<TextUI>();
        _btnLeft = FETool.findWithinChildren(gameObject, "SelectLeft").GetComponent<LevelChooserButton>();
        _btnRight = FETool.findWithinChildren(gameObject, "SelectRight").GetComponent<LevelChooserButton>();

        Thumbs.Clear();
        foreach (LevelInfo _lvl in PLAYERDATA.PROFILE.ActivatedLevels)
        {
            LevelThumbnail _th = CreateThumbnail(_lvl);
            Thumbs.Add(_th);
        }
        for (int j = 0; j < Thumbs.Count ; j++)
        {
        //			Thumbs[j].gameObject.transform.localPosition = new Vector3(0f,0f,0f);
            Thumbs[j].gameObject.transform.localPosition = new Vector3(j * gapThumbs.x, 0f, gapThumbs.z);
        }

        Thumbs[0].isStartSlot = true;
        Thumbs[Thumbs.Count-1].isEndSlot = true;

        _btnLeft.Setup(this, LevelChooserButton.DirectionList.Left);
        _btnRight.Setup(this, LevelChooserButton.DirectionList.Right);
        currThumb = Thumbs[0];
        levelName.text = currThumb.nameLv.ToString();
        checkCurrThumb();
    }
Esempio n. 2
0
 public void SwipeThumbnail(LevelChooserButton _btn)
 {
     Vector3 mod = new Vector3 (20f, 0f, 0f);
     if (_btn.direction == LevelChooserButton.DirectionList.Left)
     {
         new OTTween(ThumbGO.transform, _btn.twDuration, OTEasing.QuadInOut).Tween("position", ThumbGO.transform.position + mod);
     }
     else
     {
         new OTTween(ThumbGO.transform, _btn.twDuration, OTEasing.QuadInOut).Tween("position", ThumbGO.transform.position - mod);
     }
     currThumb = currThumb.FindThumbAround(Thumbs, currThumb, _btn.direction);
     levelName.text = currThumb.nameLv.ToString();
     checkCurrThumb();
 }
Esempio n. 3
0
    public LevelThumbnail FindThumbAround(List<LevelThumbnail> _listTh, LevelThumbnail _thumb, LevelChooserButton.DirectionList _dir)
    {
        LevelThumbnail res = null;
        LevelThumbnail lastThumb = _listTh[_listTh.Count-1];

        int nextThumb = _listTh.FindIndex(th => th.name == _thumb.name);
        if (_dir == LevelChooserButton.DirectionList.Left)
        {
            res = _listTh[nextThumb-1];
        }
        else
        {
            res = _listTh[nextThumb+1];
        }

        if (res == null)
        {
            Debug.LogError("Thumb not found");
        }
        return res;
    }
Esempio n. 4
0
        public LevelSelectState(Game game, Mod mod, Campaign campaign, int page, int highlight, bool editor, int justCompleted = -1) : base(game, "menus.level_select.title", "levels/empty.level", MenuArrangement.FullScreen)
        {
            m_mod         = mod;
            m_campaign    = campaign;
            m_page        = page;
            m_editor      = editor;
            m_highlight   = highlight;
            EnableGamepad = !m_editor;

            // Setup title
            if (m_editor)
            {
                TitleClickable = true;
                Title          = MouseButton.Left.GetPrompt() + " " + m_campaign.Title;
            }
            else
            {
                Title = m_campaign.Title;
            }

            // Create subtitle
            {
                m_subtitle               = new Text(UIFonts.Default, Game.Language.Translate("menus.level_select.subtitle"), UIColours.Text, TextAlignment.Center);
                m_subtitle.Anchor        = Anchor.TopMiddle;
                m_subtitle.LocalPosition = new Vector2(0.0f, 32.0f + UIFonts.Default.Height);
            }

            // Create buttons
            m_previousPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_previousPageButton.Region                        = new Quad(0.0f, 0.5f, 0.5f, 0.5f);
            m_previousPageButton.HighlightRegion               = m_previousPageButton.Region;
            m_previousPageButton.DisabledRegion                = m_previousPageButton.Region;
            m_previousPageButton.ShortcutButton                = GamepadButton.LeftBumper;
            m_previousPageButton.AltShortcutButton             = GamepadButton.LeftTrigger;
            m_previousPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuPreviousPage;
            m_previousPageButton.Anchor                        = Anchor.TopMiddle;
            m_previousPageButton.Colour                        = UIColours.Title;
            m_previousPageButton.HighlightColour               = UIColours.White;
            m_previousPageButton.LocalPosition                 = new Vector2(
                -240.0f - 0.5f * m_previousPageButton.Width,
                32.0f + UIFonts.Default.Height - 0.5f * m_previousPageButton.Height
                );
            m_previousPageButton.OnClicked += delegate(object sender, EventArgs e)
            {
                if (Dialog == null)
                {
                    PreviousPage();
                }
            };
            m_previousPageButton.Visible = (m_page > 0);

            // Next
            m_nextPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_nextPageButton.Region                        = new Quad(0.0f, 0.0f, 0.5f, 0.5f);
            m_nextPageButton.HighlightRegion               = m_nextPageButton.Region;
            m_nextPageButton.DisabledRegion                = m_nextPageButton.Region;
            m_nextPageButton.ShortcutButton                = GamepadButton.RightBumper;
            m_nextPageButton.AltShortcutButton             = GamepadButton.RightTrigger;
            m_nextPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuNextPage;
            m_nextPageButton.Anchor                        = Anchor.TopMiddle;
            m_nextPageButton.Colour                        = UIColours.Title;
            m_nextPageButton.HighlightColour               = UIColours.White;
            m_nextPageButton.LocalPosition                 = new Vector2(
                240.0f - 0.5f * m_nextPageButton.Width,
                32.0f + UIFonts.Default.Height - 0.5f * m_nextPageButton.Height
                );
            m_nextPageButton.OnClicked += delegate(object sender, EventArgs e)
            {
                if (Dialog == null)
                {
                    NextPage();
                }
            };
            m_nextPageButton.Visible = IsNextPageUnlocked();

            // Create thumbnails
            {
                var firstLevel = page * NUM_PER_PAGE;
                var lastLevel  = Math.Min(firstLevel + NUM_PER_PAGE, m_campaign.Levels.Count + (m_editor ? 1 : 0)) - 1;
                m_thumbnails = new LevelThumbnail[lastLevel - firstLevel + 1];

                float xStart = (NUM_COLUMNS * IMAGE_WIDTH + (NUM_COLUMNS - 1) * IMAGE_MARGIN) * -0.5f;
                float yStart = (NUM_ROWS * IMAGE_HEIGHT + (NUM_ROWS - 1) * IMAGE_MARGIN) * -0.5f + 16.0f;
                for (int i = firstLevel; i <= lastLevel; ++i)
                {
                    var levelPath  = (i < m_campaign.Levels.Count) ? m_campaign.Levels[i] : "NEW";
                    var levelIndex = i;

                    var pos       = i - firstLevel;
                    var thumbnail = new LevelThumbnail(levelPath, IMAGE_WIDTH, IMAGE_HEIGHT, Game.Language);
                    thumbnail.Anchor        = Anchor.CentreMiddle;
                    thumbnail.LocalPosition = new Vector2(
                        xStart + (pos % NUM_COLUMNS) * (IMAGE_WIDTH + IMAGE_MARGIN),
                        yStart + (pos / NUM_COLUMNS) * (IMAGE_HEIGHT + IMAGE_MARGIN)
                        );
                    thumbnail.Completed     = !m_editor && Game.User.Progress.IsLevelCompleted(LevelData.Get(levelPath).ID);
                    thumbnail.JustCompleted = thumbnail.Completed && (i == justCompleted);
                    thumbnail.Locked        = !IsLevelUnlocked(campaign, mod, levelIndex);
                    thumbnail.JustUnlocked  = !thumbnail.Locked && !thumbnail.Completed && WasJustUnlocked(campaign, mod, i, justCompleted);
                    thumbnail.CanDelete     = m_editor && levelIndex != m_campaign.Levels.Count;
                    thumbnail.CanMoveLeft   = m_editor && levelIndex > 0 && levelIndex != m_campaign.Levels.Count;
                    thumbnail.CanMoveRight  = m_editor && levelIndex < m_campaign.Levels.Count - 1;

                    thumbnail.OnClicked += delegate(object sender, EventArgs e)
                    {
                        if (Dialog == null)
                        {
                            PlayOrEditLevel(levelIndex);
                        }
                    };

                    thumbnail.OnDeleteClicked += delegate(object sender, EventArgs e)
                    {
                        if (Dialog == null)
                        {
                            DeleteLevel(TranslateTitle(thumbnail.LevelTitle), levelIndex);
                        }
                    };

                    thumbnail.OnMoveLeftClicked += delegate(object sender, EventArgs e)
                    {
                        if (Dialog == null)
                        {
                            SwapLevels(levelIndex, levelIndex - 1);
                            CutToState(new LevelSelectState(Game, m_mod, m_campaign, m_page, -1, m_editor));
                        }
                    };

                    thumbnail.OnMoveRightClicked += delegate(object sender, EventArgs e)
                    {
                        if (Dialog == null)
                        {
                            SwapLevels(levelIndex, levelIndex + 1);
                            CutToState(new LevelSelectState(Game, m_mod, m_campaign, m_page, -1, m_editor));
                        }
                    };

                    m_thumbnails[pos] = thumbnail;
                }
            }
        }