Exemplo n.º 1
0
        public void Shift(int amount)
        {
            while (amount != 0)
            {
                if (amount > 0)
                {
                    // Cursor goes right, grid elements go left.
                    UIGridLevelElement e = Get(0);
                    for (int i = 0; i < kWidth - 1; i++)
                    {
                        Add(Get(i + 1), i, 0);
                    }
                    Add(e, kWidth - 1, 0);
                    if (e != null)
                    {
                        e.Level = null;
                        e.Dirty = true;
                        e.SetOrientation(baseOrients[kWidth - 1]);
                        Foley.PlayShuffle();
                    }
                    --amount;
                }
                else
                {
                    // Cursor goes left, grid elements go right.
                    UIGridLevelElement e = Get(kWidth - 1);
                    for (int i = kWidth - 1; i > 0; i--)
                    {
                        Add(Get(i - 1), i, 0);
                    }
                    Add(e, 0, 0);
                    if (e != null)
                    {
                        e.Level = null;
                        e.Dirty = true;
                        e.SetOrientation(baseOrients[0]);
                        Foley.PlayShuffle();
                    }
                    ++amount;
                }

                if (!NoValidLevels)
                {
                    Foley.PlayShuffle();
                }
            }
        }   // end of Shift()
Exemplo n.º 2
0
        /// <summary>
        /// Loads the correct "level" data to each of the grid elements,
        /// </summary>
        /// <param name="cursor"></param>
        public void Reload(ILevelSetCursor cursor)
        {
            Log("Begin Reload");

            for (int i = 0; i < kWidth; ++i)
            {
                LevelMetadata level = cursor[i - kFront];

                UIGridLevelElement existing = Get(i);

                // If they already match then we're good.
                if (existing != null && existing.Level == level)
                {
                    continue;
                }

                // If there's no element and no level, also good.
                if (existing == null && level == null)
                {
                    continue;
                }

                if (level != null)
                {
                    // Need to create a new element
                    if (existing == null)
                    {
                        existing = CreateElement(level);
                        Add(existing, i, 0);
                        existing.SetOrientation(baseOrients[i]);
                    }
                    existing.Level = level;
                }
                else
                {
                    // No level, so set element's ref to null.
                    existing.Level = null;
                }
            }

            Log("End Reload");
        }
Exemplo n.º 3
0
        }   // end of SplitAt()

        /// <summary>
        /// Removes the element at index, collapses the rest of the list,
        /// and then adds the removed element back to the end of the list.
        /// </summary>
        /// <param name="index"></param>
        public void Remove(int index)
        {
            index += kFront;

            if (index >= 0 && index < ActualDimensions.X)
            {
                UIGridLevelElement e = Get(index);
                for (int i = index; i < kWidth - 1; i++)
                {
                    Add(grid[i + 1, 0], i, 0);
                }
                Add(e, kWidth - 1, 0);
                if (e != null)
                {
                    e.Level = null;
                    e.Dirty = true;
                    e.SetOrientation(baseOrients[kWidth - 1]);
                }
            }
        }
Exemplo n.º 4
0
        }   // end of Refresh()

        public override void Update(ref Matrix parentMatrix)
        {
            focusIndex.X = kFront;
            focusIndex.Y = 0;

            UIGridLevelElement e = Get(kFront);

            if (e != null)
            {
                e.Selected = true;
            }

            // Update orientations.
            if (!isDragging)
            {
                //if (!hasResidualVelocity)
                //{
                //    // Settle a dragged grid back into fixed positions.
                //    SettleGrid();
                //}
                //else
                //{
                if (hasResidualVelocity)
                {
                    // Residual velocity still affecting the grid.
                    UpdateResidualVelocity();
                    for (int i = 0; i < kWidth; i++)
                    {
                        e = Get(i);
                        if (e != null)
                        {
                            e.SetOrientation(currentOrients[i]);
                        }
                    }
                }
                else
                {
                    hasResidualVelocity = false;
                    residualVelocity    = 0.0f;

                    // Settle elements back into base orientation.
                    for (int i = 0; i < kWidth; i++)
                    {
                        e = Get(i);
                        if (e != null)
                        {
                            e.TwitchOrientation(baseOrients[i]);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < kWidth; i++)
                {
                    e = Get(i);
                    if (e != null)
                    {
                        e.SetOrientation(currentOrients[i]);
                    }
                }
            }

            base.Update(ref parentMatrix);
        }   // end of Update();