예제 #1
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            Bot pickedbot = null;

            foreach (var bot in MainItems.bots)
            {
                int rxl = bot.Position.X - e.X;
                int rxr = e.X - bot.Position.X;
                int ryu = e.Y - bot.Position.Y;
                int ryd = bot.Position.Y - e.Y;
                if//(((rxl >= 0 && rxl < Bot.size+2) ||(rxr >= 0 && rxr < Bot.size + 2))       )//||
                (((ryu >= 0 && ryu < Bot.size + 2) || (ryd >= 0 && ryd < Bot.size + 2)))
                {
                    pickedbot = bot;
                    break;
                }
            }
            if (pickedbot != null)
            {
                Bot nearestBot = null;
                for (int i = 0; i < 8; i++)
                {
                    nearestBot = ComExec.IsBotOnDirection(pickedbot, (Direction)(i));
                    if (nearestBot != null)
                    {
                        break;
                    }
                }
                if (nearestBot != null)
                {
                    textBox2.Text = $"Position {pickedbot.Position.X}:{pickedbot.Position.Y}; ID:{pickedbot.ID};Nearest bot:{nearestBot.ID}";
                }
                else
                {
                    textBox2.Text = $"Position {pickedbot.Position.X}:{pickedbot.Position.Y}; ID:{pickedbot.ID};Energy:{pickedbot.Energy};Gptr:{pickedbot.Gptr}";
                }
            }
            else
            {
                textBox2.Text = "Pick the bot";
            }
            pickedbot = null;
        }
예제 #2
0
 public void GiveFree()
 {
     for (int i = 0; i < 8; i++)
     {
         Bot tmp = ComExec.IsBotOnDirection(this, (Direction)i);
         if (tmp != null)
         {
             foreach (var bot in MainItems.bots)
             {
                 if (tmp.ID == bot.ID)
                 {
                     bot.Energy  += (this.Energy / 4);
                     this.Energy /= 4;
                     break;
                 }
             }
             break;
         }
     }
 }