public void addObstacle(GameObject obst)
    {
        ObstManager obstManager = obst.GetComponent <ObstManager>();

        obstManager.setIsActive(true);

        //if obstacle has not yet been asigned an index
        if (obstManager.getIndex() == -1)
        {
            Obstacles.Add(obstManager);
            obstManager.setIndex(heighestIndex);
            heighestIndex++;
            numOfObstacles++;
            gridScript.addObstPath();
        }
        else
        {
            Obstacles[obstManager.getIndex()] = obstManager;
        }

        if (managerScipt.isLocalAvoidance)
        {
            obstManager.GetComponent <PredictPath>().enabled     = false;
            obstManager.GetComponent <GetCoveredNodes>().enabled = false;
        }
    }
예제 #2
0
 // Start is called before the first frame update
 void Start()
 {
     //targetPoint = new Vector3(-5, transform.position.y, 0.5f);
     obstManagerScript = GetComponent <ObstManager>();
     speed             = obstManagerScript.speed;
     returnPoint       = transform.position;
     currentTarget     = targetPoint;
 }
    public void removeObstacle(GameObject obst)
    {
        ObstManager obstManager = obst.GetComponent <ObstManager>();

        obstManager.setIsActive(false);
        obstManager.cleanPath();
        Obstacles[obstManager.getIndex()] = null;
        numOfObstacles--;
    }
    public void init()
    {
        //set ref
        managerScript            = Ref.getManagerGO().GetComponent <Manager>();
        predictedPathBoxCollider = predictedPathBox.GetComponent <BoxCollider>();
        gridScript        = Ref.getGridScript();
        pathBounds        = predictedPathBox.GetComponent <BoxCollider>();
        obstManagerScript = GetComponent <ObstManager>();
        followPathScript  = managerScript.getActiveAgent().GetComponent <FollowPath>();

        predictedPathBoxXScale = predictedPathBox.transform.localScale.x;
        indexObstList          = obstManagerScript.getIndex();
    }
예제 #5
0
    void Start()
    {
        //set ref
        managerScript = Ref.getManagerGO().GetComponent <Manager>();
        gridScript    = Ref.getGridScript();
        GameObject activeAgent = managerScript.getActiveAgent();

        followPathScript  = activeAgent.GetComponent <FollowPath>();
        agentPropsScript  = activeAgent.GetComponent <AgentProps>();
        boxCollider       = GetComponent <BoxCollider>();
        obstManagerScript = GetComponent <ObstManager>();

        predictAheadTimeFrames = (agentPropsScript.cooperationLenght * 2 + 1);
        getCoveredNodesScript  = GetComponent <GetCoveredNodes>();
        getCoveredNodesScript.setPredictAheadTime(predictAheadTimeFrames);
        getCoveredNodesScript.init();
        lastNPoints = new List <Vector3>();
    }