示例#1
0
        void moveTimer_Tick(object sender, EventArgs e)
        {
            level.OneTick();
            int x, y;

            Bitmap   bmp = (Bitmap)pictureBox1.Image;
            Graphics g   = Graphics.FromImage(bmp);

            g.FillRectangle(Brushes.Black, 0, 0, bmp.Width, bmp.Height);
            foreach (GameItem akt in level.GameItemsCopy)
            {
                //if (akt.PosX != 24) continue;
                x = (int)(bmp.Width * akt.PosX / level.SizeX);
                y = (int)(bmp.Height * akt.PosY / level.SizeX);
                int   tilew    = bmp.Width / level.SizeX;
                int   tileh    = bmp.Height / level.SizeY;
                Brush aktBrush = Brushes.Gray;
                if (akt.ItemPlayer != null)
                {
                    aktBrush = akt.ItemPlayer.PlayerClient.ClientBrush;
                }
                if (akt is Ship)
                {
                    g.FillRectangle(aktBrush, x, y, tilew, tileh);
                }
                else
                {
                    g.FillEllipse(aktBrush, x, y, tilew, tileh);
                }
                g.DrawString(akt.NumberOfUnits.ToString(), Font_Small, Brushes.Black, x + 3, y + 3);
                //g.DrawString(akt.ItemId.ToString(), Font_Small, Brushes.Black, x + 2, y + 2);
            }
            //g.DrawString(level.CalcEndOfGame(false), MYFONT, Brushes.White, 10, 10);
            level.CalcEndOfGame(false);
            bmp = (Bitmap)pictureBox3.Image;
            g   = Graphics.FromImage(bmp);
            g.FillRectangle(Brushes.Black, 0, 0, bmp.Width, bmp.Height);
            y = 5;
            x = 5;
            foreach (Player akt in level.GamePlayers.Values)
            {
                g.DrawString(akt.PlayerClient.ClientName + ": " + akt.FinalPoints, Font_Big, akt.PlayerClient.ClientBrush, x, y);
                y += Font_Big.Height;
            }
            y += Font_Big.Height;
            g.DrawString("Remaining:" + level.currentTime, Font_Big, Brushes.White, x, y);
            y += Font_Big.Height;

            int idx = -1;

            foreach (Player akt in level.GamePlayers.Values)
            {
                idx++;
                if (idx == currentPlayer)
                {
                    string planets = string.Format("{0}/+{1}/-{2}", akt.FinalEndPlanets, akt.FinalPlanetsCaptured, akt.FinalPlanetsLost);
                    g.DrawString(planets, Font_Big, akt.PlayerClient.ClientBrush, x, y);
                    y += Font_Big.Height;
                    g.DrawString("  Shoots: " + akt.FinalShoots, Font_Big, akt.PlayerClient.ClientBrush, x, y);
                    y += Font_Big.Height;
                    g.DrawString("  Units: " + akt.FinalEndUnits, Font_Big, akt.PlayerClient.ClientBrush, x, y);
                    y += Font_Big.Height;
                    g.DrawString("  Points: " + akt.FinalPoints, Font_Big, akt.PlayerClient.ClientBrush, x, y);
                    y += Font_Big.Height;
                }
            }
            currentTicks--;
            if (currentTicks <= 0)
            {
                currentTicks = changeTicks;
                currentPlayer++;
                if (currentPlayer >= level.GamePlayers.Count)
                {
                    currentPlayer = 0;
                }
            }

            pictureBox1.Invalidate();
            pictureBox3.Invalidate();
            if (chkMapMask.Visible && level.GamePlayers.ContainsKey(txtMaskPlayer.Text))
            {
                Player akt = level.GamePlayers[txtMaskPlayer.Text];
                Bitmap uj  = new Bitmap(300, 300);
                g = Graphics.FromImage(uj);
                g.FillRectangle(Brushes.Black, 0, 0, uj.Width, uj.Height);
                int width  = akt.MapMask.GetLength(0);
                int height = akt.MapMask.GetLength(1);
                int tilew  = uj.Width / width;
                int tileh  = uj.Height / height;
                for (x = 0; x < width; x++)
                {
                    for (y = 0; y < height; y++)
                    {
                        if (akt.MapMask[x, y] == 1)
                        {
                            g.FillEllipse(Brushes.White, x * tilew, y * tileh, tilew, tileh);
                        }
                    }
                }
                pictureBox2.Image = uj;
            }
        }