public static void Attack(ref IPlayer enemy, ref IBotControl botControl, ref float attackIntervalTimer, Transform transform)
    {
        // not exportable.
        var canAttack = enemy != null && botControl != null && botControl.CanAttack();

        if (canAttack && attackIntervalTimer <= 0)
        {
            transform.LookAt(enemy.transform);
            botControl.Attack();
        }
    }
Exemple #2
0
 private void Serialize()
 {
     if (directionGuide != null)
     {
         directionGuide.localPosition = new Vector3(0, directionGuideElevation, roamRange);
     }
     self       = GetComponent <IPlayer>();
     agent      = GetComponent <NavMeshAgent>();
     collider   = GetComponent <Collider>();
     botControl = GetComponent <IBotControl>();
 }
Exemple #3
0
 /// <summary>
 /// Робота бота в Mode.Default
 /// </summary>
 /// <param name="token">Источник признака отмены</param>
 private bool botWork(CancellationToken token)
 {
     if (bc == null)
     {
         bc = new KeyboardTimerBotControl(cv.ViewPort);
     }
     Task.Run(() =>
     {
         POIData defPOI = new POIData(new Point(-1, -1), -1);
         while (true)
         {
             sw.Restart();
             if (token.IsCancellationRequested)
             {
                 if (bc != null)
                 {
                     bc.release();
                 }
                 break;
             }
             var obj = cv.detectObj();
             var com = bc.moveTo(obj);
             if (obj == null)
             {
                 obj = defPOI;
             }
             else
             {
                 obj.command = com;
             }
             sw.Stop();
             obj.fps = 1000 / sw.ElapsedMilliseconds;
             if (onDataReport != null)
             {
                 onDataReport(obj);
             }
         }
     }, token);
     return(true);
 }
Exemple #4
0
 public DiscordControl(IBotControl botControl)
 {
     _botControl = botControl;
     InitializeComponent();
 }