コード例 #1
0
ファイル: Meele.cs プロジェクト: ltduy/hihuc
        internal virtual List <ForcedPoint> GetRecentForced()
        {
            List <ForcedPoint> forces = new List <ForcedPoint>();

            #region Tank Forced
            Enemy[] enemies = new Enemy[MyBot.Targets.Values.Count];
            MyBot.Targets.Values.CopyTo(enemies, 0);
            foreach (var tank in enemies)
            {
                if (tank.Live == true && tank.Name != MyBot.Name) // prevent my name because location send through message from other droid
                {
                    var tankForce = new ForcedPoint(tank.X, tank.Y, tank.IsTeamate ? 3000 : 5000);
                    forces.Add(tankForce);
                }
            }
            #endregion

            #region Middle-Field Forced
            _midpointcount++;
            if (_midpointcount > 5)
            {
                _midpointcount    = 0;
                _midpointstrength = (_randomizer.NextDouble() * 5000);
            }
            var middleFieldForce = new ForcedPoint(MyBot.BattleFieldWidth / 2, MyBot.BattleFieldHeight / 2, _midpointstrength);
            forces.Add(middleFieldForce);
            #endregion

            #region Bullets forced
            if (BulletForces.Count > 0)
            {
                foreach (var bulletForce in BulletForces)
                {
                    forces.Add(bulletForce);
                    bulletForce.AffectTurn--;
                }
                BulletForces = BulletForces.FindAll(bf => bf.AffectTurn > 0);
            }
            #endregion

            #region Wall forced
            var wallForcePower  = 4500;
            var rightWallForce  = (new ForcedPoint(MyBot.BattleFieldWidth, MyBot.Y, wallForcePower)); forces.Add(rightWallForce);
            var leftWallForce   = (new ForcedPoint(0, MyBot.Y, wallForcePower)); forces.Add(leftWallForce);
            var topWallForce    = (new ForcedPoint(MyBot.X, MyBot.BattleFieldHeight, wallForcePower)); forces.Add(topWallForce);
            var bottomWallForce = (new ForcedPoint(MyBot.X, 0, wallForcePower)); forces.Add(bottomWallForce);
            #endregion

            return(forces);
        }
コード例 #2
0
ファイル: Meele.cs プロジェクト: ltduy/hihuc
        public override void OnPaint(IGraphics graphics)
        {
            var currentForces = new ForcedPoint[_recentForces.Count];

            _recentForces.CopyTo(currentForces);

            foreach (var item in currentForces)
            {
                var pen         = new Pen(item.Color);
                var teamMatePen = new Pen(Color.Orange);
                var brush       = new SolidBrush(item.Color);
                var size        = (float)item.Power / 50;
                var drawPoint   = new RectangleF
                {
                    X      = (float)item.X - size / 2,
                    Y      = (float)item.Y - size / 2,
                    Height = size,
                    Width  = size
                };
                graphics.DrawEllipse(item.Power == 3000 ? teamMatePen : pen, drawPoint);

                graphics.DrawString(item.Power.ToString(), new Font(FontFamily.GenericSerif, 150, FontStyle.Bold, GraphicsUnit.Millimeter), Brushes.White, new PointF
                {
                    X = (float)item.X,
                    Y = (float)item.Y
                });
            }

            var botsize = 100;

            graphics.DrawEllipse(Pens.DarkCyan, new RectangleF
            {
                X      = (float)MyBot.X - botsize / 2,
                Y      = (float)MyBot.Y - botsize / 2,
                Height = botsize,
                Width  = botsize
            });
        }