コード例 #1
0
    public void GoldUpdate()
    {
        string gold = BunnyStats.getGold().ToString();

        GoldNumA.GetComponent <Text>().text = gold;
        GoldNumH.GetComponent <Text>().text = gold;
    }
コード例 #2
0
    void Update()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Waterfall starts moving at specified camera offset
        if (Camera.main.transform.position.x >= transform.position.x - cameraWaterfallOffset)
        {
            Vector3 temp = transform.position;
            temp.y            -= waterfallSpeed;
            transform.position = temp;
        }

        //Destroy waterfall offscreen
        if (transform.position.x <= (Camera.main.transform.position.x - 10))
        {
            Destroy(this.gameObject);
        }

        //Play waterfall sound only once when it starts moving
        if (waterfallSoundPlaying == false &&
            Camera.main.transform.position.x >= transform.position.x - cameraWaterfallOffset)
        {
            StartCoroutine(playSound());
        }
    }
コード例 #3
0
    //Kill bunny method
    public IEnumerator KillBunny(BunnyStats bunny)
    {
        if (bunny != null)
        {
            //Create particle effect
            Transform clone = Instantiate(deathParticles, new Vector3(bunny.transform.position.x + (float)5.5, bunny.transform.position.y + (float)0.9, 0), bunny.transform.rotation) as Transform;

            //Play death sound
            deathSound.Play();

            //Destroy bunny and particle effect
            Destroy(bunny.gameObject);
            Destroy(clone.gameObject, 2f);

            if (bunnyLives > 0)
            {
                //Subtract a life, wait 2 seconds, then restart the current level
                yield return(new WaitForSeconds(2));

                bunnyLives -= 1;
                Application.LoadLevel(Application.loadedLevel);
                killingBunny = false;
            }
            else
            {
                //Game Over =(
                yield return(new WaitForSeconds(2));

                Score      = 0;
                retryLevel = Application.loadedLevel;
                Application.LoadLevel("Game Over");
                killingBunny = false;
            }
        }
    }
コード例 #4
0
ファイル: Spikes.cs プロジェクト: MarcFichtel/Unity3D-Games
 void FixedUpdate()
 {
     //Get bunny
     if (bunny == null)
     {
         bunny = gm.bunny;
     }
 }
コード例 #5
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     // Deletes bunnies if they touch the box
     if (collision.gameObject.tag == "Bunny")
     {
         int value = gameObject.GetComponent <TruckAlgo>().removeBunny(collision.gameObject.GetComponent <BunnyAI>().breed);
         //collision.gameObject.GetComponent<BunnyAI>().value
         BunnyStats.setGold(BunnyStats.getGold() + value);
         Destroy(collision.gameObject);
         BunnyStats.removeBunny(collision.gameObject.GetComponent <BunnyAI>().breed);
     }
 }
コード例 #6
0
    void Update()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Drop starts moving at specified camera offset, drop speed is slowed the higher its y position is
        if (Camera.main.transform.position.x >= transform.position.x - cameraDropOffset)
        {
            Vector3 temp = transform.position;
            temp.y            += dropSpeed;
            dropSpeed         -= 0.002f;
            transform.position = temp;
        }

        //Make drop bounce up and down between boundaries, reset sounds
        if (transform.position.y <= dropBoundaryBottom.position.y)
        {
            Destroy(this.gameObject);
        }

        //Make drop face up or down depending on drop speed
        Vector3 theScale = transform.localScale;

        if (dropSpeed >= 0)
        {
            theScale.y = -0.5f;
        }
        else if (dropSpeed < 0)
        {
            theScale.y = 0.5f;
        }
        transform.localScale = theScale;

        //Play sounds
        if (!dropSoundOneDone &&
            transform.position.y >= -4.6)
        {
            dropSoundOneDone = true;
            gm.dropSoundOne.Play();
        }
        if (dropSoundOneDone &&
            !dropSoundTwoDone &&
            transform.position.y <= -4.6)
        {
            dropSoundTwoDone = true;
            gm.dropSoundTwo.Play();
        }
    }
コード例 #7
0
ファイル: CarEnemy.cs プロジェクト: MarcFichtel/Unity3D-Games
    void FixedUpdate()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Destroy car if goal has been reached
        if (gm.trackEnd.goalReached)
        {
            carCol.enabled = false;
        }
    }
コード例 #8
0
ファイル: Boss3.cs プロジェクト: MarcFichtel/Unity3D-Games
    void FixedUpdate()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Black fadeout if boss is defeated
        if (bossDefeated == true)
        {
            alpha += Time.deltaTime / fadeTime;
        }
    }
