예제 #1
0
        /// <summary>
        /// Updates the icon grid.
        /// </summary>
        private void UpdateIconGrid()
        {
            for (int i = 0; i < IconGrid.Length; i++)
            {
                for (int j = 0; j < IconGrid[i].Length; j++)
                {
                    //Get the icon element
                    PowerLiftIconElement iconElement = IconGrid[i][j];

                    //If there's no icon element here, continue
                    if (iconElement == null)
                    {
                        continue;
                    }

                    //Update the icon element
                    iconElement.Update();

                    //If the icon is completely done, clear it
                    if (iconElement.IsDone == true)
                    {
                        IconGrid[i][j] = null;
                    }
                }
            }
        }
예제 #2
0
 private void SetUpGrid()
 {
     //Initialize the icon grid
     IconGrid = new PowerLiftIconElement[NumColumns][];
     for (int i = 0; i < IconGrid.Length; i++)
     {
         IconGrid[i] = new PowerLiftIconElement[NumRows];
     }
 }
예제 #3
0
        /// <summary>
        /// Chooses an icon and creates an element at a particular grid index.
        /// </summary>
        private void CreateNextIconElement(int gridCol, int gridRow)
        {
            //Choose a random icon among Poison Mushrooms, Attack, and Defense
            int randIcon = RandomGlobals.Randomizer.Next((int)PowerLiftIcons.Poison, (int)PowerLiftIcons.Defense + 1);

            //Create the icon element
            PowerLiftIconElement element = new PowerLiftIconElement((PowerLiftIcons)randIcon, IconFadeTime, IconStayTime, .45f);

            IconGrid[gridCol][gridRow] = element;
        }
예제 #4
0
        private void HandleIconSelection(PowerLiftIconElement iconSelected)
        {
            if (iconSelected != null)
            {
                switch (iconSelected.PowerliftIcon)
                {
                case PowerLiftIcons.Poison:
                    IsPoisoned        = true;
                    ElapsedPoisonTime = 0d;

                    IconGrid[CurColumn][CurRow] = null;
                    break;

                case PowerLiftIcons.Attack:
                    AttackSelections++;
                    if (AttackSelections >= AttackBoostReq)
                    {
                        AttackBoosts++;
                        AttackSelections = 0;
                        LastAttackBoost  = Time.ActiveMilliseconds;

                        //Send the response with the new number of boosts
                        SendResponse(new ActionCommandGlobals.PowerLiftResponse(AttackBoosts, DefenseBoosts));
                    }

                    IconGrid[CurColumn][CurRow] = null;
                    break;

                case PowerLiftIcons.Defense:
                    DefenseSelections++;
                    if (DefenseSelections >= DefenseBoostReq)
                    {
                        DefenseBoosts++;
                        DefenseSelections = 0;
                        LastDefenseBoost  = Time.ActiveMilliseconds;

                        //Send the response with the new number of boosts
                        SendResponse(new ActionCommandGlobals.PowerLiftResponse(AttackBoosts, DefenseBoosts));
                    }

                    IconGrid[CurColumn][CurRow] = null;
                    break;

                default:
                    break;
                }
            }

            //Pressing A to select causes the cursor to turn red for 1 frame even if you don't hit an icon
            CursorColor  = SelectedColor;
            SelectedIcon = true;
        }
        private void DrawGrid()
        {
            //Draw the grid
            for (int i = 0; i < ActionCmd.IconGrid.Length; i++)
            {
                for (int j = 0; j < ActionCmd.IconGrid[i].Length; j++)
                {
                    PowerLiftIconElement iconElement = ActionCmd.IconGrid[i][j];

                    //Draw the icon elements
                    if (iconElement != null)
                    {
                        CroppedTexture2D croppedTex = IconGraphics[iconElement.PowerliftIcon];

                        if (croppedTex != null)
                        {
                            Vector2 position = PowerLiftGrid.GetPositionAtIndex(PowerLiftGrid.GetIndex(i, j));
                            SpriteRenderer.Instance.DrawUI(croppedTex.Tex, position, croppedTex.SourceRect, iconElement.TintColor, 0f, new Vector2(.5f, .5f), iconElement.Scale, false, false, iconElement.Depth);
                        }
                    }
                }
            }
        }