示例#1
0
    public void init()
    {
        //set ref
        GameObject agent     = Ref.getActiveAgent();
        GameObject managerGO = Ref.getManagerGO();
        GameObject plane     = Ref.getPlane();

        managerScript    = managerGO.GetComponent <Manager>();
        findPathScript   = agent.GetComponent <FindPath>();
        followPathScript = agent.GetComponent <FollowPath>();
        agentPropsScript = agent.GetComponent <AgentProps>();

        visObstManagerScript = agent.GetComponent <VisibleObstManager>();

        nodeDiameter = nodeRadius * 2;

        if (levelTxt != null)
        {
            lines = levelTxt.text.Split('\n');
            string firstLine = lines[0];
            gridWorldSize.x = int.Parse(firstLine.Split(' ')[0]);
            gridWorldSize.y = int.Parse(firstLine.Split(' ')[1]);
        }
        GridSizeX = Mathf.RoundToInt(gridWorldSize.x / nodeDiameter);
        GridSizeY = Mathf.RoundToInt(gridWorldSize.y / nodeDiameter);
        GridSizeZ = agentPropsScript.cooperationLenght * 2 + 1;

        plane.transform.localScale = new Vector3(GridSizeX / 10f, 1, GridSizeY / 10f);
        worldBottomLeft            = transform.position - Vector3.right * gridWorldSize.x / 2 - Vector3.forward * gridWorldSize.y / 2;

        CreateGrid();
    }
示例#2
0
    private void Start()
    {
        agent = transform.parent.gameObject;
        findPathStaticScript = agent.GetComponent <FindPathStatic>();
        agentProps           = agent.GetComponent <AgentProps>();
        Vector3 dir = transform.TransformDirection(Vector3.forward);

        followPathScript = agent.GetComponent <FollowPath>();

        //all dirs
        for (int i = 0; i < 8; i++)
        {
            dirs[i] = Quaternion.Euler(0, 45 * i, 0) * dir;
        }
    }
    public void init()
    {
        //set ref
        agentPropsScript = GetComponent <AgentProps>();
        GameObject managerGO = Ref.getManagerGO();

        managerScript = managerGO.GetComponent <Manager>();

        followPathScript = GetComponent <FollowPath>();
        gridScript       = Ref.getGridScript();
        grid             = gridScript.getGrid();

        windowLenght = agentPropsScript.cooperationLenght * 2;
        float agentSpeed = agentPropsScript.getSpeed();
    }
    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>();
    }
    void Start()
    {
        managerScript            = Ref.getManagerGO().GetComponent <Manager>();
        gridScript               = Ref.getGridScript();
        visibleObstManagerScript = GetComponent <VisibleObstManager>();

        agentPropsScript = GetComponent <AgentProps>();
        saveInitalGrid();
        agent = transform;

        spatialAStarScript = GetComponent <SpatialAStar>();
        spatialAStarScript.init(grid);
        managerScript.increaseFrameCount();

        path = spatialAStarScript.FindPathSpatial(agent.position, target.position, true, null);

        followPathScript = agent.GetComponent <FollowPath>();
        followPathScript.init();
        followPathScript.setNewPath(path);
    }
示例#6
0
 public static IEnumerable <string> AgentPaths(string path = null) => AgentProps
 .Select(p => path == null ? p : $"{path}.{p}");