Пример #1
0
    //Writing out the text.
    IEnumerator TypeText()
    {
        foreach (char letter in text.ToCharArray())
        {
            yield return(new WaitForSeconds(letterPause));

            textBeingWritten += letter;

            if (letter != ' ')
            {
                if (!Game.tootMode)
                {
                    PlaySound.NoLoop(snd);
                }
            }

            if (text != null)
            {
                //Text should equal the text being written out in the coroutine.
                textObj.GetComponent <TextMesh>().text = textBeingWritten;
            }

            yield return(0);

            yield return(new WaitForSeconds(letterPause));
        }
    }
Пример #2
0
    public void Refund()
    {
        //This unlocks the "First Refund." Achievement.
        Game.CheckAchievements(22);

        //Calculate how much money needs to be returned.
        int moneyToReturn = MoneySpent();

        //..give the money back...
        Game.coins = Game.coins + moneyToReturn;

        //...reset all the ranks...
        Game.healthRank     = 0;
        Game.shotSpeedRank  = 0;
        Game.speedRank      = 0;
        Game.shotSplitRank  = 0;
        Game.ownsFloppyDisk = false;

        //Here we make the coin spurt and color it, etc.
        Quaternion             rot = Quaternion.Euler(-90, 0, 0);
        GameObject             obj = Instantiate(coinSpurt, new Vector3(20, -23.5f, 0f), rot) as GameObject;
        ParticleSystemRenderer rr  = obj.GetComponent <ParticleSystemRenderer>();

        rr.material.color = new Color(Game.frontColor.r, Game.frontColor.g, Game.frontColor.b, 0.333f);
        PlaySound.NoLoop(cashSnd);

        //...and save the game.
        Game.SaveGame();
    }
Пример #3
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;
         }
     }
 }
Пример #4
0
    void Shoot()
    {
        if (shootCounter <= 0 && startCounter <= 0.65f)
        {
            Game.newShotCount++;
            PlaySound.NoLoop(shoot);
            //How many bullets and where they come from based on your shot split rank.
            switch (Game.shotSplitRank)
            {
            case 0:
                GameObject bulletInst = Instantiate(bullet, p0.transform.position, p0.transform.rotation) as GameObject;
                bulletInst.transform.parent = Game.bulletHolder.transform;
                break;

            case 1:
                GameObject bulletInst1 = Instantiate(bullet, p1.transform.position, p1.transform.rotation) as GameObject;
                GameObject bulletInst2 = Instantiate(bullet, p2.transform.position, p2.transform.rotation) as GameObject;
                bulletInst1.transform.parent = Game.bulletHolder.transform;
                bulletInst2.transform.parent = Game.bulletHolder.transform;
                break;

            case 2:
                GameObject bulletInst3 = Instantiate(bullet, p0.transform.position, p0.transform.rotation) as GameObject;
                GameObject bulletInst4 = Instantiate(bullet, p1.transform.position, p1.transform.rotation) as GameObject;
                GameObject bulletInst5 = Instantiate(bullet, p2.transform.position, p2.transform.rotation) as GameObject;
                bulletInst3.transform.parent = Game.bulletHolder.transform;
                bulletInst4.transform.parent = Game.bulletHolder.transform;
                bulletInst5.transform.parent = Game.bulletHolder.transform;
                break;
            }
            shootCounter = shootTime;
        }
    }
Пример #5
0
 void Update()
 {
     if (Game.playerObj != null)
     {
         float d = Vector2.Distance(new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y), new Vector2(transform.position.x, transform.position.y));
         if (d < 1.7f && !got)
         {
             Destroy(gameObject.GetComponent <iTween>());
             Destroy(shine.GetComponent <iTween>());
             Destroy(puppet);
             iTween.ColorTo(shine, iTween.Hash(
                                "a", 0f,
                                "time", 0.5f,
                                "looptype", iTween.LoopType.none,
                                "easetype", iTween.EaseType.easeInOutSine
                                ));
             iTween.ScaleTo(shine, iTween.Hash(
                                "x", 7f, "y", 7f,
                                "time", 0.5f,
                                "looptype", iTween.LoopType.none,
                                "easetype", iTween.EaseType.easeInOutSine
                                ));
             Destroy(gameObject, 3f);
             PlaySound.NoLoop(cockLol);
             Game.gotGun = true;
             got         = true;
         }
     }
 }
Пример #6
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);
             }
         }
     }
 }
Пример #7
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;
         }
     }
 }
Пример #8
0
    // Update is called once per frame
    void Update()
    {
        if (!got && Game.playerObj != null)
        {
            Vector3 playerPos = Game.playerObj.transform.position;
            EndPointX = playerPos.x;
            EndPointY = playerPos.y;

            BezierTime += Time.deltaTime;

            CurveX = (((1 - BezierTime) * (1 - BezierTime)) * StartPointX) + (2 * BezierTime * (1 - BezierTime) * ControlPointX) + ((BezierTime * BezierTime) * EndPointX);
            CurveY = (((1 - BezierTime) * (1 - BezierTime)) * StartPointY) + (2 * BezierTime * (1 - BezierTime) * ControlPointY) + ((BezierTime * BezierTime) * EndPointY);
            gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, new Vector3(CurveX, CurveY, 0), 7f * Time.deltaTime);

            if (BezierTime >= 1.11f)
            {
                GameObject puppet = transform.Find("puppet").gameObject;
                if (Game.currentLasers < Game.maxLasers)
                {
                    Game.currentLasers++;
                }
                float size = 10f;
                PlaySound.NoLoop(snd);
                iTween.ScaleTo(puppet, new Vector3(size, size / 2f, 1f), 1f);
                iTween.ColorTo(puppet, new Color(puppet.GetComponent <MeshRenderer>().material.color.r, puppet.GetComponent <MeshRenderer>().material.color.g, puppet.GetComponent <MeshRenderer>().material.color.b, 0f), 1f);
                particleObj.GetComponent <ParticleSystem>().Stop();
                got = true;
            }
        }
        else
        {
            Destroy(gameObject, 1f);
        }
    }
Пример #9
0
 //Shooting bullets.
 private void Shoot()
 {
     shootCounter -= Time.deltaTime;
     if (shootCounter <= 0)
     {
         Game.shots++;
         PlaySound.NoLoop(shoot);
         bulletInst = (GameObject)Instantiate(bullet, wepPoint.transform.position, Quaternion.identity);
         bulletInst.transform.parent        = Game.bulletHolder.transform;
         bulletInst.transform.localRotation = puppet.transform.localRotation;
         shootCounter = shootTime;
     }
 }
Пример #10
0
    void ShootLaser()
    {
        PlaySound.NoLoop(laserSnd);
        Vector3    v   = pLaser.transform.rotation.eulerAngles;
        Vector3    v2  = new Vector3(v.x, v.y, v.z + 90);
        Quaternion rot = Quaternion.Euler(v2);

        currentLaser = Instantiate(laserPrefab, pLaser.transform.position, rot) as GameObject;
        currentLaser.transform.parent = Game.bulletHolder.transform;
        Game.currentLasers--;
        laserHoldCounter  = laserHoldTime;
        laserShootCounter = laserShootTime;
    }
Пример #11
0
 private void Die()
 {
     if (!madeCoins)
     {
         Instantiate(attacks[2], Vector3.zero, Quaternion.identity);
         PlaySound.NoLoop(killSound);
         for (int i = 0; i < moneys; i++)
         {
             Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
             Instantiate(coin, transform.position, rot);
         }
         iTween.ScaleTo(wallHolder, iTween.Hash("x", 2, "y", 2, "z", 1, "time", 5f, "easetype", iTween.EaseType.easeInOutSine, "looptype", iTween.LoopType.none));
         Destroy(wallHolder, 5f);
         madeCoins = true;
     }
     p    = Phase.Death;
     dead = true;
 }
Пример #12
0
 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--;
     }
 }
