コード例 #1
0
        public void UpdateSelector(NoteSelector left, NoteSelector right)
        {
            bool isLeftConnected = false;

            if (left != null && left.ActiveBlockPos == ActiveBlockPos && ActiveBlockPos != null)
            {
                isLeftConnected = true;
            }
            bool isRightConnected = false;

            if (right != null && right.ActiveBlockPos == ActiveBlockPos && ActiveBlockPos != null)
            {
                isRightConnected = true;
            }
            if (isLeftConnected && isRightConnected)
            {
                blocks[(int)ActiveBlockPos].CurrentMode = NoteBlock.Mode.Middle;
            }
            else if (isLeftConnected)
            {
                blocks[(int)ActiveBlockPos].CurrentMode = NoteBlock.Mode.Right;
            }
            else if (isRightConnected)
            {
                blocks[(int)ActiveBlockPos].CurrentMode = NoteBlock.Mode.Left;
            }
            else if (ActiveBlockPos != null)
            {
                blocks[(int)ActiveBlockPos].CurrentMode = NoteBlock.Mode.Single;
            }
        }
コード例 #2
0
        protected override void Awake()
        {
            base.Awake();

            if (NoteEditorUpdated == null)
            {
                NoteEditorUpdated = new NoteEditorUpdated();
            }

            bounds = new BoundsInt(-slotsAmount / 2 - slotsAmount % 2, 0, 0, slotsAmount, 2, 0);

            float noteWidth = 0;

            Vector2?selectorSize = null;

            for (int i = bounds.xMin; i < bounds.xMax; ++i)
            {
                NoteSelector selector = Instantiate(data.NoteSelectorPrefab, grid.transform);
                if (selectorSize == null)
                {
                    selectorSize = selector.Size;
                    InitGrid(selector.Size);
                }

                selector.SelectorIndex           = i - bounds.xMin;
                selector.transform.localPosition = Helpers.ReplaceZ(
                    grid.GetCellCenterLocal(new Vector3Int(i, 0, 0)), -0.1f);
                selectors.Add(selector);
                selector.NoteSelected.AddListener(UpdateSelectors);
                noteWidth = selector.NoteSize.x;
            }

            spriteRenderer      = GetComponent <SpriteRenderer>();
            spriteRenderer.size = new Vector2(noteWidth * slotsAmount + 2 * data.ContentMargin,
                                              spriteRenderer.size.y);

            if (data.NoteProgressGridUiPrefab != null)
            {
                InitProgressGrid();
            }

            InitPointer(new Vector3Int(bounds.xMin, -1, 0));
        }