Beispiel #1
0
    private void Awake()
    {
        graph = GetComponent <NavGraphPlatformer>();
        if (graph == null)
        {
            Debug.Log("graph is null");
        }
        GameObject[] terrainGameObjects = GameObject.FindGameObjectsWithTag("Terrain");
        allTerrains = new List <TerrainFloorNodeContainer>();

        foreach (GameObject t in terrainGameObjects)
        {
            TerrainFloorNodeContainer temp = t.GetComponent <TerrainFloorNodeContainer>();
            if (temp != null)
            {
                allTerrains.Add(temp);
            }
        }

        ///////////////////////////////////////////////////////////////////////

        actionNodePQ = new SimplePriorityQueue <GameObject, float>();

        allNodeGameObjects = GameObject.FindGameObjectsWithTag("Node");


        sortedActionNodeGameObjects = new List <GameObject>();

        sortedActionNodeXPositions = new List <float>();

        foreach (GameObject nodeGameObject in allNodeGameObjects)
        {
            ActionNode actionNode = nodeGameObject.GetComponent <ActionNode>();
            if (actionNode != null)
            {
                actionNodePQ.Enqueue(nodeGameObject, nodeGameObject.transform.position.x);
            }
        }


        while (actionNodePQ.Count > 0)
        {
            sortedActionNodeGameObjects.Add(actionNodePQ.First);
            sortedActionNodeXPositions.Add(actionNodePQ.Dequeue().transform.position.x);
        }
    }
    //public GameObject chit;

    //public GameObject JumpNodeContainer;

    //public GroundedEntityAI_PathOptimization pathOptimization;

    private void Awake()
    {
        graph                = GameObject.FindGameObjectWithTag("Graph").GetComponent <NavGraphPlatformer>();
        groundedEntity       = GetComponent <DixieController>();
        navFSM               = new StateMachine <GroundedEntityAI>(this);
        messagePriorityQueue = new SimplePriorityQueue <Message, int>();
        navFSM.ChangeState(new DoNothing());

        navFSM.previousState = new DoNothing();


        StartCoroutine(UpdatePath());

        timeBetweenSearches += Random.Range(0, .1f);
        //pathOptimization = GameObject.FindGameObjectWithTag("Graph").GetComponent<GroundedEntityAI_PathOptimization>();

        //pathOptimization.QueueAddDixie(this);
    }
    protected override void Awake()
    {
        base.Awake();
        characterDimensions = GetComponent <Collider2D>().bounds.size;
        weaponDimensions    = meleeStrikePrefab.GetComponent <Collider2D>().bounds.size;

        halfSquareRoot2 = Mathf.Sqrt(2) / 2;

        graph        = GameObject.FindGameObjectWithTag("Graph").GetComponent <NavGraphPlatformer>();
        graph.player = this;

        CameraFollow mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>();

        if (mainCam != null)
        {
            mainCam.target = GetComponent <Controller2D>();
        }
    }
Beispiel #4
0
    private void Awake()
    {
        player = GetComponent <PlayerController>();

        graph = GameObject.FindGameObjectWithTag("Graph").GetComponent <NavGraphPlatformer>();
    }