Пример #13
0
    void Update()
    {
        if (gameObject.transform.position == Vector3.zero && activated && !startedHurting)
        {
            warden.BlueHurtMe();
            PlaySound.NoLoop(boomSnd);
            startedHurting = true;
        }

        if (hitCounter > 0)
        {
            hitCounter -= Time.deltaTime;
            targetColor = hurtColor;
        }
        else
        {
            targetColor = notHurtColor;
        }
        crystalCrack.GetComponent <MeshRenderer>().material.color = Color.Lerp(crystalCrack.GetComponent <MeshRenderer>().material.color, targetColor, 5f * Time.deltaTime);
    }
    void OnTriggerEnter2D(Collider2D bullet)
    {
        if (bullet.gameObject.tag == "Bullet")
        {
            if (hp > 1)
            {
                AudioClip a = hitSounds[Random.Range(0, hitSounds.Count)];
                PlaySound.NoLoop(a);
                bullet.gameObject.GetComponent <BulletScript>().PoofMe();
                hp--;
                hitCounter = hitTime;
            }
            else     //Killing the laser.
            //Creating the break explosion.
            {
                GameObject breakInst = (GameObject)Instantiate(breakEffect, transform.position, Quaternion.identity);
                breakInst.transform.parent = Game.bulletHolder.transform;
                Destroy(breakInst, 5f);

                //Playing the break sound.
                AudioClip a = killSounds[Random.Range(0, killSounds.Count)];
                PlaySound.NoLoop(a);

                Destroy(gameObject);
            }
        }

        if (bullet.gameObject.tag == "Player Laser")
        {
            //Creating the break explosion.
            GameObject breakInst = (GameObject)Instantiate(breakEffect, transform.position, Quaternion.identity);
            breakInst.transform.parent = Game.bulletHolder.transform;
            Destroy(breakInst, 5f);

            //Playing the break sound.
            AudioClip a = killSounds[Random.Range(0, killSounds.Count)];
            PlaySound.NoLoop(a);

            Destroy(gameObject);
        }
    }
Пример #15
0
    void OnMouseDown()
    {
        if (!gMan.goingBackToMenu)   //No button is interactible in any way when the going back to menu transition is playing.
        {
            if (!pressed)
            {
                switch (b)
                {
                case Butt.Resume:
                    gMan.PauseMenuAction(0);
                    break;

                case Butt.BackToMenu:
                    gMan.PauseMenuAction(1);
                    break;
                }
                pressed = true;
            }
            PlaySound.NoLoop(snd);
        }
    }
Пример #16
0
    void Update()
    {
        if (gameObject.transform.position == Vector3.zero && activated && !startedHurting)
        {
            v.HurtMe();
            PlaySound.NoLoop(boom);
            startedHurting = true;
        }

        Vector2 pos = new Vector2(transform.position.x, transform.position.y - 0.5f);

        if (first && firstObj != null)
        {
            firstObj.transform.rotation   = Quaternion.identity;
            firstObj.transform.position   = new Vector3(pos.x, pos.y + 0.5f, -1f);
            firstObj.transform.localScale = gameObject.transform.localScale;
        }

        bool hit = Physics2D.OverlapCircle(pos, 2f, bulletLayer);

        if (hit && !activated)
        {
            int coinsToSpawn = 10;
            for (int i = 0; i < coinsToSpawn; i++)
            {
                Quaternion coinRotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                Instantiate(coinObj, transform.position, coinRotation);
            }
            Destroy(firstObj);
            ignite.GetComponent <ParticleSystem>().Play();
            AudioSource litSound = gameObject.AddComponent <AudioSource>();
            litSound.clip         = lit;
            litSound.volume       = Game.soundVolume;
            litSound.loop         = false;
            litSound.spatialBlend = 0f;
            litSound.Play();
            puppet.GetComponent <AnimationScript>().enabled = true;
            activated = true;
        }
    }
