Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     health = Random.Range(healthrange.x, healthrange.y);
     birb   = birdState.neutral;
     if (direction != 1)
     {
         gameObject.transform.rotation = Quaternion.Euler(0, -180, 0);
     }
     speed = Random.Range(speed * .9f, speed * 1.3f);
     rb    = GetComponent <Rigidbody2D>();
 }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player" && Random.Range(1f, 10f) < 4 && birb == birdState.neutral)
        {
            speed = 3;

            if (birb != birdState.chasing)
            {
                birb = birdState.chasing;
                Vector2 dif = direction == 1 ? transform.position - other.transform.position :  other.transform.position - transform.position;
                DiveAngle          = Mathf.Atan2(dif.y, dif.x);
                DiveAngle         *= Mathf.Rad2Deg;
                DiveAngle         += 180;
                transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, direction * DiveAngle);
            }
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (direction == 1)
        {
            if (transform.position.x > end_range)
            {
                Destroy(gameObject);
            }
        }
        else
        {
            if (transform.position.x < end_range)
            {
                Destroy(gameObject);
            }
        }
        if (birb == birdState.chasing && transform.position.y <= 4.8)
        {
            transform.rotation = Quaternion.Euler(0f, transform.rotation.eulerAngles.y, -1 * transform.rotation.eulerAngles.z);
            birb = birdState.leaving;
        }

        rb.MovePosition(transform.position + (transform.right) * Time.deltaTime * speed);
    }
Exemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     nowState = birdState.Start;
     rb       = bird.GetComponent <Rigidbody2D>();
 }