Beispiel #1
0
    private void launch()
    {
        kim.gameObject.SetActive(true);
        power *= scale;
        var     rb    = kim.GetComponent <Rigidbody2D>();
        Vector2 force = new Vector2(Mathf.Cos(rotate) * power, Mathf.Sin(rotate) * power);

        rb.AddForce(force);
        Destroy(GameObject.Find("Plane"));
        Camera.main.backgroundColor = new Color(122f / 255f, 200f / 255f, 236f / 255f);
        Camera.main.GetComponent <AudioSource>().clip = newsong;
        Camera.main.GetComponent <AudioSource>().loop = true;
        Camera.main.GetComponent <AudioSource>().Play();
        sun.SetActive(true);
    }
Beispiel #2
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject == kim.gameObject)
     {
         spindex++;
         GetComponent <SpriteRenderer>().sprite = pics[spindex];
         Vector2 vel = kim.GetComponent <Rigidbody2D>().velocity;
         if (vel.y > 0)
         {
             vel.y = vel.y * 1.4f + 2f;
         }
         else
         {
             vel.y = -vel.y * 1.4f + 2f;
         }
         if (vel.y < 7f)
         {
             vel.y = 7f;
         }
         kim.xvel -= 5f;
         kim.GetComponent <Rigidbody2D>().velocity = vel;
         Destroy(GetComponent <BoxCollider2D>());
     }
 }