Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 public void Moved()
 {
     if (false)
     {
         if (pointFollow != null && Vector2.Distance(_unit.position, pointFollow.position) > distanceFollow)
         {
             _thisMotor.GoToTarget(pointFollow.position);
         }
         else if (_hitWall)
         {
             _unit.Rotate(new Vector3(0, 0, 1), Random.Range(90f, 180f));
             _hitWall = false;
         }
         else if (!_movedAction && !_rotation)
         {
             RotateState();
         }
         else if (!_movedAction && _rotation)
         {
             _point       = _unit.position;
             _movedAction = true;
         }
         else if (_movedAction && _rotation)
         {
             if (Time.time < _period)
             {
                 _thisMotor.GoToForward(_unit.right);
             }
             else
             {
                 _movedAction = false;
                 _rotation    = false;
                 _gradus      = Random.Range(-180f, 180f);
                 _period      = Random.Range(minDelay, maxDelay) + Time.time;
             }
         }
         _returnMoved = false;
     }
     else if (_returnMoved == false)
     {
         _returnMoved = true;
         float[] coordinatesCenter = getCenterFigure(_thisPoints[0].x, _thisPoints[0].y, _thisPoints[2].x, _thisPoints[2].y, _thisPoints[1].x, _thisPoints[1].y, _thisPoints[3].x, _thisPoints[3].y);
         RotateState(new Vector3(coordinatesCenter[0], coordinatesCenter[1]));
     }
     else if (_returnMoved == true)
     {
         _thisMotor.GoToForward(_unit.right);
     }
 }
Beispiel #2
0
    public void Attack()
    {
        if (DistanceVisible() < distanceDamage)
        {
            StartCoroutine(Attack());
        }
        else
        {
            motorNow.GoToTarget();
        }

        IEnumerator Attack()
        {
            if (attack)
            {
                player?.SetDamage(damage);
                attack = false;
                yield return(new WaitForSeconds(attackFrequency));

                attack = true;
            }
        }
    }