// Use this for initialization
	IEnumerator Start () {
		scoreTracker = GameObject.Find("ScoreTracker").GetComponent<ScoreTracker>();
		AdjustForDifficulty();
		beatActiveParticles = beatActive.particleSystem;
		beatActiveParticles2 = beatActive2.particleSystem;
		player = GameObject.Find ("OVRCameraRig");
		yield return new WaitForSeconds(timeToExplode / 2f);
		dontShow = false;
		yield return new WaitForSeconds((timeToExplode / 2f) - .1f);
		CheckForNextBeat();
		yield return new WaitForSeconds(.1f);
		finished = true;
		gameObject.layer = 2;
		Global.totalBeats ++;
		if(hasBeenHit > 0f || Global.difficulty == 0) {
			/*
			int numPartles = 2;
			for(int i = 0; i < numPartles; i++) {
				explosionParticles[i].particleSystem.Play();
			}*/
			Global.beatsHit ++;
			GameObject dasExplosion = (GameObject)Instantiate(successResidualParticles, transform.position, Quaternion.identity);
			dasExplosion.transform.LookAt(explosionTarget);
			float lifespan = timeFromLastBeat/(float)Global.audioClip.frequency;
			if(lifespan > 2.5f) {
				lifespan = 2.5f;
			}
			dasExplosion.particleSystem.startLifetime = lifespan * 1.1f;
			dasExplosion.particleSystem.Emit(50 + (int)(magnitude * 75f * lifespan));
			lifespan = 3f - lifespan;
			dasExplosion.particleSystem.startSpeed = lifespan * 12f;
			scoreTracker.AddPoints(transform.position);
			
			
			dasExplosion = (GameObject)Instantiate(successParticlesSmall, transform.position, Quaternion.identity);
			dasExplosion.transform.LookAt(explosionTarget);
			lifespan = timeFromLastBeat/(float)Global.audioClip.frequency;
			if(lifespan > 2.5f) {
				lifespan = 2.5f;
			}
			dasExplosion.particleSystem.startLifetime = lifespan * 1.43f;
			dasExplosion.particleSystem.Emit(50 + (int)(magnitude * 65f * lifespan));
			lifespan = 3f - lifespan;
			dasExplosion.particleSystem.startSpeed = lifespan * 12f;
			scoreTracker.AddPoints(transform.position);
		} else {
			Instantiate(failResidualParticles, transform.position, Quaternion.identity);
			AudioModifier audioModifier = GameObject.Find ("VisualMaster").GetComponent<AudioModifier>();
			audioModifier.Damage();
			scoreTracker.Hit();
		}
	}
Exemple #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <CharacterMovement>() != null)
     {
         scoreTracker.AddPoints(1);
         soundPlayer.PlayRandomCollectSound();
         Disappear();
     }
     else if (other.GetComponentInParent <CollectAllPower>() != null)
     {
         scoreTracker.AddPoints(1);
         // sound played by collectallpower script
         Disappear();
     }
 }
Exemple #3
0
 //Used to handle when supergirl jumps on the monsters head.
 public virtual void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "SupergirlFoot")
     {
         GetComponent <AudioSource>().Play();
         //Keeps the monster from moving on death.
         pos1 = transform.position;
         transform.position = pos1;
         moveSpeed          = 0;       //Stops the monster from moving when it dies
         myAnimator.SetTrigger("die"); //Triggers the animation for death
         ScoreTracker.AddPoints(5);
         if (transform.localScale.x < 0)
         {
             transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
         }
         GetComponent <Collider2D>().enabled = false; //Turns off collisions so the player can't collide during the death animation.
         StartCoroutine(Wait());
     }
     if (other.tag == "Laser")
     {
         GetComponent <AudioSource>().Play();
         //Keeps the monster from moving on death.
         pos1 = transform.position;
         transform.position = pos1;
         moveSpeed          = 0;       //Stops the monster from moving when it dies
         myAnimator.SetTrigger("die"); //Triggers the animation for death
         ScoreTracker.AddPoints(5);
         if (transform.localScale.x < 0)
         {
             transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
         }
         GetComponent <Collider2D>().enabled = false; //Turns off collisions so the player can't collide during the death animation.
         StartCoroutine(Wait());
     }
 }
Exemple #4
0
 void Update()
 {
     while (Time.time > timeOfNextReward)
     {
         timeOfNextReward += interval;
         ScoreTracker.AddPoints(pointAmount);
     }
 }
    private void OnTriggerEnter2D(Collider2D other)
    {
        AudioSource.PlayClipAtPoint(popSound, transform.position);

        ScoreTracker.AddPoints(points);

        Destroy(gameObject);
    }
Exemple #6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Player> () == null)
        {
            return;
        }
        ScoreTracker.AddPoints(pointsToAdd);

        gameObject.GetComponent <AudioSource> ().Play();
        gameObject.GetComponent <PolygonCollider2D>().enabled = false;
        gameObject.GetComponent <SpriteRenderer> ().enabled   = false;

        Destroy(gameObject, 1f);
    }
Exemple #7
0
    private void StartDeath()
    {
        moveSpeed = 0;                               //Stops the monster from moving when it dies
        myAnimator.SetTrigger("die");                //Triggers the animation for death
        GetComponent <Collider2D>().enabled = false; //Turns off collisions so the player can't collide during the death animation.

        ScoreTracker.AddPoints(5);

        myRigidBody.gravityScale = 0; //Turns off gravity so that the body will not fall through the floor.
        if (transform.localScale.x < 0)
        {
            transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
        }
        StartCoroutine(Wait());
    }
Exemple #8
0
    //Trigger collider
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <ObjectLauncher>())
        {
            if (other.GetComponent <ScorePointsContainer>())
            {
                ScoreTracker.AddPoints(other.GetComponent <ScorePointsContainer>().UseContainer());
            }
            other.GetComponent <ObjectLauncher>().Launch(stateTracker.CurrentPlayerState);
        }

        if (other.GetComponent <FinishTrigger>())
        {
            win?.Invoke();
        }
    }
Exemple #9
0
 protected void BeginDeath()
 {
     if (gameObject.tag != "Player" && transform.localScale.x < 0)
     {
         transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
     }
     moveSpeed = 0;                //Stops the monster from moving when it dies
     myAnimator.SetTrigger("die"); //Triggers the animation for death
     if (gameObject.tag != "Player")
     {
         ScoreTracker.AddPoints(5);
     }
     transform.rotation = Quaternion.identity;
     GetComponent <BoxCollider2D>().enabled = false;
     myRigidBody.gravityScale = 0;
     StartCoroutine(onComplete());
 }
Exemple #10
0
 public void AddPoints()
 {
     scoreTrackerSc.AddPoints();
 }