Пример #17
0
 private void OnTriggerEnter2D(Collider2D bullet)
 {
     if (bullet.tag == "Bullet")
     {
         if (health > 1)
         {
             AudioClip a = hitSounds[Random.Range(0, hitSounds.Count)];
             PlaySound.NoLoop(a);
             bullet.gameObject.GetComponent <BulletScript>().PoofMe();
             health--;
             hitCounter = hitTime;
         }
         else                                                             //What do to when out of health...
         {
             Instantiate(explo, transform.position, Quaternion.identity); //Spawn the death pop explosion.
             PlaySound.NoLoop(popSound);                                  //Play the death sound.
             if (myPhase != Phase.Final)                                  //If it isn't the final plum, split into to plums!
             {
                 Vector2    bPoint = new Vector2(bullet.gameObject.transform.position.x, bullet.gameObject.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
                 GameObject plum1  = Instantiate(nextPhaseObj, transform.position, Quaternion.identity) as GameObject;
                 GameObject plum2  = Instantiate(nextPhaseObj, transform.position, Quaternion.identity) as GameObject;
                 plum1.transform.parent = Game.plumBatch.transform;
                 plum1.transform.parent = Game.plumBatch.transform;
                 Vector2 sqForce = new Vector2((bPoint.y * 5) * nextFormSpeed / 3, (bPoint.x * 5) * nextFormSpeed / 3);
                 plum1.GetComponent <Rigidbody2D>().AddForce(sqForce.normalized * nextFormSpeed, ForceMode2D.Impulse);
                 plum2.GetComponent <Rigidbody2D>().AddForce(-sqForce.normalized * nextFormSpeed, ForceMode2D.Impulse);
                 Destroy(gameObject);
             }
             else     //If it is the final plum, don't make plums and just make the final plopplet.
             {
                 for (int i = 0; i < moneys; i++)
                 {
                     Quaternion rot = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
                     Instantiate(coin, transform.position, rot);
                 }
                 Destroy(gameObject);
             }
         }
     }
 }
Пример #18
0
 private void HurtMe(Vector2 touchPoint)
 {
     if (hurtCounter <= 0 && startCounter <= 0)
     {
         if (Game.newCurrentHealth > 1)
         {
             Game.hitByFinalBoss = true;
             PlaySound.NoLoop(hitSndPool[UnityEngine.Random.Range(0, hitSndPool.Length)]);
             Instantiate(swearObj, transform.position, Quaternion.identity);
             man.gotHit = true;
             Vector2 bPoint = new Vector2(transform.position.x, transform.position.y) - touchPoint;
             bPoint.Normalize();
             GetComponent <Rigidbody2D>().AddForce(new Vector2((bPoint.x * knockBack) * knockBackMultiplier, (bPoint.y * knockBack) * knockBackMultiplier), ForceMode2D.Impulse);
             Game.newCurrentHealth--;
             hurtCounter = hurtTime;
         }
         else if (!dead)
         {
             KillMe();
         }
     }
 }
Пример #19
0
 //When I'm hit by a bullet.
 void OnTriggerEnter2D(Collider2D bullet)
 {
     if (bullet.gameObject.tag == "Bullet")
     {
         Vector2 bPoint = new Vector2(bullet.gameObject.transform.position.x, bullet.gameObject.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
         if (hp > 1)
         {
             AudioClip a = hitSounds[Random.Range(0, hitSounds.Count)];
             PlaySound.NoLoop(a);
             bullet.gameObject.GetComponent <BulletScript>().PoofMe();
             hp--;
             hitCounter = hitTime;
             bPoint.Normalize();
             GetComponent <Rigidbody2D>().AddForce(new Vector2(((bPoint.x * knockBack) * -1) * speed / 3, ((bPoint.y * knockBack) * -1) * speed / 3), ForceMode2D.Impulse);
         }
         else
         {
             if (enemy == Enemy.Splitter)
             {
                 GameObject sq      = Resources.Load("Enemies/Square Enemy") as GameObject;
                 GameObject sq1     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
                 GameObject sq2     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
                 Vector2    sqForce = new Vector2((bPoint.y * 5) * speed / 3, (bPoint.x * 5) * speed / 3);
                 sq1.GetComponent <Rigidbody2D>().AddForce(sqForce, ForceMode2D.Impulse);
                 sq2.GetComponent <Rigidbody2D>().AddForce(-sqForce, ForceMode2D.Impulse);
             }
             AudioClip a = killSounds[Random.Range(0, killSounds.Count)];
             PlaySound.NoLoop(a);
             if (healthChance == 3)
             {
                 Instantiate(heartPickup, transform.position, Quaternion.identity);
             }
             breakInst = (GameObject)Instantiate(breakEffect, transform.position, Quaternion.identity);
             breakInst.transform.parent = Game.bulletHolder.transform;
             Destroy(breakInst, 5f);
             Destroy(gameObject);
         }
     }
 }
Пример #20
0
    //Writing out the text.
    IEnumerator TypeText()
    {
        foreach (char letter in textLines[index].ToCharArray())
        {
            yield return(new WaitForSeconds(letterPause));

            if (letter == '~')
            {
                ableToGoOn = true;
            }
            else
            {
                textBeingWritten += letter;
            }

            if (letter != ' ')
            {
                PlaySound.NoLoop(letterWriteSound);
            }

            if (charsCurrently >= maxCharsALine && letter == ' ')
            {
                textBeingWritten = textBeingWritten + "\n";
                charsCurrently   = 0;
            }

            if (tMeshCurrentlyBeingUsed != null)
            {
                //Text should equal the text being written out in the coroutine.
                tMeshCurrentlyBeingUsed.text = textBeingWritten;
            }

            charsCurrently++;
            yield return(0);

            yield return(new WaitForSeconds(letterPause));
        }
    }
Пример #21
0
    //When I'm hit by a bullet.
    void OnTriggerEnter2D(Collider2D bullet)
    {
        if (Game.playerObj != null)
        {
            Vector2 playerPoint = new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
            Vector2 bulletPoint = new Vector2(bullet.gameObject.transform.position.x, bullet.gameObject.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
            if (bullet.gameObject.tag == "Bullet" || (enemy == Enemy.MoneyCircle && bullet.gameObject.tag == "Player"))
            {
                if (hp > 1)
                {
                    AudioClip a = hitSounds[Random.Range(0, hitSounds.Count)];
                    PlaySound.NoLoop(a);
                    bullet.gameObject.GetComponent <BulletScript>().PoofMe();
                    hp--;
                    hitCounter = hitTime;
                    playerPoint.Normalize();
                    if (enemy == Enemy.Hexagon || enemy == Enemy.Circle)
                    {
                        GetComponent <Rigidbody2D>().AddForce(new Vector2(((bulletPoint.x * knockBack) * -1) * speed / 3, ((bulletPoint.y * knockBack) * -1) * speed / 3), ForceMode2D.Impulse);
                    }
                    else
                    {
                        GetComponent <Rigidbody2D>().AddForce(new Vector2(((playerPoint.x * knockBack) * -1) * speed / 3, ((playerPoint.y * knockBack) * -1) * speed / 3), ForceMode2D.Impulse);
                    }
                }
                else
                {
                    Die(playerPoint, bulletPoint);
                }
            }

            if (bullet.gameObject.tag == "Player Laser" && enemy != Enemy.MoneyCircle)
            {
                Die(playerPoint, bulletPoint);
            }
        }
    }
Пример #22
0
    private void WallDeflect(string direction)
    {
        int   zp = 5;
        float deflectKnockBack = 35f;

        switch (direction)
        {
        case "Left":
            Vector3    rotVecLeft = new Vector3(0, 0, 270);
            Quaternion rotLeft    = Quaternion.Euler(rotVecLeft);
            Instantiate(deflectEffect, new Vector3(-35.6f, transform.position.y, zp), rotLeft);
            deflectForceVec = new Vector2(deflectKnockBack, 0);
            break;

        case "Right":
            Vector3    rotVecRight = new Vector3(0, 0, 90);
            Quaternion rotRight    = Quaternion.Euler(rotVecRight);
            Instantiate(deflectEffect, new Vector3(35.6f, transform.position.y, zp), rotRight);
            deflectForceVec = new Vector2(-deflectKnockBack, 0);
            break;

        case "Up":
            Vector3    rotVecUp = new Vector3(0, 0, 180);
            Quaternion rotUp    = Quaternion.Euler(rotVecUp);
            Instantiate(deflectEffect, new Vector3(transform.position.x, 20.2f, zp), rotUp);
            deflectForceVec = new Vector2(0, -deflectKnockBack);
            break;

        case "Down":
            Instantiate(deflectEffect, new Vector3(transform.position.x, -20.2f, zp), Quaternion.identity);
            deflectForceVec = new Vector2(0, deflectKnockBack);
            break;
        }
        PlaySound.NoLoop(wallDeflectSnd);
        deflectCounter = deflectTime;
    }
Пример #23
0
    void Update()
    {
        //Set position and parents of the object and body.
        body.transform.parent       = Game.enemyHolder.transform;
        body.transform.position     = gameObject.transform.position;
        gameObject.transform.parent = Game.enemyHolder.transform;

        //Manage the health bar.
        float divider = 0.02f;

        Game.manager.GetComponent <GameManager>().BossHealthBar(health, divider);
        if (health < 0)
        {
            health = 0;
        }

        //Hold boss until not in Splash Screen.
        if (Game.manager.GetComponent <GameManager>().splashCounter <= 0 && !dead)
        {
            //Move towards player slowly.
            if (Game.playerObj != null)
            {
                dif = new Vector2(transform.position.x, transform.position.y) - new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y);
            }
            Vector2 vel = -(dif.normalized) * speed;
            GetComponent <Rigidbody2D>().velocity = vel;

            //Scale up the less health he has.
            float   scale       = ((50 - health) * 0.325f) + 4f;
            Vector3 targetScale = new Vector3(scale, scale, 1f);
            transform.localScale      = Vector3.Lerp(transform.localScale, targetScale, 5f * Time.deltaTime);
            body.transform.localScale = transform.localScale;

            //Make the hurt face when hit.
            if (hurtCounter > 0)
            {
                hurtCounter -= Time.deltaTime;
                targetFace   = 1;
            }
            else
            {
                if (Game.smileyMode)
                {
                    targetFace = 2;
                }
                else
                {
                    targetFace = 0;
                }
            }

            //Apply what face to show. [1= normal; 2 = hurt;]
            for (int i = 0; i < faces.Length; i++)
            {
                faces[i].SetActive(i == targetFace);
            }
        }
        else if (dead)           //When dead.
        {
            if (!playedDeadTween)
            {
                iTween.MoveTo(gameObject, iTween.Hash(
                                  "x", 0f, "y", 0f, "z", 0f,
                                  "time", deathTime,
                                  "easetype", iTween.EaseType.easeInOutSine,
                                  "looptype", iTween.LoopType.none
                                  ));
                iTween.ScaleTo(spikes, Vector3.zero, deathTime);
                deathParticles.GetComponent <ParticleSystem>().Play();
                GetComponent <Rigidbody2D>().velocity = Vector2.zero;
                playedDeadTween = true;
            }
            transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(4f, 4f, 1f), 5f * Time.deltaTime);
            faces[0].SetActive(false);
            faces[1].SetActive(true);
            faces[2].SetActive(false);
            body.transform.localScale = transform.localScale;
            GetComponent <CircleCollider2D>().enabled = false;
            body.GetComponent <Collider2D>().enabled  = false;
            if (deathCounter > 0)
            {
                deathCounter -= Time.deltaTime;
            }
            if (deathCounter <= 0 && !playedSecondTween)
            {
                iTween.MoveTo(gameObject, iTween.Hash(
                                  "x", 0f, "y", -27f, "z", 0f,
                                  "time", 1f,
                                  "easetype", iTween.EaseType.linear,
                                  "looptype", iTween.LoopType.none
                                  ));
                iTween.ScaleTo(boom, iTween.Hash(
                                   "x", 20f, "y", 20f, "z", 1f,
                                   "time", 1f,
                                   "delay", 1f,
                                   "easetype", iTween.EaseType.linear,
                                   "looptype", iTween.LoopType.none
                                   ));
                iTween.ColorTo(boom, iTween.Hash(
                                   "a", 0f,
                                   "time", 0.75f,
                                   "delay", 1.25f,
                                   "easetype", iTween.EaseType.linear,
                                   "looptype", iTween.LoopType.none
                                   ));
                Game.manager.GetComponent <GameManager>().victory = true;
                PlaySound.NoLoop(boomSnd);
                playedSecondTween = true;
            }
        }
    }
Пример #24
0
    public void MenuAction(int i)
    {
        switch (i)
        {
        case 0:                 //Play Adventure.
            if (Game.beatFirstLevel)
            {
                currentMenu  = Menu.Adventure;
                adventureCam = true;
                camState     = 0;
            }
            else
            {
                LoadLevel(6);
            }
            break;

        case 1:                 //Play Bullet Hell.
            LoadLevel(4);
            break;

        case 2:                 //Play Legacy Mode.
            LoadLevel(2);
            break;

        case 3:                 //Play Legacy Bullet Hell Mode.
            LoadLevel(3);
            break;

        case 4:                 //The Ship Shop.
            camState    = 3;
            currentMenu = Menu.Shop;
            break;

        case 5:                 //Statistics.
            camState    = 1;
            currentMenu = Menu.Stats;
            break;

        case 6:                 //Options.
            camState    = 2;
            currentMenu = Menu.Settings;
            break;

        case 7:                 //Purchase Soundtrack.
            if (Game.steamy)
            {
                SteamFriends.ActivateGameOverlayToWebPage("https://store.steampowered.com/app/1194020/LoopLoop_DX_Official_Soundtrack/");
            }
            break;

        case 8:                 //Purchase Supporter Pack.
            if (Game.steamy)
            {
                SteamFriends.ActivateGameOverlayToWebPage("https://store.steampowered.com/app/1194021/LoopLoop_DX_Supporter_Pack/");
            }
            break;

        case 9:                 //Quit.
            LoadLevel(420);
            break;

        case 10:                 //Back from statistics.
            camState    = 0;
            currentMenu = Menu.Main;
            break;

        case 11:                 //Back from options.
            gamePadSettingsIndex = 0;
            atRightSettingsMenu  = false;
            camState             = 0;
            currentMenu          = Menu.Main;
            break;

        case 12:                 //Back from shop.
            camState    = 0;
            currentMenu = Menu.Main;
            break;

        case 13:                 //Back from delete menu.
            camState    = 2;
            currentMenu = Menu.Settings;
            break;

        case 14:                 //Delete Adventure.
            camState    = 4;
            dType       = DeleteType.Adventure;
            currentMenu = Menu.DeleteSave;
            break;

        case 15:                 //Delete ALLLLL
            camState    = 4;
            dType       = DeleteType.All;
            currentMenu = Menu.DeleteSave;
            break;

        case 16:     //Back from adventure.
            currentMenu = MenuManagerScript.Menu.Main;
            PlaySound.NoLoop(snd);
            float camTime = 1.5f;
            backFromAdventureTweenCounter = camTime + 0.1f;
            iTween.MoveTo(Camera.main.gameObject, iTween.Hash("x", 0, "y", 0, "time", camTime, "easetype", iTween.EaseType.easeInOutSine, "looptype", iTween.LoopType.none));
            adventureCam = false;
            break;
        }
        PlaySound.NoLoop(snd);         //Play button click sound.
    }
Пример #25
0
    private void MyAI()
    {
        //Cast ray to player.
        playerRay = Physics2D.Linecast(transform.position, new Vector3(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y - 0.25f, Game.playerObj.transform.position.z), wall);

        //Square + Circle AI.
        if (enemy == Enemy.Square || enemy == Enemy.Circle || enemy == Enemy.Hexagon)
        {
            //If the player ray isn't interrupted by a wall...
            if (!playerRay)
            {
                targetForce = new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
                targetForce.Normalize();
                targetForce = new Vector2(targetForce.x * speed, targetForce.y * speed);
                if (enemy == Enemy.Square)
                {
                    moveLerp = 3f;
                }
            }
            else                 // If you are interrupted by a wall.
            {
                AStarAI();
            }

            if (enemy == Enemy.Square)
            {
                //Setting rotation of my bby.
                puppets[0].GetComponent <RotateScript>().rotationSpeed = (targetForce.x / 2) * -1;
            }

            //Apply force with that smooth lerp bby.
            GetComponent <Rigidbody2D>().velocity = Vector2.Lerp(GetComponent <Rigidbody2D>().velocity, targetForce, moveLerp * Time.deltaTime);
        }

        //Triangle AI.
        if (enemy == Enemy.Triangle)
        {
            float qSlerp = 0f;
            trailObj.GetComponent <TrailRenderer>().material.color = Game.bulletColor; //Color the trail.
            //If the player ray isn't interrupted by a wall...
            if (!playerRay)
            {
                qSlerp      = 6f;
                targetForce = new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
                targetForce.Normalize();
                dashCounter -= Time.deltaTime;
                if (dashCounter <= 0)
                {
                    GetComponent <Rigidbody2D>().AddForce(new Vector2(targetForce.x * speed, targetForce.y * speed), ForceMode2D.Impulse);
                    dashCounter = dashTime;
                }
                //Managing subpuppet color.
                float alph = dashCounter / 2;
                if (alph < 0)
                {
                    alph = 0;
                }
                if (alph > 1)
                {
                    alph = 1;
                }
                Color subCol = new Color(Game.backColor.r, Game.backColor.g, Game.backColor.b, (1f - alph));
                subPuppet.GetComponent <MeshRenderer>().material.color = subCol;
                subPuppet.transform.localScale = new Vector3(alph, alph, 1);

                //Managing trail lifetime.
                targetTrailLifeTime = dashCounter;
                //Slowing down the triangle, since he isn't dashing anymore.
                float   slowdown = 30f;
                Vector2 vel      = rig.velocity;
                if (vel.x > 0)
                {
                    vel.x -= Time.deltaTime * slowdown;
                }
                if (vel.x < 0)
                {
                    vel.x += Time.deltaTime * slowdown;
                }
                if (vel.y > 0)
                {
                    vel.y -= Time.deltaTime * slowdown;
                }
                if (vel.y < 0)
                {
                    vel.y += Time.deltaTime * slowdown;
                }
                rig.velocity = vel;
            }
            else
            {
                Color subCol = subPuppet.GetComponent <MeshRenderer>().material.color;
                if (subCol.a > 0f)
                {
                    subCol.a -= Time.deltaTime;
                }
                else if (subCol.a < 0f)
                {
                    subCol.a = 0;
                }
                subPuppet.GetComponent <MeshRenderer>().material.color = subCol;
                dashCounter = dashTime;
                AStarAI();
                qSlerp = 6f;
                targetTrailLifeTime = 0.5f;
                //Apply force with that smooth lerp bby.
                GetComponent <Rigidbody2D>().velocity = Vector2.Lerp(GetComponent <Rigidbody2D>().velocity, targetForce, moveLerp * Time.deltaTime);
            }
            float smooth = 5f;
            Mathf.Lerp(trailObj.GetComponent <TrailRenderer>().time, targetTrailLifeTime, smooth * Time.deltaTime);
            Quaternion w     = Quaternion.identity;
            float      angle = Mathf.Atan2(targetForce.y, targetForce.x) * Mathf.Rad2Deg;
            w.eulerAngles = new Vector3(0, 0, (angle - 90));
            puppets[0].transform.rotation = Quaternion.Slerp(puppets[0].transform.rotation, w, qSlerp * Time.deltaTime);
        }

        //Splitter AI.
        if (enemy == Enemy.Splitter || enemy == Enemy.VennDiagram)
        {
            //If the player ray isn't interrupted by a wall...
            if (!playerRay)
            {
                targetForce = new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y) - new Vector2(transform.position.x, transform.position.y);
                targetForce.Normalize();
                targetForce = new Vector2(targetForce.x * speed, targetForce.y * speed);
            }
            else
            {
                AStarAI();
            }
            //Apply force with that smooth lerp bby.
            GetComponent <Rigidbody2D>().velocity = Vector2.Lerp(GetComponent <Rigidbody2D>().velocity, targetForce, moveLerp * Time.deltaTime);
        }

        //Hexagon AI.
        if (enemy == Enemy.Hexagon)
        {
            float   trigD = 8f;
            float   d     = Vector2.Distance(new Vector2(transform.position.x, transform.position.y), new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y));
            Vector3 scale = new Vector3((trigD / d), (trigD / d), 1f);
            if (scale.x > 1f)
            {
                scale.x = 1f;
            }
            else if (scale.x < 0f)
            {
                scale.x = 0f;
            }
            if (scale.y > 1f)
            {
                scale.y = 1f;
            }
            else if (scale.y < 0f)
            {
                scale.y = 0f;
            }
            subPuppet.transform.localScale = scale;
            subPuppet.GetComponent <MeshRenderer>().material.color = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, (trigD / d));
            if (d < trigD && !madeAtk)
            {
                GameObject atkObj  = Resources.Load("New Hex Blast") as GameObject;
                GameObject atkInst = Instantiate(atkObj, transform.position, Quaternion.identity) as GameObject;
                iTween.ScaleTo(atkInst, iTween.Hash(
                                   "x", 3f,
                                   "y", 3f,
                                   "z", 3f,
                                   "time", 0.2f,
                                   "easetype", iTween.EaseType.easeInOutSine,
                                   "looptype", iTween.LoopType.pingPong
                                   ));
                atkInst.transform.parent = gameObject.transform;
                Destroy(atkInst, 0.39f);
                madeAtk = true;
            }
            if (d > trigD)
            {
                madeAtk = false;
            }
        }

        //Shooter AI.
        if (enemy == Enemy.Shooter)
        {
            //Quaternions for shooter bullet rotation.
            Quaternion u  = transform.localRotation * Quaternion.identity;
            Quaternion ul = transform.localRotation * Quaternion.Euler(0, 0, 45);
            Quaternion l  = transform.localRotation * Quaternion.Euler(0, 0, 90);
            Quaternion ur = transform.localRotation * Quaternion.Euler(0, 0, 135);
            Quaternion d  = transform.localRotation * Quaternion.Euler(0, 0, 180);
            Quaternion dr = transform.localRotation * Quaternion.Euler(0, 0, (180 + 45));
            Quaternion r  = transform.localRotation * Quaternion.Euler(0, 0, 270);
            Quaternion dl = transform.localRotation * Quaternion.Euler(0, 0, (270 + 45));
            //Subtract that counter!
            shootCounter -= Time.deltaTime;

            //Manage the subpuppet color and scale.
            float f = (shootCounter / 2f) + 0.2f;
            if (f > 1f)
            {
                f = 1f;
            }
            subPuppet.transform.localScale = new Vector3(f - 0.2f, f - 0.2f, 1);
            subPuppet.GetComponent <MeshRenderer>().material.color = new Color(Game.backColor.r, Game.backColor.g, Game.backColor.b, 1f - f);

            //When the shootcounter goes below 0...
            if (shootCounter <= 0)
            {
                //Make the bullets.
                switch (shooterType)
                {
                case ShooterType.Regular:
                    GameObject go1 = Instantiate(bullet, transform.position, u) as GameObject; go1.transform.parent = Game.bulletHolder.transform;
                    GameObject go2 = Instantiate(bullet, transform.position, d) as GameObject; go2.transform.parent = Game.bulletHolder.transform;
                    GameObject go3 = Instantiate(bullet, transform.position, l) as GameObject; go3.transform.parent = Game.bulletHolder.transform;
                    GameObject go4 = Instantiate(bullet, transform.position, r) as GameObject; go4.transform.parent = Game.bulletHolder.transform;
                    break;

                case ShooterType.Diagonal:
                    GameObject go5 = Instantiate(bullet, transform.position, ul) as GameObject; go5.transform.parent = Game.bulletHolder.transform;
                    GameObject go6 = Instantiate(bullet, transform.position, ur) as GameObject; go6.transform.parent = Game.bulletHolder.transform;
                    GameObject go7 = Instantiate(bullet, transform.position, dr) as GameObject; go7.transform.parent = Game.bulletHolder.transform;
                    GameObject go8 = Instantiate(bullet, transform.position, dl) as GameObject; go8.transform.parent = Game.bulletHolder.transform;
                    break;

                case ShooterType.EightWay:
                    GameObject go9  = Instantiate(bullet, transform.position, u) as GameObject; go9.transform.parent = Game.bulletHolder.transform;
                    GameObject go10 = Instantiate(bullet, transform.position, d) as GameObject; go10.transform.parent = Game.bulletHolder.transform;
                    GameObject go11 = Instantiate(bullet, transform.position, l) as GameObject; go11.transform.parent = Game.bulletHolder.transform;
                    GameObject go12 = Instantiate(bullet, transform.position, r) as GameObject; go12.transform.parent = Game.bulletHolder.transform;
                    GameObject go13 = Instantiate(bullet, transform.position, ul) as GameObject; go13.transform.parent = Game.bulletHolder.transform;
                    GameObject go14 = Instantiate(bullet, transform.position, ur) as GameObject; go14.transform.parent = Game.bulletHolder.transform;
                    GameObject go15 = Instantiate(bullet, transform.position, dr) as GameObject; go15.transform.parent = Game.bulletHolder.transform;
                    GameObject go16 = Instantiate(bullet, transform.position, dl) as GameObject; go16.transform.parent = Game.bulletHolder.transform;
                    break;
                }
                shootCounter = shootTime;
            }
        }

        //Donut AI.
        if (enemy == Enemy.Donut)
        {
            GameObject pupil       = transform.Find("pupil").gameObject;
            GameObject pupilCharge = transform.Find("pupil charge").gameObject;
            GameObject lineObj     = pupil.transform.Find("laser").gameObject;
            GameObject linePuppet  = lineObj.transform.Find("laser puppet").gameObject;
            GameObject spark       = lineObj.transform.Find("laser sparks").gameObject;

            //Manage the position of the pupil charge.
            pupilCharge.transform.position = new Vector3(pupil.transform.position.x, pupil.transform.position.y, -1f);

            //Rotate laser to player, but only when not firing.
            if (!madeAtk)
            {
                Vector3    dir         = transform.position - new Vector3(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y - 0.25f, Game.playerObj.transform.position.z);
                float      angle       = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
                Quaternion newRotation = Quaternion.AngleAxis(angle, Vector3.forward);
                pupil.transform.rotation = Quaternion.Slerp(pupil.transform.rotation, newRotation, 5f * Time.deltaTime);
            }

            //The direction the ray will look, at the player.
            RaycastHit2D hit = Physics2D.Raycast(pupil.transform.position, -pupil.transform.right, 100, wall);
            if (hit)
            {
                dist = hit.distance;
            }
            else
            {
                dist = 100f;
            }
            lineObj.transform.localScale = new Vector3(dist + 0.5f, 1, 1);

            //Setting texture scale of the sparks.
            spark.GetComponent <MeshRenderer>().material.mainTextureScale = new Vector2(dist, 1f);
            spark.SetActive(madeAtk);

            //If looking at a player.
            if (!playerRay)
            {
                Vector3 pPos  = transform.position - Game.playerObj.transform.position;
                Vector3 nPPos = -(pPos.normalized) / 1.5f;
                if (!madeAtk)
                {
                    pupil.transform.localPosition = Vector3.Lerp(pupil.transform.localPosition, nPPos, 4 * Time.deltaTime);
                }
                laserChargeCounter -= Time.deltaTime;
                if (laserChargeCounter <= 0)
                {
                    laserHoldCounter -= Time.deltaTime;
                    pupilCharge.GetComponent <MeshRenderer>().material.color = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, laserHoldCounter * 2);
                    pupilCharge.transform.localScale = new Vector3(laserHoldCounter * 2f, laserHoldCounter * 2, 1f);
                    laserColor = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b);
                    if (!madeAtk)
                    {
                        PlaySound.NoLoop(laserSnd);
                        madeAtk = true;
                    }
                    if (laserHoldCounter <= 0)
                    {
                        laserChargeCounter = laserChargeTime;
                    }
                }
                else
                {
                    pupilCharge.GetComponent <MeshRenderer>().material.color = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, 1f - (laserChargeCounter / 2f));
                    pupilCharge.transform.localScale = new Vector3(1f - (laserChargeCounter / 2f), 1f - (laserChargeCounter / 2f), 1f);
                    madeAtk          = false;
                    laserHoldCounter = laserHoldTime;
                    laserColor       = new Color(Game.frontColor.r, Game.frontColor.g, Game.frontColor.b, 0.5f);
                }
            }
            else    //If can't see the player.
            {
                madeAtk                       = false;
                laserChargeCounter            = laserChargeTime;
                pupil.transform.localPosition = Vector3.Lerp(pupil.transform.localPosition, Vector3.zero, 4 * Time.deltaTime);
                laserColor                    = Color.clear;
            }
            linePuppet.GetComponent <MeshRenderer>().material.color = laserColor;
            if (laserChargeCounter <= 0)
            {
                lineObj.tag = "Murder";
            }
            else
            {
                lineObj.tag = "Untagged";
            }
        }

        //Money Circle AI.
        if (enemy == Enemy.MoneyCircle)
        {
            coinTime -= Time.deltaTime;
            GameObject n = transform.Find("text").gameObject;
            n.GetComponent <TextMesh>().text    = Mathf.RoundToInt(coinTime).ToString();
            GetComponent <Collider2D>().enabled = (coinTime > 0f);
            if (coinTime <= 0f)
            {
                GameObject succ     = Resources.Load("Suck Effect") as GameObject;
                GameObject succInst = Instantiate(succ, new Vector3(transform.position.x, transform.position.y, transform.position.z + 4), Quaternion.identity);
                succInst.transform.parent = Game.bulletHolder.transform;
                breakInst = (GameObject)Instantiate(breakEffect, transform.position, Quaternion.identity);
                breakInst.transform.parent = Game.bulletHolder.transform;
                Destroy(succInst, 5f);
                Destroy(breakInst, 5f);
                Destroy(gameObject);
            }
        }

        //Urchin AI.
        if (enemy == Enemy.Urchin)
        {
            float suckPower = 1.25f;//How hard i suck.

            //Coloring the urchin outline.
            if (urchinOutline == null)
            {
                urchinOutline = puppets[0].transform.Find("visible radius").gameObject;
                return;
            }
            else if (urchinOutline != null && hp > 0)
            {
                Color lineC = new Color(Game.bulletColor.r, Game.bulletColor.g, Game.bulletColor.b, 0.35f);
                urchinOutline.GetComponent <LineRenderer>().material.color = lineC;
            }

            //If the player is present... suck him!
            if (Game.playerObj)
            {
                Vector2 playerPos      = new Vector2(Game.playerObj.transform.position.x, Game.playerObj.transform.position.y);
                Vector2 urchinDistance = new Vector2(transform.position.x, transform.position.y);
                float   triggerRadius  = 15f;
                float   d = Vector2.Distance(playerPos, urchinDistance);
                //Debug.Log(d.ToString());
                if (d < triggerRadius)
                {
                    Vector2 forceToApply = (playerPos - urchinDistance);
                    forceToApply.Normalize();
                    forceToApply = new Vector2(-forceToApply.x * suckPower, -forceToApply.y * suckPower);
                    //Debug.Log(forceToApply.ToString());
                    Game.playerObj.GetComponent <Rigidbody2D>().velocity += forceToApply;
                }
            }
        }

        //Swimmer AI.
        if (enemy == Enemy.Swimmer)
        {
            switch (swimmerDir)
            {
            case SwimmerType.Up:
                targetForce = new Vector2(0, speed);
                break;

            case SwimmerType.Down:
                targetForce = new Vector2(0, -speed);
                break;

            case SwimmerType.Left:
                targetForce = new Vector2(-speed, 0);
                break;

            case SwimmerType.Right:
                targetForce = new Vector2(speed, 0);
                break;
            }

            //Apply force.
            GetComponent <Rigidbody2D>().velocity = targetForce;
        }
    }
