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(); }
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(); }
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; }