Esempio n. 1
0
        /// <summary>
        /// Call this function before doing anything with the console
        /// </summary>
        internal static void Init()
        {
            CmdLog  = new DropOutStack <LogEntry>(MaxHistory);
            History = new DropOutStack <string>(MaxHistory);
            Style   = new GUIStyle
            {
                font     = Font.CreateDynamicFontFromOSFont("Consolas", 16),
                richText = true
            };

            Shell.LoadCommands();

            ModInput.RegisterBinding(null, "ToggleConsole", KeyCode.BackQuote);
            ModInput.RegisterBinding(null, "ConsoleAutocompletion", KeyCode.Tab);

            Initialized = true;

            Log("Console initialized");
            Log("Type \"help\" to get a list of commands");

            while (EntryQueue.Any())
            {
                KeyValuePair <LogType, object> entry = EntryQueue.Dequeue();
                Log(entry.Key, entry.Value);
            }
        }
Esempio n. 2
0
        public FXPerf(string name, string anno, int capacity, bool debugging) : base(name, anno)
        {
            /// INIT

            glqueryStart    = 0;
            timerStartFrame = -1;
            startTime       = 0;
            endTime         = 0;
            queryActive     = false;

            if (debugging)
            {
                return;
            }

            /// CREATE TIMER STACKS

            timings = new DropOutStack <float>(capacity);
            frames  = new DropOutStack <int>(capacity);

            /// CREATE OPENGL TIMER QUERY

            glqueryStart = (uint)GL.GenQuery();
            glqueryEnd   = (uint)GL.GenQuery();
        }
Esempio n. 3
0
        private void Awake()
        {
            if (PlayerPrefs.GetInt("DrawThree") == 1)
            {
                gameObject.SetActive(false);
            }

            _moves = new DropOutStack <Move>(Convert.ToInt32(PlayerPrefs.GetString("UndoCount")));
        }
Esempio n. 4
0
        public DropOutStack(DropOutStack <T> toClone)
        {
            var len = toClone._items.Length;

            _items = new T[len];
            Array.Copy(toClone._items, _items, len);
            _top   = toClone._top;
            _count = toClone._count;
        }
Esempio n. 5
0
        private DropOutStack <char> Initialize(int capacity)
        {
            var stackTest = new DropOutStack <char>(capacity);

            foreach (var ch in DigitsAlphabetsUpper)
            {
                stackTest.Push(ch);
            }

            return(stackTest);
        }
Esempio n. 6
0
        private double CalculateRollingAverage(DropOutStack <double> stack)
        {
            double total = 0;

            for (int i = 0; i < c_rollingAveragingRange; i++)
            {
                total += stack[i];
            }

            return(total / c_rollingAveragingRange);
        }
Esempio n. 7
0
 internal void Reset()
 {
     pc         = 0;
     W          = 0;
     R          = new int[256];
     Stack      = new DropOutStack <int>(8);
     prescaler  = 0;
     ignoreBank = false;
     writeRegister(0x3, 24);
     R[0x81]        = 0b1111_1111;
     R[0x85]        = 0b1_1111;
     R[0x86]        = 0b1111_1111;
     laufzeitzähler = 0;
 }
Esempio n. 8
0
        private double CalculateMovingAverage(DropOutStack <double> stack)
        {
            int    weight = stack.Capacity;
            double total  = 0;
            int    size   = 0;

            foreach (double item in stack)
            {
                total += item * weight;
                size  += weight;
                weight--;
            }

            return(total / size);
        }
Esempio n. 9
0
        public void DropoutTest()
        {
            var stack = new DropOutStack <string>(3);

            Assert.IsNull(stack.Pop());
            stack.Push("A");
            stack.Push("B");
            stack.Push("C");
            Assert.AreEqual("C", stack.Pop());
            Assert.AreEqual("B", stack.Pop());
            Assert.AreEqual("A", stack.Pop());
            Assert.IsNull(stack.Pop());
            stack.Push("A");
            stack.Push("B");
            stack.Push("C");
            Assert.AreEqual("C", stack.Pop());
            Assert.AreEqual("B", stack.Pop());
            Assert.AreEqual("A", stack.Pop());
            Assert.IsNull(stack.Pop());
        }
Esempio n. 10
0
        void Start()
        {
            if (tilePositions.Count <= 0)
            {
                Tile[] tiles = GetComponentsInChildren <Tile>();
                if (tiles.Length == 0)
                {
                    Debug.LogError("No Tiles found!!");
                    return;
                }

                foreach (Tile tile in tiles)
                {
                    tilePositions.Add(tile.GridPosition, tile);
                }
            }

            if (Styles.Count == 0)
            {
                Debug.LogError("There need to be at least 2 Styles set");
            }
            Styles.Sort((a, b) => a.score.CompareTo(b.score));

            //set the initial tile to a state (If loading save game this doesn't matter)
            if (Score == 0)
            {
                Tile edge1 = FindEmptyEdgeTile();
                SpawnTile(edge1, true);
                Tile edge2 = FindEmptyEdgeTile();
                SpawnTile(edge2, true);
            }

            if (GameOver != null)
            {
                GameOver.gameObject.SetActive(false);
            }

            history = new DropOutStack <BoardState>(historyLength);
            UpdateHistory(); //save initial state
        }