Пример #26
0
    private void Update()
    {
        if (!ended)   //If the cutscene is not ended...

        //Managing the spooky sound effect.
        {
            if (!Game.savedVektor)
            {
                if (index < 20)
                {
                    spooky.volume = 0f;
                }
                else if (index == 20)
                {
                    spooky.volume = 0.1f;
                }
                else if (index == 21)
                {
                    spooky.volume = 0.25f;
                }
                else if (index == 22)
                {
                    spooky.volume = 0.4f;
                }
                else if (index == 23)
                {
                    spooky.volume = 0.6f;
                }
                else if (index == 24)
                {
                    spooky.volume = 0.8f;
                }
                else if (index == 25)
                {
                    spooky.volume = 1f;
                }
            }
            else
            {
                spooky.volume = 0f;
            }

            //Determine which text mesh is currently being used.
            int currentSpeaker = speakingCharacterIndex[index];
            switch (currentSpeaker)
            {
            case 0:     //Heart speaking.
                whoSpeak                = Speaking.Heart;
                maxCharsALine           = 30;
                tMeshCurrentlyBeingUsed = heartTMesh;
                cAndVTMesh.text         = "";
                break;

            case 1:     //Carl Speaking.
                whoSpeak                = Speaking.Carl;
                maxCharsALine           = 48;
                tMeshCurrentlyBeingUsed = cAndVTMesh;
                heartTMesh.text         = "";
                break;

            case 2:     //Vektor speaking.
                whoSpeak                = Speaking.Vektor;
                maxCharsALine           = 48;
                tMeshCurrentlyBeingUsed = cAndVTMesh;
                heartTMesh.text         = "";
                break;
            }

            //When to set certain graphics to be active.
            heartText.SetActive(whoSpeak == Speaking.Heart);
            carlAndVektorText.SetActive(whoSpeak == Speaking.Vektor || whoSpeak == Speaking.Carl);
            carlAndVektorTextBox.SetActive(whoSpeak == Speaking.Vektor || whoSpeak == Speaking.Carl);
            carlPicture.SetActive(whoSpeak == Speaking.Carl);
            vektorPicture.SetActive(whoSpeak == Speaking.Vektor);

            if ((Input.GetButtonDown("Submit") || Input.GetButtonDown("Shoot")) && index != endAtLine && ableToGoOn)
            {
                index++;
                charsCurrently = 0;
                PlaySound.NoLoop(advanceTextSound);
                textBeingWritten = "";
                StartCoroutine(TypeText());
                tMeshCurrentlyBeingUsed.text = "";
                ableToGoOn = false;
            }

            if ((Input.GetButtonDown("Submit") || Input.GetButtonDown("Shoot")) && index >= endAtLine && ableToGoOn)
            {
                ended = true;
            }
        }
        else     //Load credits when ended...
        {
            if (!Game.savedVektor)
            {
                SceneManager.LoadScene(16);
            }
            else
            {
                fadeOutTime       -= Time.deltaTime;
                whiteNoise.volume -= Time.deltaTime / 7f;
                if (whiteNoise.volume <= 0)
                {
                    whiteNoise.volume = 0;
                }
                if (!playedFadeTween)
                {
                    iTweenEvent.GetEvent(fadeOut, "fadeout").Play();
                    playedFadeTween = true;
                }
                if (fadeOutTime <= 0)
                {
                    SceneManager.LoadScene(16);
                }
            }
        }
    }
