void OnTriggerEnter2D(Collider2D other) { if (!debounce && (other.tag != "Enemy" && other.isTrigger == false) || other.tag == "Player") { ArrowBehavior exp = Instantiate(explosion, transform); exp.SetBehavior(0, transform.position, 0, 0); debounce = true; Destroy(gameObject); } }
void Passive() { shotTarget = passiveTimer; if (shotTimer > shotTarget && shotTarget > 0) { target = new Vector2(transform.position.x + 1 * -(transform.right.normalized.x), transform.position.y + 1); ArrowBehavior arroz = Instantiate(arrow); arroz.SetBehavior(damage, transform.position, target, target - new Vector2(transform.position.x, transform.position.y), arrowSpeed); shotTimer = 0; } }
void Aggressive() { shotTarget = aggroTimer; if (shotTimer > shotTarget && shotTarget > 0) //shoot at the player every two seconds //determine player position { float playerX = GetPlayer().transform.position.x; float playerY = GetPlayer().transform.position.y; //make target mean something GenerateTarget(playerX, playerY); //raycast to target; if open air, shoot RaycastHit2D line = Physics2D.Linecast(transform.position, target, mask); if (!line) { ArrowBehavior arroz = Instantiate(arrow); arroz.SetBehavior(damage, transform.position, target, target - new Vector2(transform.position.x, transform.position.y), arrowSpeed); shotTimer = 0; } } }
void ShootArrow(float angle) { ArrowBehavior currentShot = Instantiate(shot); currentShot.SetBehavior(30, transform.position, angle, 5f); }