コード例 #1
0
 public static void HumanPlayer(FootballPlayer player)
 {
     if (Globals.keyboard.GetPress("W"))
     {
         player.pos    = player.move(player.pos);
         player.pos    = player.move(player.pos);
         player.moving = true;
     }
     else
     {
         player.moving = false;
     }
     if (Globals.keyboard.GetPress("A"))
     {
         player.AddDirection(-2);
     }
     if (Globals.keyboard.GetPress("S"))
     {
         player.pos = player.move(player.pos);
     }
     if (Globals.keyboard.GetPress("D"))
     {
         player.AddDirection(2);
     }
     if (Globals.keyboard.GetPress("Space"))
     {
         player.Shoot(player);
     }
 }
コード例 #2
0
ファイル: Globals.cs プロジェクト: DavidDorenbos/threading
 public static void AI(FootballPlayer player)
 {
     if (!player.hasBall)
     {
         if (Globals.ball.GetDistance(player.pos) < 200f && player.hadDistance)
         {
             player.direction = Globals.RotateTowards(player.pos, Globals.ball.pos) / (float)Math.PI / 2 * 360;
             player.pos       = player.move(player.pos);
             player.pos       = player.move(player.pos);
         }
         else if (Globals.ball.GetDistance(player.pos) < 100f && !player.hadDistance)
         {
             player.direction = (Globals.RotateTowards(player.pos, Globals.ball.pos) / (float)Math.PI / 2 * 360) + 180;
             player.pos       = player.move(player.pos);
             player.pos       = player.move(player.pos);
         }
         else if (Globals.ball.GetDistance(player.pos) > 200f)
         {
             if (player.GetDistanceFromStart() < 2.0f)
             {
                 player.direction = Globals.RotateTowards(player.pos, Globals.ball.pos) / (float)Math.PI / 2 * 360;
             }
             else
             {
                 player.direction = Globals.RotateTowards(player.pos, player.startLocation) / (float)Math.PI / 2 * 360;
                 player.pos       = player.move(player.pos);
                 player.pos       = player.move(player.pos);
             }
         }
     }
     else
     {
         player.direction = Globals.RotateTowards(player.pos, player.scoreLocation()) / (float)Math.PI / 2 * 360;
         player.Shoot(player);
     }
 }