Пример #27
0
    //This is how the player is handled regularly.
    void ControlPlayerRegularly()
    {
        if (startCounter > 0)
        {
            startCounter -= Time.deltaTime;
        }

        //Set pos and vel.
        pos = new Vector3(transform.position.x, transform.position.y, 0);
        vel = GetComponent <Rigidbody2D>().velocity;

        //If the laser hold counter is less than or equal to 0, move normally.
        if (laserHoldCounter <= 0 && deflectCounter <= 0)
        {
            //Tracking x and y input for keyboard.
            if (Game.usingController)
            {
                x = Input.GetAxis("Horizontal [Gamepad]");
                y = -Input.GetAxis("Vertical [Gamepad]");
            }
            else
            {
                x = Input.GetAxisRaw("Horizontal");
                y = Input.GetAxisRaw("Vertical");

                //Track the position of the mouse relative to the screen.
                mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                if (Camera.main.gameObject != null)
                {
                    mousePos = Camera.main.ScreenToWorldPoint(mousePos);
                }
                else
                {
                    mousePos = Vector2.zero;
                }
            }

            //Move around.
            vel = Vector2.Lerp(vel, new Vector2(x * speed, y * speed), Time.deltaTime * 8f);

            //Looping around the screen. (You can do this when you aren't being pushed by the laser.)
            if (Game.loopBlocked) //If the player is blocked from looping... knock him back!
            {
                if (deflectCounter > 0)
                {
                    deflectCounter -= Time.deltaTime;
                }
                else
                {
                    if (pos.x < -36f)
                    {
                        WallDeflect("Left");
                    }
                    if (pos.x > 36f)
                    {
                        WallDeflect("Right");
                    }
                    if (pos.y > 21f)
                    {
                        WallDeflect("Up");
                    }
                    if (pos.y < -21f)
                    {
                        WallDeflect("Down");
                    }
                }
            }
            else         //If the player is NOT blocked from looping, go around the screen as normal.
            {
                if (pos.x < -37f)
                {
                    pos.x = 36.5f;
                }
                if (pos.x > 37f)
                {
                    pos.x = -36.5f;
                }
                if (pos.y > 22f)
                {
                    pos.y = -21.5f;
                }
                if (pos.y < -22f)
                {
                    pos.y = 21.5f;
                }
            }


            //Apply rotation.
            puppet.transform.localRotation = Quaternion.Slerp(puppet.transform.localRotation, MyRotation(), Time.deltaTime * 25f);
        }
        else if (laserHoldCounter > 0)    //If the laser hold counter is greater than zero... push the player back with it.
        {
            laserHoldCounter -= Time.deltaTime;
            if (currentLaser != null && laserHoldCounter < 0.8f)
            {
                //Push back the player.
                float      pushBack = (speed * laserHoldCounter);
                GameObject midPoint = currentLaser.GetComponent <PlayerLaserScript>().midPoint;
                Vector2    bPoint   = new Vector2(transform.position.x, transform.position.y) - new Vector2(midPoint.transform.position.x, midPoint.transform.position.y);
                bPoint.Normalize();
                vel = new Vector2((bPoint.x * pushBack), (bPoint.y * pushBack));

                //Position the laser.
                currentLaser.transform.position = pLaser.transform.position;
            }
            else
            {
                vel = Vector2.zero;
            }
            //If you go out of bounds of screen while being pushed by the laser, keep me on the screen and don't loop.
            if (pos.x < -36f)
            {
                pos.x = -36f;
            }
            if (pos.x > 36f)
            {
                pos.x = 36f;
            }
            if (pos.y > 21f)
            {
                pos.y = 21f;
            }
            if (pos.y < -21f)
            {
                pos.y = -21f;
            }
        }
        else if (deflectCounter > 0)
        {
            deflectCounter -= Time.deltaTime;
            vel             = deflectForceVec;
        }
        else
        {
            vel = Vector2.zero;
        }



        //Figuring out if the player is in the disruptor or not.
        Game.inDisruptor = Physics2D.OverlapPoint(new Vector2(pos.x, pos.y), disruptorLayer);

        //Playing the disruptor sound effects.
        if (Game.inDisruptor && !playedEnterDisruptorSound)
        {
            PlaySound.NoLoop(enterDisruptorSnd);
            disruptorParticlesObj.GetComponent <ParticleSystem>().Play();
            playedExitDisruptorSound  = false;
            playedEnterDisruptorSound = true;
        }
        else if (!Game.inDisruptor && !playedExitDisruptorSound)
        {
            PlaySound.NoLoop(exitDisruptorSnd);
            disruptorParticlesObj.GetComponent <ParticleSystem>().Stop();
            playedEnterDisruptorSound = false;
            playedExitDisruptorSound  = true;
        }

        //Always setting the color of the disruptor particle Object.
        disruptorParticlesObj.GetComponent <Renderer>().material.color = Game.bulletColor;

        //Shooting bullets.
        if (shootCounter > 0)
        {
            shootCounter -= Time.deltaTime;
        }

        //Shooting bullets with keyboard controls.
        if (!Game.usingController)
        {
            if (Input.GetButton("Shoot") && Game.canShoot && Game.gotGun && !Game.inDisruptor)
            {
                Shoot();
            }
        }
        else     //Shooting bullets with gamepad controls.
        {
            if (looking && Game.canShoot && Game.gotGun && !Game.inDisruptor)
            {
                Shoot();
            }
        }

        //Laser shooting.
        if (laserShootCounter > 0)
        {
            laserShootCounter -= Time.deltaTime;
        }

        //Shoot lasers when you got them. (Keyboard)
        if (Game.ownsLasers && Input.GetButtonDown("Shoot Laser") && laserShootCounter <= 0 && !Game.usingController && Game.currentLasers > 0 && !Game.inDisruptor)
        {
            ShootLaser();
        }
        //Shoot lasers when you got them. (Gamepad)
        if (Game.usingController)
        {
            float lPull = Input.GetAxisRaw("Shoot Laser [Gamepad]");
            if (lPull > 0.65f && laserShootCounter <= 0 && Game.ownsLasers && Game.currentLasers > 0 && !Game.inDisruptor)
            {
                ShootLaser();
            }
            //Debug.Log("Left Trigger: " + lPull.ToString());
        }

        //Apply position.
        GetComponent <Rigidbody2D>().velocity = vel;
        transform.position = pos;

        //Managing the loop puppet.
        loopPuppet.SetActive(Game.canShootSelf);
        loopPuppet.GetComponent <MeshRenderer>().material.color = Game.backColor;

        //Managing the glitter.
        moving = Moving(vel);
        if (moving)
        {
            if (Game.enableGlitterTrail && !glitterObj.GetComponent <ParticleSystem>().isPlaying)
            {
                glitterObj.GetComponent <ParticleSystem>().Play();
            }
            if (!Game.enableGlitterTrail && glitterObj.GetComponent <ParticleSystem>().isPlaying)
            {
                glitterObj.GetComponent <ParticleSystem>().Stop();
            }
        }
        else
        {
            if (glitterObj.GetComponent <ParticleSystem>().isPlaying)
            {
                glitterObj.GetComponent <ParticleSystem>().Stop();
            }
        }
    }
