UpdateGraphs() public method

public UpdateGraphs ( Bounds bounds ) : void
bounds Bounds
return void
Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Monster"))
        {
            Monster collidedMonster = collision.gameObject.GetComponent <Monster>();
            Vector2 pushdirection   = collidedMonster.transform.position - transform.position;
            pushdirection.Normalize();
            collidedMonster.Damage(atkpower, pushdirection);
        }

        if (collision.gameObject.GetComponent <breakableCrate>() != null)
        {
            Destroy(collision.gameObject);
            GetComponent <AudioSource>().PlayOneShot(cratebreak);
            Instantiate(crateexp, collision.transform.position, Quaternion.identity);

            // recalculate bounds when crates break
            // AstarPath astarscript = GameObject.FindGameObjectWithTag("A*").GetComponent<AstarPath>();
            Bounds b = new Bounds();
            b.center = collision.gameObject.GetComponent <BoxCollider2D>().transform.position;
            b.size   = collision.gameObject.GetComponent <BoxCollider2D>().transform.position;
            astarscript.UpdateGraphs(b);
            //GameObject.FindGameObjectWithTag("A*").GetComponent<AstarPath>().UpdateGraphs(b);
        }
    }
Ejemplo n.º 2
0
    public void UpdateSection(Bounds bounds)
    {
        var guo = new GraphUpdateObject(bounds)
        {
            updatePhysics = true
        };

        map.UpdateGraphs(guo);
    }
Ejemplo n.º 3
0
    public virtual void UpdatePathfinding()
    {
        AstarPath astar = AstarPath.active;

        // Expand bounds to include room connections;
        var fullBounds = new Bounds(bounds.center, bounds.size);

        fullBounds.Expand(dungeon.roomSpacing);
        astar.UpdateGraphs(fullBounds);
    }
Ejemplo n.º 4
0
        public void UpdateAstarPath(Vector2Int position, string pathTag)
        {
            var graphupdate = new GraphUpdateObject
            {
                setTag    = TagFromString(pathTag),
                bounds    = new Bounds(new Vector3(position.x, position.y, 0), Vector3.one),
                modifyTag = true
            };

            AStarPath.UpdateGraphs(graphupdate);
        }
Ejemplo n.º 5
0
    void generateRoom()
    {
        // 7x7 room
        float botleft_x = origin.x - 4f;
        float botleft_y = origin.y - 4f;
        float offset    = 3f;

        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                if (i == 0 || i == 8 || j == 0 || j == 8)
                {
                    // summon arena of crates
                    Instantiate(crate, new Vector3(botleft_x + i, botleft_y + j), Quaternion.identity);
                }
            }
        }


        Instantiate(slow, new Vector3(origin.x, origin.y), Quaternion.identity); // slow

        // summon monsters
        Instantiate(seek, new Vector3(origin.x - offset, origin.y - offset), Quaternion.identity);
        Instantiate(melee, new Vector3(origin.x - offset, origin.y + offset), Quaternion.identity);
        Instantiate(melee, new Vector3(origin.x + offset, origin.y - offset), Quaternion.identity);
        Instantiate(sprint, new Vector3(origin.x + offset, origin.y + offset), Quaternion.identity);
        Instantiate(ranged, new Vector3(origin.x + offset, origin.y), Quaternion.identity);
        Instantiate(ranged, new Vector3(origin.x - offset, origin.y), Quaternion.identity);



        AstarPath astarscript = GameObject.FindGameObjectWithTag("A*").GetComponentInChildren <AstarPath>();

        astarscript = FindObjectOfType <AstarPath>();
        Bounds bound = new Bounds();

        bound.center = origin;
        bound.size   = new Vector3(10f, 10f);
        astarscript.UpdateGraphs(bound);

        //GameObject.FindGameObjectWithTag("A*").GetComponentInChildren<AstarPath>().UpdateGraphs(bound);
    }
        protected virtual void OnDoorStateChanged(Door door, bool isOpen)
        {
            Bounds            bounds = UnityUtil.CalculateObjectBounds(door.gameObject, false, true);
            GraphUpdateObject guo    = new GraphUpdateObject(bounds);
            int tag = isOpen ? OpenDoorTag : ClosedDoorTag;

            // Invalid tag ID
            if (tag > 31)
            {
                Debug.LogError("Invalid tag ID. Tags must be < 32");
                return;
            }

            guo.modifyTag     = true;
            guo.setTag        = tag;
            guo.updatePhysics = false;

            PathFinder.UpdateGraphs(guo);
        }
Ejemplo n.º 7
0
    private IEnumerator UpdateGraphsNextFrame(Vector2 position)
    {
        yield return(null);

        astarPath.UpdateGraphs(new Bounds(position, graphUpdateBoundSize));
    }
Ejemplo n.º 8
0
 private void UpdateGraph(Vector3Int origin)
 {
     UnityEngine.Debug.Log("UpdateGraph at " + origin);
     _pathfinder.UpdateGraphs(new Bounds(origin, new Vector3Int(10, 10, 1)));
 }
Ejemplo n.º 9
0
	// Use this for initialization
	void Start ()
	{


		// initialize lists
		checkpoint_Transforms = new List<Transform> ();
		checkpoint_Objects = new List<GameObject> ();
		patrol_Transforms = new List<Transform> ();
		patrol_Scripts = new List<Patrol> ();
		score_Texts = new List<GUIText> ();
		remaining_Texts = new List<GUIText> ();

		// build the level
		level_End = false;
		string[][] currentLevel = ReadLevel (LevelFile);
		BuildLevel (currentLevel);
		string[][] currentEntities = ReadLevel (EntityFile);
		BuildEntities (currentEntities);

		// select our checkpoints
		ChooseCheckpoints ();
		Debug.Log (checkpoint_Objects.Count);

		// get components and objects

		compass = player_Transform.Find ("camera_main/compass").GetComponent<Compass> ();
		audio_Controller_Script = AudioControllerObject.GetComponent<AudioController> ();
		audio_Controller_Script.FadeSpeed = FadeSpeed;
		scene_Fader = FindObjectOfType<GUITexture> ().GetComponent<SceneFadeInOut> ();
		scene_Fader.FadeSpeed = FadeSpeed;

		// initialize the pathfinder

		a_Star_Path = Astar.GetComponent<AstarPath> ();
		a_Star_Path.UpdateGraphs (new Pathfinding.GraphUpdateObject ());
		a_Star_Path.Scan ();

		// build the patrollers - this needs to be done after the pathfinder is up

		string[][] currentPatrols = ReadLevel (PatrolFile);
		BuildPatrols (currentPatrols);
		foreach (Patrol current_patrol in patrol_Scripts) {
			current_patrol.FadeSpeed = FadeSpeed;
		}

		// set the first checkpoint
		next_Checkpoint = 0;
		checkpoint_Objects [next_Checkpoint].SetActive (true);

		// setup GUI

		foreach (GUIText text in FindObjectsOfType<GUIText>()) {
			if (text.name.Contains ("text_score"))
				score_Texts.Add (text);
			if (text.name.Contains ("text_remaining"))
				remaining_Texts.Add (text);
		}

		RenderText ();
	}