Esempio n. 11
0
        /// <summary>
        /// draws the main graph section
        /// </summary>
        private void DrawGraph(DrawingContext drawingContext)
        {
            if (NetworkFrames.Count <= 1)
            {
                return;
            }

            RenderOptions.SetEdgeMode(this, EdgeMode.Unspecified);
            int    x      = (int)ActualWidth - 1;
            double yMin   = ActualHeight - 1;
            double yRange = yMin - 3;

            DesiredNetworkBufferSize = x;

            NetworkFrame[] frames = NetworkFrames.Take(x).ToArray();
            double[]       up     = new double[Math.Min(x, frames.Length)];
            double[]       down   = new double[Math.Min(x, frames.Length)];
            double         range  = 0;

            if (RenderMode == RenderingMode.Average && up.Length > c_rollingAveragingRange)
            {
                int i = 0;
                DropOutStack <double> upStack   = new DropOutStack <double>(c_rollingAveragingRange);
                DropOutStack <double> downStack = new DropOutStack <double>(c_rollingAveragingRange);
                foreach (NetworkFrame frame in frames)
                {
                    if (i > up.Length)
                    {
                        break;
                    }

                    upStack.Push(frame.Upload);
                    downStack.Push(frame.Download);
                    up[i]   = Math.Max(frame.Upload, CalculateRollingAverage(upStack));
                    down[i] = Math.Max(frame.Download, CalculateRollingAverage(downStack));

                    range = Math.Max(up[i], Math.Max(down[i], range));
                    i++;
                }
            }
            else if (RenderMode == RenderingMode.AverageMoving && up.Length > c_movingAveragingRange)
            {
                int i = 0;
                DropOutStack <double> upStack   = new DropOutStack <double>(c_movingAveragingRange);
                DropOutStack <double> downStack = new DropOutStack <double>(c_movingAveragingRange);
                foreach (NetworkFrame frame in frames)
                {
                    if (i > up.Length)
                    {
                        break;
                    }

                    upStack.Push(frame.Upload);
                    downStack.Push(frame.Download);
                    up[i]   = Math.Max(frame.Upload, CalculateMovingAverage(upStack));
                    down[i] = Math.Max(frame.Download, CalculateMovingAverage(downStack));

                    range = Math.Max(up[i], Math.Max(down[i], range));
                    i++;
                }
            }
            else if (RenderMode == RenderingMode.Smart && up.Length > c_movingAveragingRange && up.Length > c_rollingAveragingRange)
            { // Combine both average and moving average
                int i = 0;
                DropOutStack <double> upStack   = new DropOutStack <double>(Math.Max(c_movingAveragingRange, c_rollingAveragingRange));
                DropOutStack <double> downStack = new DropOutStack <double>(Math.Max(c_movingAveragingRange, c_rollingAveragingRange));
                foreach (NetworkFrame frame in frames)
                {
                    if (i > up.Length)
                    {
                        break;
                    }

                    upStack.Push(frame.Upload);
                    downStack.Push(frame.Download);

                    up[i]   = Math.Max(CalculateRollingAverage(upStack), CalculateMovingAverage(upStack));
                    down[i] = Math.Max(CalculateRollingAverage(downStack), CalculateMovingAverage(downStack));

                    range = Math.Max(up[i], Math.Max(down[i], range));
                    i++;
                }
            }
            else if (RenderMode == RenderingMode.Thick && up.Length > c_maxedAveragingRange)
            {
                int i = 0;
                DropOutStack <double> upStack   = new DropOutStack <double>(c_maxedAveragingRange);
                DropOutStack <double> downStack = new DropOutStack <double>(c_maxedAveragingRange);
                foreach (NetworkFrame frame in frames)
                {
                    if (i >= up.Length)
                    {
                        break;
                    }

                    upStack.Push(frame.Upload);
                    downStack.Push(frame.Download);
                    up[i]   = upStack.Max();
                    down[i] = downStack.Max();

                    range = Math.Max(up[i], Math.Max(down[i], range));
                    i++;
                }
            }
            else // RenderMode == RenderingMode.Direct
            {
                int i = 0;
                foreach (NetworkFrame frame in frames)
                {
                    if (i > up.Length)
                    {
                        break;
                    }

                    up[i]   = frame.Upload;
                    down[i] = frame.Download;

                    range = Math.Max(up[i], Math.Max(down[i], range));
                    i++;
                }
            }

            for (int i = 0; i < up.Length - 1; i++)
            {
                double barRange = down[i] / range;
                drawingContext.DrawLine(m_downloadPen, new Point(x, yMin), new Point(x, yMin - (yRange * barRange)));

                barRange = up[i] / range;
                drawingContext.DrawLine(m_uploadPen, new Point(x, yMin), new Point(x, yMin - (yRange * barRange)));

                x -= 1;
            }

            RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
        }
Esempio n. 12
0
 private void Awake()
 {
     _lastScores = new DropOutStack <string>(Convert.ToInt32(PlayerPrefs.GetString("UndoCount")));
 }