Пример #28
0
    //This is how the player is handled during the final phase of the final boss.
    void ControlPlayerFinal()
    {
        //Start counter is always 0.
        startCounter = 0;

        //Hide the loop puppet.
        loopPuppet.SetActive(false);

        //Turn on the final trail.
        finalTrail.SetActive(true);
        if (!finalTrail.GetComponent <ParticleSystem>().isPlaying)
        {
            finalTrail.GetComponent <ParticleSystem>().Play();
        }

        //The x position the player is locked at.
        float xLockPos = -30.5f;

        //Set pos and vel vectors.
        pos = new Vector3(xLockPos, transform.position.y, 0);
        vel = GetComponent <Rigidbody2D>().velocity;

        //Reading moving up and down controls without a controller.
        if (Game.usingController)
        {
            y = -Input.GetAxis("Vertical [Gamepad]");
        }
        else     //Reading vertical input from a controller.
        {
            y = Input.GetAxisRaw("Vertical");
        }

        //Lerp the vel vector to match the y input.
        float speed = 23f;

        vel = Vector2.Lerp(vel, new Vector2(0, y * speed), Time.deltaTime * 8f);

        //Loop the player around vertically.
        if (pos.y > 22f)
        {
            pos.y = -21.5f;
        }
        if (pos.y < -22f)
        {
            pos.y = 21.5f;
        }

        //Apply position and velocity.
        transform.position = pos;
        GetComponent <Rigidbody2D>().velocity = vel;

        //Keep ship at proper rotation.
        finalShipRot.eulerAngles  = new Vector3(0, 0, -90);
        puppet.transform.rotation = finalShipRot;

        //Shooting bullets.
        float bulletXSpawn = 0.5f;

        if (finalShootCounter > 0)
        {
            finalShootCounter -= Time.deltaTime;
        }
        if (Game.usingController)
        {
            //Looking with the right stick.
            Vector2 lookVec = new Vector2(Input.GetAxisRaw("Gamepad Right Stick X"), -Input.GetAxisRaw("Gamepad Right Stick Y"));
            float   thresh  = 0.15f;
            if (lookVec.x > thresh || lookVec.y > thresh || lookVec.x < -thresh || lookVec.y < -thresh)
            {
                looking = true;
                angle   = Mathf.Atan2(lookVec.x, lookVec.y) * Mathf.Rad2Deg;
            }
            else
            {
                looking = false;
            }

            //If you are holding the right stick in any direction, shoot!
            if (looking && finalShootCounter <= 0)
            {
                PlaySound.NoLoop(shoot);
                Vector3 bulletSpawnPos = new Vector3(pos.x + bulletXSpawn, pos.y, 0);
                Instantiate(finalBulletBatch, bulletSpawnPos, Quaternion.identity);
                finalShootCounter = finalShootTime;
            }
        }
        else
        {
            if (Input.GetButton("Shoot") && finalShootCounter <= 0)
            {
                PlaySound.NoLoop(shoot);
                Vector3 bulletSpawnPos = new Vector3(pos.x + bulletXSpawn, pos.y, 0);
                Instantiate(finalBulletBatch, bulletSpawnPos, Quaternion.identity);
                finalShootCounter = finalShootTime;
            }
        }
    }
