Exemple #1
0
        // This is the "fast" method that cuts corners and assumes way too much about the data. I'll
        // document the assumptions as I make them, though they seem to be safe anyway.
        public static void fastOptimizeIndices(BSP me)
        {
            long largestIndex = 2;             // Assumption: Highest index will always be at least 2.

            for (int i = 0; i < me.Indices.Count / 3; i++)
            {
                if (me.Indices[(i * 3) + 2] > largestIndex)                // Assumption: Every third index will be greater than the previous two
                {
                    largestIndex = me.Indices[(i * 3) + 2];
                }
            }
            NumList newIndices = new NumList(NumList.dataType.UINT);

            for (int i = 0; i < largestIndex - 1; i++) // Assumption: If the highest index is N, there will be N-1 sets of three ints
            {
                newIndices.Add(0);                     // Assumption: The first index in a triple will always be 0
                newIndices.Add(i + 1);                 // Assumption: The second index is always the current set of three plus one
                newIndices.Add(i + 2);                 // Assumption: The third index is always the current set of three plus two
            }
            me.Indices = newIndices;
            for (int i = 0; i < me.Faces.Count; i++)
            {
                me.Faces[i].FirstIndex = 0;                 // Assumption: Every face starts at the beginning of the pattern, and will take what it needs
            }
            Console.WriteLine("Indices optimized to " + (newIndices.Count * 4) + " bytes.");
        }
        NumTable GetDiagonalDown(NumTable table)
        {
            var tableDiagonalDown = new NumTable();

            // get bottom-left triangle
            for (int row = 0; row < table.Height(); ++row)
            {
                var newList = new NumList();
                for (int col = 0; col + row < table.Width(); ++col)
                {
                    var diagOffset = col;
                    newList.Add(table[row + diagOffset][col]);
                }
                newList.TrimExcess();
                tableDiagonalDown.Add(newList);
            }

            // get top-right triangle
            // offset col by 1 because [0][0] was collected by last loop
            for (int col = 1; col < table.Width(); ++col)
            {
                var newList = new NumList();
                for (int row = 0; row + col < table.Width(); ++row)
                {
                    var diagOffset = col - 1;
                    newList.Add(table[row + diagOffset][col]);
                }
                newList.TrimExcess();
                tableDiagonalDown.Add(newList);
            }
            tableDiagonalDown.TrimExcess();
            return(tableDiagonalDown);
        }
Exemple #3
0
        public void SpawnNum(Numoptions op, int dmg)
        {
            Label lbl = new Label
            {
                Content    = dmg,
                FontWeight = FontWeights.Bold,
                Margin     = new Thickness(583, 171, 0, 0),
                FontSize   = 28,
                Tag        = ControlTag.damagenum
            };

            if (op == Numoptions.normal)
            {
                lbl.Foreground = Brushes.LightGoldenrodYellow;
            }
            if (op == Numoptions.crit)
            {
                lbl.Foreground = Brushes.LightPink;
            }
            if (op == Numoptions.miss)
            {
                lbl.Content    = "MISS";
                lbl.Foreground = Brushes.White;
            }
            NumList.Add(lbl);
            BattleGrid.Children.Add(lbl);
        }
Exemple #4
0
        /// <summary>
        /// 加入數據
        /// </summary>
        /// <param name="SrcNum"></param>
        public void Add(byte SrcNum)
        {
            if (SrcNum < 1 || SrcNum > 49)
            {
#if DEBUG
                Trace.WriteLine("Wrong SrcNum : " + SrcNum);
#endif
            }
            else
            {
                NumList.Add(SrcNum);
            }
        }
        NumTable GetTopToBottom(NumTable table)
        {
            var tableTopToBottom = new NumTable();

            for (int i = 0; i < table.Width(); ++i)
            {
                NumList listTopToBottom = new NumList();
                for (int row = 0; row < table.Height(); ++row)
                {
                    listTopToBottom.Add(table[row][i]);
                }
                listTopToBottom.TrimExcess();
                tableTopToBottom.Add(listTopToBottom);
            }

            tableTopToBottom.TrimExcess();
            return(tableTopToBottom);
        }
        NumTable GetDiagonalUp(NumTable table)
        {
            var tableDiagonalUp = new NumTable();

            var maxIndexHeight = table.Height() - 1;
            var maxIndexWidth  = table.Width() - 1;

            // get top-left triangle
            for (int row = 0; row > table.Height(); ++row)
            {
                var newList = new NumList();
                for (int col = maxIndexWidth; col >= 0; --col)
                {
                    var diagOffset = col;
                    newList.Add(table[row + diagOffset][col]);
                }
                newList.TrimExcess();
                tableDiagonalUp.Add(newList);
            }

            // get bottom-right triangle
            // offset row by 1 because [0][0] was collected by last loop
            for (int row = 1; row < table.Height(); ++row)
            {
                var newList = new NumList();
                for (int col = maxIndexWidth; col <= maxIndexWidth - col; --col)
                {
                    var diagOffset = maxIndexWidth - col;
                    newList.Add(table[row + diagOffset][col]);
                }
                tableDiagonalUp.Add(newList);
            }

            tableDiagonalUp.TrimExcess();
            return(tableDiagonalUp);
        }