コード例 #9
0
    void FixedUpdate()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Fadeout
        if (goalReached == true)
        {
            alpha += Time.deltaTime / fadeTime;
        }

        return;
    }
コード例 #10
0
    void Update()
    {
        //Get gamemaster
        if (gm == null)
        {
            gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster> ();
        }

        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Get rigidbody
        pineconeRB = GetComponent <Rigidbody2D> ();

        //Get position
        Vector3 temp = transform.position;

        //Pinecone falls if falling is true
        if (falling == true)
        {
            temp.y -= fallSpeed;
        }

        //Respawn one pinecone
        if (temp.y <= 0 &&
            respawning == false)
        {
            respawning = true;
            StartCoroutine(gm.respawnPinecone(startingPos));
        }

        //Destroy pinecone offscreen after the respawn coroutine finished
        if (temp.y <= -150)
        {
            Destroy(this.gameObject);
        }

        //Set new position
        transform.position = temp;
    }
コード例 #11
0
    //Search for bunny
    IEnumerator SearchForBunny()
    {
        //Store search result
        searchResult = GameObject.FindObjectOfType <BunnyStats> ();

        //If no bunny was found, keep looking
        if (searchResult == null)
        {
            yield return(new WaitForSeconds(1f));

            StartCoroutine(SearchForBunny());
        }
        else
        {
            //If bunny was found, stop looking
            bunny             = searchResult;
            searchingForBunny = false;
            return(false);
        }
    }
コード例 #12
0
    void Update()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Poop falls
        Vector3 temp = transform.position;

        temp.y            -= poopSpeed;
        transform.position = temp;

        //Destroy stalagtite offscreen
        if (transform.position.y <= -10)
        {
            Destroy(this.gameObject);
        }
    }
コード例 #13
0
    void FixedUpdate()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Apply air wind force, if bunny is inside wind zone and jumping, or ground wind force, if bunny is grounded
        if (insideWindzone &&
            bunny != null &&
            !bunny.grounded)
        {
            bunny.bunnyRB.AddForce(windForceInAir);
        }
        else if (insideWindzone &&
                 bunny != null &&
                 bunny.grounded)
        {
            bunny.bunnyRB.AddForce(windForceOnGround);
        }
    }
コード例 #14
0
    void FixedUpdate()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Get current position
        Vector3 switchPos    = Switch.transform.position;
        Vector2 boxcolOffset = boxcol.offset;

        //Move switch down a bit, if it was pressed
        if (switchPressed == true)
        {
            switchPos.y     = pressedSwitchPos;
            boxcolOffset.y -= 0.45f;
        }

        //Apply new position
        Switch.transform.position = switchPos;
        boxcol.offset             = boxcolOffset;
    }
コード例 #15
0
ファイル: Boss1.cs プロジェクト: MarcFichtel/Unity3D-Games
    void Update()
    {
        //Get bunny
        if (bunny == null)
        {
            bunny = gm.bunny;
        }

        //Create boss hurt timer
        bossHurtTimer -= Time.deltaTime;
        if (bossHurtTimer <= 0)
        {
            bossIsHurt = false;
        }

        //Get boss position and scale
        Vector3 bossPos   = transform.position;
        Vector3 bossScale = transform.localScale;

        //Get current X position
        currentX = bossPos.x;

        //Flip the sprire's X scale if the last X position is bigger than the current one
        if (currentX > lastX)
        {
            bossScale.x = 1;
        }
        else if (lastX > currentX)
        {
            bossScale.x = -1;
        }
        transform.localScale = bossScale;

        //Create hovering behaviour
        if (hovering == true &&
            bossHealth > 0)
        {
            //Set animator and colliders
            bossAnimator.SetBool("hover", true);
            boxCol.enabled = false;
            cirCol.enabled = true;

            //Make bird chase the bunny
            if (bunny != null)
            {
                transform.position = Vector2.MoveTowards(bossPos, bunny.transform.position, bossSpeedHover * Time.deltaTime);
            }

            //Create zooming behaviour
        }
        else if (bossHealth > 0)
        {
            //Set animator
            bossAnimator.SetBool("hover", false);

            //Switch colliders
            boxCol.enabled = true;
            cirCol.enabled = false;

            //Move boss at zoom speed
            transform.position += new Vector3(bossSpeedZoom, 0, 0);

            //Turn boss around if it flies too far, its heights is either top or bottom level
            if (transform.position.x >= 50)
            {
                bossSpeedZoom *= -1;
                gm.boss1zoomSound.Play();
                transform.position = new Vector3(50, Random.value < 0.5f ? 3 : -3);
            }
            if (transform.position.x <= -50)
            {
                bossSpeedZoom *= -1;
                gm.boss1zoomSound.Play();
                transform.position = new Vector3(-50, Random.value < 0.5f ? 3 : -3);
            }
        }

        //Create boss defeat behaviour
        if (bossHealth <= 0 &&
            !bossDefeated)
        {
            bossDefeated = true;
            StartCoroutine(levelComplete());
        }

        //Start hurtFlicker if its not already in progress and boss is hurt, else revert to normal color
        if (bossIsHurt == true &&
            blinking == false)
        {
            blinking = true;
            StartCoroutine(hurtFlicker());
        }
        else
        {
            spriteRenderer.color = bossColor;
        }
    }