Пример #29
0
    private void Update()
    {
        //Screen looping.
        if (myPhase != Phase.One)  //The only phase that doesn't screen loop is the first one.
        {
            pos = transform.position;

            float baseLoopXLimit = 35.4f;
            float baseLoopYLimit = 20.4f;
            float sizeAddition   = puppet.transform.localScale.x / 2f;
            float xLimit         = baseLoopXLimit + sizeAddition;
            float yLimit         = baseLoopYLimit + sizeAddition;

            //Looping around the screen.
            if (pos.x < -xLimit)
            {
                pos.x = xLimit - 0.5f;
            }
            if (pos.x > xLimit)
            {
                pos.x = -xLimit + 0.5f;
            }
            if (pos.y > yLimit)
            {
                pos.y = -yLimit + 0.5f;
            }
            if (pos.y < -yLimit)
            {
                pos.y = yLimit - 0.5f;
            }

            //Locking the z position.
            pos.z = zLock;

            //Updating the position.
            transform.position = pos;
        }
        else
        {
            float   soundDist = 40f;
            Vector2 vTwoPos   = new Vector2(gameObject.transform.position.x, gameObject.transform.position.y);
            float   d         = Vector2.Distance(vTwoPos, Vector2.zero);
            if (d < soundDist && !playedIntroSound)
            {
                PlaySound.NoLoop(introSnd);
                playedIntroSound = true;
            }
        }



        //Flash me when I'm hit.
        if (hitCounter > 0f)
        {
            hitCounter -= Time.deltaTime;
            targetColor = Game.bulletColor;
        }
        else
        {
            targetColor = new Color(0.7f, 0f, 1f);
        }

        //Lerp that color!
        float smoothness = 5f;

        puppet.GetComponent <MeshRenderer>().material.color = Color.Lerp(puppet.GetComponent <MeshRenderer>().material.color, targetColor, smoothness * Time.deltaTime);
    }
