Beispiel #1
0
 public void OnPathComplete(Path p)
 {
     if (!p.error)
     {
         path            = p;
         currentWaypoint = 0;
         _state          = PyramidState.MOVING;
     }
 }
Beispiel #2
0
    private void Shoot()
    {
        // Gradually Stop rb in order to shoot
        _timeoutCounter += Time.deltaTime;
        if (_timeoutCounter < nextActionWaitSeconds)
        {
            rb.velocity = rb.velocity * 0.9f;
            return;
        }

        _timeoutCounter = 0;
        Debug.Log("Pyramid shot a beam!");
        _state = PyramidState.SEARCHING;
    }
Beispiel #3
0
    private void MoveToTarget()
    {
        //TODO: Always look at player

        // Check if the move timeout was reached
        _timeoutCounter += Time.deltaTime;
        if (_timeoutCounter > nextPathMoveTimeoutSeconds)
        {
            _timeoutCounter = 0f;
            _state          = PyramidState.SHOOTING;
            return;
        }

        // If there's no path, search again
        if (path == null)
        {
            _state = PyramidState.SEARCHING;
            return;
        }

        // Check if path was reached
        if (currentWaypoint >= path.vectorPath.Count)
        {
            path            = null;
            _timeoutCounter = 0f;
            _state          = PyramidState.SHOOTING;
            return;
        }


        //Direction to the next waypoint
        Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;

        dir *= speed * Time.fixedDeltaTime;

        //Move the AI
        rb.AddForce(dir, fMode);

        float dist = Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]);

        if (dist < nextWaypointDistance)
        {
            currentWaypoint++;
            return;
        }
    }
Beispiel #4
0
 private void Start()
 {
     seeker = GetComponent <Seeker>();
     rb     = GetComponent <Rigidbody2D>();
     _state = PyramidState.SEARCHING;
 }