コード例 #1
0
    bool CheckReachedWaypoint()
    {
        //Debug.Log("CheckReachedWaypoint");
        if (waypoints.Count == 0 || activeWaypoint >= waypoints.Count)
        {
            return(true);
        }

        // There should not be any empty waypoints!
        //Assert.AreNotEqual(waypoints[activeWaypoint], null);
        if (waypoints[activeWaypoint] == null)
        {
            return(true);
        }

        Vector3 currentPos  = transform.position;
        Vector3 destination = waypoints[activeWaypoint].transform.position;

        if (GameplayHelper.GetSquaredDistanceBetween(currentPos, destination) < distanceToWaypoint * distanceToWaypoint)
        {
            return(true);
        }

        return(false);
    }
コード例 #2
0
    bool PlayerInAttackRange()
    {
        //Debug.Log("PlayerInAttackRange");
        Assert.AreNotEqual(player, null);

        if (CanSeePlayer())
        {
            return(GameplayHelper.GetSquaredDistanceBetween(lastKnownPlayerPosition, gameObject.transform.position) < attackRange * attackRange);
        }

        return(false);
    }
コード例 #3
0
    void PlayerSpottedEvent(Vector3 _playerPosition)
    {
        if (ignoreAlert)
        {
            return;
        }
        if (GameplayHelper.GetSquaredDistanceBetween(_playerPosition, gameObject.transform.position) > alertDistance * alertDistance)
        {
            return;
        }

        //Debug.Log("PlayerSpottedEvent");
        lastKnownPlayerPosition = _playerPosition;

        // We already see the player.
        if (canSeePlayerPrevious)
        {
            return;
        }

        chaseGiveUpTimer = chaseGiveUpDuration;
        // flowAI.Swap(chaseNodeId, flowAI.currentNode.localId);
        flowAI.Transition(chaseNodeId);
    }