void Start() { pf2 = GetComponent <Pathfinding2D> (); dead = false; turnDone = false; isPathCalculated = false; }
private IEnumerator MoveCooldown(Vector3 target) { Moving = true; /*A forma mais eficiente é rodar isso a partir da posicao do flash*/ Vector3 myPos = transform.position; List <Vector3> path = new Pathfinding2D(ground).A_Star(myPos, target); foreach (Vector3 NextPos in path) { if (player.transform.position != target) { path = new Pathfinding2D(ground).A_Star(myPos, target); } else { if (!flash.ilumina) { anim.SetBool("andando", true); Vector3 movVet = NextPos - transform.position; if (movVet.x > 0) { anim.SetFloat("horizontal", 1.0f); } if (movVet.x < 0) { anim.SetFloat("horizontal", -1.0f); } if (movVet.x == 0) { anim.SetFloat("horizontal", 0.0f); } if (movVet.y > 0) { anim.SetFloat("vertical", 1.0f); } if (movVet.y < 0) { anim.SetFloat("vertical", -1.0f); } if (movVet.y == 0) { anim.SetFloat("vertical", 0.0f); } transform.position = NextPos; //Move para a direção alvo. -A ms.PlaySound(Vector3.Distance(transform.position, player.transform.position)); yield return(new WaitForSeconds(Speed)); } else { anim.SetBool("andando", false); } } } Moving = false; }
void Start() { nextPosition = transform.position; move = GetComponent <AIMove>(); data = GetComponent <PlayerData>(); pathfinding = GetComponent <Pathfinding2D>(); //tiles = MapController.Instance.Tiles; }
public void HasPathToCenter() { Vector3 endPos; //make sure we're not on a disallowed piece, we want to be able to find a valid path do { float randAngle = Random.Range(0f, 2 * Mathf.PI); endPos = this.transform.position + 10f * new Vector3(Mathf.Cos(randAngle), Mathf.Sin(randAngle)); } while (IsWithinDisallowedObject(endPos)); Pathfinding2D finder = this.GetComponent <Pathfinding2D>(); finder.FindPath(this.transform.position, endPos, true); //asynchronous, need to wait for message... }
void Start() { isKiting = false; kiteCW = false; slowed = false; slow_duration = 0f; SearchDelay = 1.0f; nearest = null; body = GetComponent<Rigidbody2D>(); Srenderer = GetComponent<SpriteRenderer>(); timer = rate; pf = GetComponent<Pathfinding2D> (); timeTillDestroy = 0.5f; infected = false; }
void Start() { isKiting = false; kiteCW = false; slowed = false; slow_duration = 0f; SearchDelay = 1.0f; nearest = null; body = GetComponent <Rigidbody2D>(); Srenderer = GetComponent <SpriteRenderer>(); timer = rate; pf = GetComponent <Pathfinding2D> (); timeTillDestroy = 0.5f; infected = false; }