Пример #30
0
    private void Die(Vector2 playerPoint, Vector2 bulletPoint)
    {
        //What to do special when the urchin dies.
        if (enemy == Enemy.Urchin)
        {
            float      destroyTime = 1;
            GameObject newParent   = new GameObject();
            newParent.name = "Urchin Death Effect";
            GameObject bubbles = puppets[0].transform.Find("bubbles").gameObject;
            GameObject vortex  = puppets[0].transform.Find("vortex").gameObject;
            bubbles.transform.parent     = Game.bulletHolder.transform;
            bubbles.transform.localScale = Vector3.one;
            Destroy(bubbles, 5f);
            urchinOutline.transform.parent = newParent.transform;
            vortex.transform.parent        = newParent.transform;
            bubbles.GetComponent <ParticleSystem>().Stop();
            iTween.ColorTo(urchinOutline, iTween.Hash("a", 0f, "time", destroyTime, "easetype", iTween.EaseType.linear, "looptype", iTween.LoopType.none));
            LowerDistortionOvertimeScript dts = vortex.AddComponent <LowerDistortionOvertimeScript>();
            dts.speed = 25;
            Destroy(newParent, destroyTime);
        }
        //What to do special when the splitter dies.
        if (enemy == Enemy.Splitter)
        {
            GameObject sq      = Resources.Load("New Enemies/New Square Enemy") as GameObject;
            GameObject sq1     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
            GameObject sq2     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
            Vector2    sqForce = new Vector2((bulletPoint.y) * speed / 0.5f, (bulletPoint.x) * speed / 0.5f);
            sq1.GetComponent <Rigidbody2D>().AddForce(sqForce, ForceMode2D.Impulse);
            sq2.GetComponent <Rigidbody2D>().AddForce(-sqForce, ForceMode2D.Impulse);
        }
        //What to do special when the venn diagram dies.
        if (enemy == Enemy.VennDiagram)
        {
            GameObject sq      = Resources.Load("New Enemies/New Circle Enemy") as GameObject;
            GameObject sq1     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
            GameObject sq2     = (GameObject)Instantiate(sq, transform.position, Quaternion.identity);
            Vector2    sqForce = new Vector2((bulletPoint.y) * speed / 0.5f, (bulletPoint.x) * speed / 0.5f);
            sq1.GetComponent <Rigidbody2D>().AddForce(sqForce, ForceMode2D.Impulse);
            sq2.GetComponent <Rigidbody2D>().AddForce(-sqForce, ForceMode2D.Impulse);
        }

        //Spawn the coins.
        for (int i = 0; i < coins; i++)
        {
            Quaternion coinRotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f));
            Instantiate(coin, transform.position, coinRotation);
        }

        //Check for moneybag achievements.
        if (enemy == Enemy.MoneyCircle)
        {
            switch (bagColor)
            {
            case MoneyBag.Red:
                Game.CheckAchievements(32);
                break;

            case MoneyBag.Yellow:
                Game.CheckAchievements(34);
                break;

            case MoneyBag.Green:
                Game.CheckAchievements(35);
                break;

            case MoneyBag.Blue:
                Game.CheckAchievements(36);
                break;

            case MoneyBag.Purple:
                Game.CheckAchievements(37);
                break;

            case MoneyBag.White:
                Game.CheckAchievements(13);
                break;
            }
            Game.SaveGame(); //Save the achievements you just unlocked.
        }
        //Other one-line things to do on death.
        AudioClip a = killSounds[Random.Range(0, killSounds.Count)]; //Load a random death sound.

        Game.enemiesKilled++;                                        //Increase the amount of enemies you've killed by one in the statistics.
        PlaySound.NoLoop(a);                                         //Play the death sound.
        if (healthChance == 3)
        {
            Instantiate(heartPickup, transform.position, Quaternion.identity);
        }
        if (Game.ownsLasers && laserChance == 3 && healthChance != 3)
        {
            Instantiate(laserPickup, transform.position, Quaternion.identity);
        }
        breakInst = (GameObject)Instantiate(breakEffect, transform.position, Quaternion.identity);
        breakInst.transform.parent = Game.bulletHolder.transform;
        Destroy(breakInst, 5f);
        Destroy(gameObject);
    }