예제 #1
0
        /// <summary>
        /// This is called when the focus has moved to scroll the grid.
        /// </summary>
        private void Scroll()
        {
            if (scrolling)
            {
                // Without a twitch...
                //scrollOffset = grid[ focusIndex.X, focusIndex.Y ].Position;

                // Create a twitch to scroll the grid.
                TwitchManager.GetVector3    get    = delegate(Object param) { return(scrollOffset); };
                TwitchManager.SetVector3    set    = delegate(Vector3 value, Object param) { scrollOffset = value; };
                TwitchManager.Vector3Twitch twitch = new TwitchManager.Vector3Twitch(get, set, grid[focusIndex.X, focusIndex.Y].Position, 0.15f, TwitchCurve.Shape.Linear, null);
                twitch.Start();
            }
        }
예제 #2
0
        }   // end of TexturePicker InitFileList()

        public void Update()
        {
            if (active)
            {
                GamePadInput pad = GamePadInput.GetGamePad1();

                // Switch active grid?
                bool changed = false;
                if (pad.LeftStickLeft.WasPressed || pad.DPadLeft.WasPressed)
                {
                    activeGrid = (activeGrid + 3) % 4;
                    changed    = true;
                    Foley.PlayProgrammingClick();
                }
                if (pad.LeftStickRight.WasPressed || pad.DPadRight.WasPressed)
                {
                    activeGrid = (activeGrid + 1) % 4;
                    changed    = true;
                    Foley.PlayProgrammingClick();
                }

                if (changed)
                {
                    Vector3 newPosition                = new Vector3(-2.25f + 1.5f * activeGrid, 0.0f, 0.0f);
                    TwitchManager.GetVector3    get    = delegate(Object param) { return(selectionPlate.Position); };
                    TwitchManager.SetVector3    set    = delegate(Vector3 value, Object param) { selectionPlate.Position = value; };
                    TwitchManager.Vector3Twitch twitch = new TwitchManager.Vector3Twitch(get, set, newPosition, 0.25f, TwitchCurve.Shape.OvershootOut);
                    twitch.Start();

                    grid0.Active = false;
                    grid1.Active = false;
                    grid2.Active = false;
                    grid3.Active = false;

                    switch (activeGrid)
                    {
                    case 0: grid0.Active = true; break;

                    case 1: grid1.Active = true; break;

                    case 2: grid2.Active = true; break;

                    case 3: grid3.Active = true; break;
                    }

                    changed = false;
                }

                backPlate.Update();
                selectionPlate.Update();
                grid0.Update(ref worldGrid);
                grid1.Update(ref worldGrid);
                grid2.Update(ref worldGrid);
                grid3.Update(ref worldGrid);

                // See if any of the grids have changed which texture is in focus.
                // If so, change what the terrain sees.
                if (grid0.SelectionIndex.Y != curFocusIndex0)
                {
                    curFocusIndex0 = grid0.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(0, files[curFocusIndex0]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid1.SelectionIndex.Y != curFocusIndex1)
                {
                    curFocusIndex1 = grid1.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(1, files[curFocusIndex1]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid2.SelectionIndex.Y != curFocusIndex2)
                {
                    curFocusIndex2 = grid2.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(2, files[curFocusIndex2]);
                    InGame.inGame.IsLevelDirty = true;
                }
                if (grid3.SelectionIndex.Y != curFocusIndex3)
                {
                    curFocusIndex3 = grid3.SelectionIndex.Y;
                    InGame.inGame.Terrain.ChangeTerrainTexture(3, files[curFocusIndex3]);
                    InGame.inGame.IsLevelDirty = true;
                }

                float outerRowAlpha = 0.3f;
                float innerRowAlpha = 0.7f;

                // Update the alpha values of the visible tiles.
                for (int i = 0; i < grid0.ActualDimensions.Y; i++)
                {
                    UIGrid2DTextureElement e = null;

                    e = grid0.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid0.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }

                    e = grid1.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid1.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                    e = grid2.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid2.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                    e = grid3.Get(0, i) as UIGrid2DTextureElement;
                    if (e != null)
                    {
                        int delta = Math.Abs(i - grid3.SelectionIndex.Y);
                        if (delta < 2)
                        {
                            e.Alpha = 1.0f;
                        }
                        else if (delta < 3)
                        {
                            e.Alpha = innerRowAlpha;
                        }
                        else
                        {
                            e.Alpha = outerRowAlpha;
                        }
                    }
                }
            }
        }   // end of TexturePicker Update()