コード例 #16
0
    public void BunnyUpdate()
    {
        string bunnies = BunnyStats.getBunnyCount().ToString();

        BunnyNumA.GetComponent <Text>().text = bunnies;
        BunnyNumH.GetComponent <Text>().text = bunnies;
        string bunniesWh = BunnyStats.getWhiteBunnyCount().ToString();

        BunnyWhite.GetComponent <Text>().text = bunniesWh;
        string bunniesBl = BunnyStats.getBlackBunnyCount().ToString();

        BunnyBlack.GetComponent <Text>().text = bunniesBl;
        string bunniesGr = BunnyStats.getGrayBunnyCount().ToString();

        BunnyGray.GetComponent <Text>().text = bunniesGr;
        string bunniesRe = BunnyStats.getRedBunnyCount().ToString();

        BunneyRed.GetComponent <Text>().text = bunniesRe;
        string bunniesBlu = BunnyStats.getBlueBunnyCount().ToString();

        BunneyBlue.GetComponent <Text>().text = bunniesBlu;
        string bunniesYe = BunnyStats.getYellowBunnyCount().ToString();

        BunneyYellow.GetComponent <Text>().text = bunniesYe;
        string bunniesBr = BunnyStats.getBrownBunnyCount().ToString();

        BunnyBrown.GetComponent <Text>().text = bunniesBr;
        string bunniesPu = BunnyStats.getPurpleBunnyCount().ToString();

        BunnyPurple.GetComponent <Text>().text = bunniesPu;
        string bunniesPi = BunnyStats.getPinkBunnyCount().ToString();

        BunnyPink.GetComponent <Text>().text = bunniesPi;
        string bunniesGre = BunnyStats.getGreenBunnyCount().ToString();

        BunnyGreen.GetComponent <Text>().text = bunniesGre;
        string bunniesOr = BunnyStats.getOrangeBunnyCount().ToString();

        BunnyOrange.GetComponent <Text>().text = bunniesOr;
        string bunniesCr = BunnyStats.getCrystalBunnyCount().ToString();

        BunnyCrystal.GetComponent <Text>().text = bunniesCr;
        string bunniesCy = BunnyStats.getCyanBunnyCount().ToString();

        BunnyCyan.GetComponent <Text>().text = bunniesCy;
        string bunniesGo = BunnyStats.getGoldenBunnyCount().ToString();

        BunnyGolden.GetComponent <Text>().text = bunniesGo;
        string bunniesQz = BunnyStats.getRoseQuartzBunnyCount().ToString();

        BunnyRoseQuartz.GetComponent <Text>().text = bunniesQz;
        string bunniesAd = BunnyStats.getAdventurineBunnyCount().ToString();

        BunnyAdventurine.GetComponent <Text>().text = bunniesAd;
        string bunniesTo = BunnyStats.getTourmalineBunnyCount().ToString();

        BunnyTourmaline.GetComponent <Text>().text = bunniesTo;
        string bunniesSi = BunnyStats.getSilverBunnyCount().ToString();

        BunnySilver.GetComponent <Text>().text = bunniesSi;
        string bunniesEm = BunnyStats.getEmeraldBunnyCount().ToString();

        BunnyEmerald.GetComponent <Text>().text = bunniesEm;
        string bunniesAm = BunnyStats.getAmethystBunnyCount().ToString();

        BunnyAmathyst.GetComponent <Text>().text = bunniesAm;
    }
コード例 #17
0
    public void TaskUpdate()
    {
        string task = BunnyStats.getCompletedTask().ToString();

        CompletedTasks.GetComponent <Text>().text = task;
    }