コード例 #1
0
 public void InitControlDicValue()
 {
     RefTimer.Change(System.Threading.Timeout.Infinite, 0);
     //    ErrorLog.Error("---");
     _dicRecordLog.Clear();
     _settingControl = tpSettings.Controls;
     InitSettingControl(tpSettings.Controls);
     InitDictionary(_settingControl);
 }
コード例 #2
0
        /// <summary>
        /// Renders everything
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Main_Paint(object sender, PaintEventArgs e)
        {
            gStopwatch.Reset();
            gStopwatch.Start();
            gBuf.ClearBuffer(Color.Black);

            #region Buffer Insertions

            gBuf.buffer.Graphics.DrawRectangle(new Pen(Color.Gray, 1), Border); // Draws border rectangle

            if (showGrid)
            {
                DisplayGrid(gBuf.buffer.Graphics);
            }

            for (int z = 0; z < GlobalPointOfInterest.Count; z++)
            {
                if (GlobalPointOfInterest[z] != null)
                {
                    try
                    {
                        Color c = Color.DarkRed;

                        if (GlobalPointOfInterest[z].IsGood)
                        {
                            c = Color.DarkGreen;
                        }

                        gBuf.buffer.Graphics.FillEllipse(new SolidBrush(c), GlobalPointOfInterest[z].Point.X - GlobalPointOfInterest[z].Value / 2, GlobalPointOfInterest[z].Point.Y - GlobalPointOfInterest[z].Value / 2, GlobalPointOfInterest[z].Value, GlobalPointOfInterest[z].Value);
                    }
                    catch
                    {
                    }
                }
            }

            for (int i = 0; i < Creatures.Count; i++)
            {
                if (!Creatures[i].Dead)
                {
                    if (DrawHealth)
                    {
                        Creatures[i].DrawHealth = true;
                    }
                    else
                    {
                        Creatures[i].DrawHealth = false;
                    }

                    Creatures[i].Draw(gBuf.buffer.Graphics);
                }
            }

            if (DrawStatistics)
            {
                if (pSize != null)
                {
                    labelSize.Text = "Largest: " + size;
                    gBuf.buffer.Graphics.DrawLine(new Pen(Color.White), labelSize.Location, pSize);
                }

                if (pSpeed != null)
                {
                    labelSpeed.Text = "Fastest: " + speed;
                    gBuf.buffer.Graphics.DrawLine(new Pen(Color.Yellow), labelSpeed.Location, pSpeed);
                }

                if (pHealth != null)
                {
                    labelHealth.Text = "Healthiest: " + health;
                    gBuf.buffer.Graphics.DrawLine(new Pen(Color.Red), labelHealth.Location, pHealth);
                }

                if (pEnergy != null)
                {
                    labelEnergy.Text = "Most fit: " + energy;
                    gBuf.buffer.Graphics.DrawLine(new Pen(Color.Green), labelEnergy.Location, pEnergy);
                }

                if (pAge.Count > 0)
                {
                    labelAge.Text = "Oldest: " + age;

                    for (int i = 0; i < pAge.Count; i++)
                    {
                        gBuf.buffer.Graphics.DrawLine(new Pen(Color.Green), labelAge.Location, pAge[i]);
                    }
                }
            }

            #endregion

            gBuf.RenderBuffer(e.Graphics);

            frames++;

            gStopwatch.Stop();
            TimeSpan ts = gStopwatch.Elapsed;
            labelRender.Text       = "R: " + ts.Milliseconds + " ms";
            labelFPS.Text          = "FPS: " + fps;
            labelClaculations.Text = "C: " + cTime + " ms";

            RefTimer.Start();
        }