Example #1
0
 private void OnTriggerEnter2D(Collider2D bullet)
 {
     if (bullet.gameObject.tag == "Bullet")
     {
         if (health > 1)
         {
             health--;
             PlaySound.Damage();
             hitCounter = hitTime;
         }
         else
         {
             PlaySound.NoLoop(breakSnd);
             Instantiate(crystalBreak, transform.position, Quaternion.identity);
             crystalCrack.SetActive(false);
             crystal.SetActive(false);
             GetComponent <PolygonCollider2D>().enabled = false;
             ignite.GetComponent <ParticleSystem>().Play();
             AudioSource litSound = gameObject.AddComponent <AudioSource>();
             litSound.clip         = litSnd;
             litSound.volume       = Game.soundVolume;
             litSound.loop         = false;
             litSound.spatialBlend = 0f;
             litSound.Play();
             puppet.GetComponent <AnimationScript>().enabled = true;
             activated = true;
         }
     }
 }
Example #2
0
 void OnTriggerEnter2D(Collider2D bullet)
 {
     if (bullet.gameObject.tag == "Bullet" && !dead)
     {
         if (health <= 0)
         {
             PlaySound.NoLoop(exploSnd);
             Instantiate(explosionParticles, gameObject.transform.position, gameObject.transform.rotation);
             for (int i = 0; i < puppets.Count; i++)
             {
                 iTween.ScaleTo(puppets[i], iTween.Hash(
                                    "x", 0, "y", 0, "z", 0,
                                    "time", deathTime - 0.1f,
                                    "looptype", iTween.LoopType.none,
                                    "easetype", iTween.EaseType.easeInOutSine
                                    ));
             }
             iTween.ScaleTo(reticle, iTween.Hash(
                                "y", 0f,
                                "time", deathTime - 0.1f,
                                "looptype", iTween.LoopType.none,
                                "easetype", iTween.EaseType.easeInOutSine
                                ));
             GetComponent <Collider2D>().enabled = false;
             Destroy(gameObject, deathTime);
             dead = true;
         }
         else
         {
             PlaySound.Damage();
             health--;
             hitCounter = hitTime;
         }
     }
 }
Example #3
0
 private void OnTriggerEnter2D(Collider2D bullet)
 {
     if (bullet.tag == "Bullet")
     {
         if (health > 1)
         {
             PlaySound.Damage();
             bullet.gameObject.GetComponent <BulletScript>().PoofMe();
             health--;
             hitCounter = hitTime;
         }
         else                 //What do to when out of health...
         {
             Instantiate(explo, transform.position, Quaternion.identity);
             PlaySound.NoLoop(breakSnd); //Play the death sound.
             if (mySize != Size.Small)
             {
                 Vector2    dif    = new Vector2(bullet.gameObject.transform.position.x, bullet.gameObject.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
                 Vector2    bPoint = dif.normalized;
                 GameObject plum1  = Instantiate(nextPhaseObj, transform.position, Quaternion.identity) as GameObject;
                 GameObject plum2  = Instantiate(nextPhaseObj, transform.position, Quaternion.identity) as GameObject;
                 plum1.transform.parent = Game.wardenPurpleCrystalHolder.transform;
                 plum2.transform.parent = Game.wardenPurpleCrystalHolder.transform;
                 Vector2 sqForce = new Vector2(bPoint.y * nextFormSpeed, bPoint.x * nextFormSpeed);
                 plum1.GetComponent <Rigidbody2D>().velocity = sqForce;
                 plum2.GetComponent <Rigidbody2D>().velocity = -sqForce;
                 Destroy(gameObject);
             }
             else     //If it is the final plum, don't make plums and just make the final plopplet.
             {
                 Destroy(gameObject);
             }
         }
     }
 }
    void OnTriggerEnter2D(Collider2D playerBullet)
    {
        if (playerBullet.gameObject.tag == "Bullet")
        {
            playerBullet.gameObject.GetComponent <BulletScript>().PoofMe();
            if (health >= 1)
            {
                hitCounter = hitTime;
                PlaySound.Damage();
                health--;
            }
            else
            {
                if (!madeCoins)
                {
                    for (int i = 0; i < moneys; i++)
                    {
                        Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                        Instantiate(coin, transform.position, rot);
                    }
                    madeCoins = true;
                }
                deathParticles.GetComponent <ParticleSystem>().Play();
                p = Phase.Death;
                iTween.ScaleTo(secondGuns, iTween.Hash("x", 0f, "y", 0f, "z", 1f, "time", 2f, "easetype", iTween.EaseType.easeInOutSine, "looptype", iTween.LoopType.none));
                dead = true;
            }
        }

        if (playerBullet.gameObject.tag == "Player Laser" && p == Phase.PhaseTwo)
        {
            health = 0;
            if (!madeCoins)
            {
                for (int i = 0; i < moneys; i++)
                {
                    Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                    Instantiate(coin, transform.position, rot);
                }
                madeCoins = true;
            }
            deathParticles.GetComponent <ParticleSystem>().Play();
            p = Phase.Death;
            iTween.ScaleTo(secondGuns, iTween.Hash("x", 0f, "y", 0f, "z", 1f, "time", 2f, "easetype", iTween.EaseType.easeInOutSine, "looptype", iTween.LoopType.none));
            dead = true;
        }
    }
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (crystalHealth < 1)
     {
         Instantiate(crystalExplo, new Vector3(0, 0, 40), Quaternion.identity);
         PlaySound.NoLoop(glassBreakSnd);
         crystalCrack.SetActive(false);
         crystalHolderObj.SetActive(false);
         crystalCollider.enabled = false;
         ph = Phase.BrokeShield;
     }
     else
     {
         PlaySound.Damage();
         crystalHurtCounter = crystalHurtTime;
         crystalHealth--;
     }
 }
