Beispiel #1
0
 void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.tag == "Player")
     {
         ShakeScript ss = other.gameObject.AddComponent <ShakeScript>();
     }
 }
Beispiel #2
0
    void Update()
    {
        GameObject  clock = GameObject.Find("Timer");
        TimerScript t     = clock.GetComponent <TimerScript>();

        if (t.timer >= t.limit)
        {
            ShakeScript cam = GameObject.FindObjectOfType(typeof(ShakeScript)) as ShakeScript;
            cam.TriggerShake(1);
            gameObject.GetComponent <SpriteRenderer>().enabled = true;
            Vector3    pos = new Vector3(0f, 0f, -5f);
            Quaternion rot = new Quaternion();
            transform.SetPositionAndRotation(pos, rot);
        }

        if (t.timer >= t.limit && Input.GetKeyDown("r"))
        {
            currentScene = SceneManager.GetActiveScene();

            if (currentScene.name != firstScene)
            {
                GameScore gScore = GameObject.FindObjectOfType(typeof(GameScore)) as GameScore;
                gScore.decrementScore();
            }

            RestartGame();
        }
    }
    void Start()
    {
        audioSource = GetComponent <AudioSource>();
        rb          = GetComponent <Rigidbody2D>();
        speed       = Random.Range(3.0f, 8.0f);
        shake       = GameObject.Find("Shake Manager").GetComponent <ShakeScript>();
        shake.CamShake();

        if (Random.Range(0, 100) == 0)
        {
            this.GetComponent <SpriteRenderer>().sprite = secret;
        }
    }
Beispiel #4
0
 public int OnCollisionEnter2D(Collision2D coll)
 {
     if (canTakeDamage && coll.gameObject.tag == "bouncer")
     {
         hp = hp - 1;
         ShakeScript cam = GameObject.FindObjectOfType(typeof(ShakeScript)) as ShakeScript;
         cam.TriggerShake();
         StartCoroutine(damageTimer());
         StartCoroutine(Flasher());
         BouncerSound sound = GameObject.FindObjectOfType(typeof(BouncerSound)) as BouncerSound;
         sound.TriggerSound();
     }
     return(hp);
 }
Beispiel #5
0
 private void Start()
 {
     ShakeCamera = Camera.main.GetComponent <ShakeScript>();
 }
Beispiel #6
0
 void Awake()
 {
     instance = this;
 }