Example #6
0
    //Getting hit by a bullet!
    void OnTriggerEnter2D(Collider2D playerBullet)
    {
        if (playerBullet.gameObject.tag == "Bullet")
        {
            playerBullet.gameObject.GetComponent <BulletScript>().PoofMe();
            if (health >= 1)
            {
                PlaySound.Damage();
                health--;
                hitCounter = hitTime;
            }
            else
            {
                Die();
            }
        }

        if (playerBullet.gameObject.tag == "Player Laser")
        {
            switch (p)
            {
            case Phase.Phase1:
                GoPhaseTwo();
                break;

            case Phase.Phase2:
                health = 149;
                p      = Phase.Transition1;
                break;

            case Phase.Phase3:
                health = 50;
                break;

            case Phase.Phase4:
                Die();
                break;
            }
        }
    }
Example #7
0
    void OnTriggerEnter2D(Collider2D playerBullet)
    {
        if (playerBullet.gameObject.tag == "Bullet")
        {
            playerBullet.gameObject.GetComponent <BulletScript>().PoofMe();
            if (health >= 1)
            {
                PlaySound.Damage();
                health--;
                hurtCounter = hurtTime;
            }
            else
            {
                if (!madeCoins)
                {
                    for (int i = 0; i < moneys; i++)
                    {
                        Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                        Instantiate(coin, transform.position, rot);
                    }

                    for (int j = 0; j < walls.Length; j++)
                    {
                        iTween.ScaleTo(walls[j], iTween.Hash(
                                           "y", 0f, "z", 0f,
                                           "time", 1f,
                                           "delay", 1f,
                                           "easetype", iTween.EaseType.linear,
                                           "looptype", iTween.LoopType.none
                                           ));
                    }

                    madeCoins = true;
                }
                dead = true;
            }
        }

        if (playerBullet.gameObject.tag == "Player Laser")
        {
            health = 0;
            if (!madeCoins)
            {
                for (int i = 0; i < moneys; i++)
                {
                    Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                    Instantiate(coin, transform.position, rot);
                }

                for (int j = 0; j < walls.Length; j++)
                {
                    iTween.ScaleTo(walls[j], iTween.Hash(
                                       "y", 0f, "z", 0f,
                                       "time", 1f,
                                       "delay", 1f,
                                       "easetype", iTween.EaseType.linear,
                                       "looptype", iTween.LoopType.none
                                       ));
                }
                madeCoins = true;
            }
            dead = true;
        }
    }