Exemple #1
0
        public Student[] SortByNumber()
        {
            biggerThan = new BiggerThan(Student.BiggerThanNumber);
            Sort();

            return(students);
        }
Exemple #2
0
 public Student[] SortByAverageGrade()
 {
     biggerThan = new BiggerThan(Student.BiggerThanAverageGrade);
     Sort();
     return(students);
 }
Exemple #3
0
 public Student[] SortByCredit()
 {
     biggerThan = new BiggerThan(Student.BiggerThanCredit);
     Sort();
     return(students);
 }
Exemple #4
0
 public Student[] SortByName()
 {
     biggerThan = new BiggerThan(Student.BiggerThanName);
     Sort();
     return(students);
 }
    // OLD SHOOT:
    //	if  (touch.position.y > desiredHeight) {
    //

    //	if (LoadingBar.fillAmount == 1) {

    //		GameObject bullet01 = (GameObject)Instantiate (PlayerBullet);
    //		bullet01.transform.position = bulletPosition.transform.position;  //set the bullet initial position
    //		LoadingBar.fillAmount = 0;
    //	}


    void OnTriggerEnter2D(Collider2D other)
    {
        if (TutorialMode == false)
        {
            NewExperience += 5;

            if (LoadingBar.fillAmount == 1 && GunHasBeenShown == false)
            {
                GunIsReady.SetActive(true);
                GunHasBeenShown = true;
                Invoke("SetOff", 2f);
            }
        }

        //if (NewExperience > 14) {
        //	HowToPlay.SetActive (false);
        //}


        if (other.gameObject.tag == "Surprise")
        {
            if (InfinityMode == false)
            {
                //if (TutorialMode == false) {

                //Surprise randomBox = other.gameObject.GetComponent<Surprise> ();

                //summa = summa + randomBox.summaBox;
                //summa = randomBox.summaBox;

                //} else {
                //	summa = summa + Random.Range (1, 100);
                //}

                if (Random.value < 0.5f)
                {
                    summa = summa * 2;
                }
                else
                {
                    summa = summa / 4;
                }
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalSurprise", PlayerPrefs.GetInt("TotalSurprise") + 1);
            source.PlayOneShot(SurpriseSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }


        if (other.gameObject.tag == "GronRandom")
        {
            BoxRandom randomBox = other.gameObject.GetComponent <BoxRandom>();

            summa = summa + randomBox.summaBox;

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalGreen", PlayerPrefs.GetInt("TotalGreen") + 1);
            source.PlayOneShot(GreenSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "GreenPlus")
        {
            BoxPlus randomBox = other.gameObject.GetComponent <BoxPlus>();

            summa = summa + randomBox.summaBox;

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalGreen", PlayerPrefs.GetInt("TotalGreen") + 1);
            source.PlayOneShot(GreenSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }


        if (other.gameObject.tag == "GreenMultiply")
        {
            BoxMultiply randomBox = other.gameObject.GetComponent <BoxMultiply>();

            summa = summa + randomBox.summaBox;

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalGreen", PlayerPrefs.GetInt("TotalGreen") + 1);
            source.PlayOneShot(GreenSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "GreenExponent")
        {
            BoxExponent randomBox = other.gameObject.GetComponent <BoxExponent>();
            summa = summa + randomBox.summaBox;

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalGreen", PlayerPrefs.GetInt("TotalGreen") + 1);
            source.PlayOneShot(GreenSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }


        if (other.gameObject.tag == "RodRandom")
        {
            if (InfinityMode == false)
            {
                BoxRandom randomBox      = other.gameObject.GetComponent <BoxRandom> ();
                float     sumBeforeDeath = summa;
                summa = summa - randomBox.summaBox;
                if (summa < 0)
                {
                    DeathExplanation.text = sumBeforeDeath + " - " + randomBox.summaBox + " = " + summa.ToString();
                }
            }
            else
            {
                BoxRandom randomBox = other.gameObject.GetComponent <BoxRandom> ();
                summa = summa + randomBox.summaBox;
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalRed", PlayerPrefs.GetInt("TotalRed") + 1);
            source.PlayOneShot(RedSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "RedPlus")
        {
            if (InfinityMode == false)
            {
                BoxPlus randomBox      = other.gameObject.GetComponent <BoxPlus> ();
                float   sumBeforeDeath = summa;
                summa = summa - randomBox.summaBox;
                if (summa < 0)
                {
                    DeathExplanation.text = sumBeforeDeath + " - (" + randomBox.summaX + "+" + randomBox.summaY + ") = " + summa.ToString();
                }
            }
            else
            {
                BoxPlus randomBox = other.gameObject.GetComponent <BoxPlus> ();
                summa = summa + randomBox.summaBox;
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalRed", PlayerPrefs.GetInt("TotalRed") + 1);
            source.PlayOneShot(RedSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }


        if (other.gameObject.tag == "RedMultiply")
        {
            if (InfinityMode == false)
            {
                BoxMultiply randomBox      = other.gameObject.GetComponent <BoxMultiply> ();
                float       sumBeforeDeath = summa;
                summa = summa - randomBox.summaBox;
                if (summa < 0)
                {
                    DeathExplanation.text = sumBeforeDeath + " - (" + randomBox.summaX + "×" + randomBox.summaY + ") = " + summa.ToString();
                    // här behövs ingen särskild formatering då max är 99x99
                }
            }
            else
            {
                BoxMultiply randomBox = other.gameObject.GetComponent <BoxMultiply> ();
                summa = summa + randomBox.summaBox;
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalRed", PlayerPrefs.GetInt("TotalRed") + 1);
            source.PlayOneShot(RedSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "RedExponent")
        {
            if (InfinityMode == false)
            {
                BoxExponent randomBox      = other.gameObject.GetComponent <BoxExponent> ();
                float       sumBeforeDeath = summa;
                summa = summa - randomBox.summaBox;
                if (summa < 0)
                {
                    if (sumBeforeDeath < 1000000)
                    {
                        DeathExplanation.text = sumBeforeDeath + " - (" + randomBox.summaX + "^" + randomBox.summaY + ") = " + summa.ToString();
                    }
                    else
                    {
                        DeathExplanation.text = (sumBeforeDeath / 1000000).ToString("0.###") + "M" + " - (" + randomBox.summaX + "^" + randomBox.summaY + ") = " + (summa / 1000000).ToString("0.###") + "M";
                    }
                }
            }
            else
            {
                BoxExponent randomBox = other.gameObject.GetComponent <BoxExponent> ();
                summa = summa + randomBox.summaBox;
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalRed", PlayerPrefs.GetInt("TotalRed") + 1);
            source.PlayOneShot(RedSFX, 0.7F);
            SetCountText();
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "OrangeRandom")
        {
            if (InfinityMode == false)
            {
                OrangeBox randomBox = other.gameObject.GetComponent <OrangeBox> ();
                dividedBy = randomBox.summaBox;

                // if (summa % dividedBy == 0) { //om det älbart med summan påen
                summa = summa / dividedBy;                         //dividera med summan påen

                //	}    else {
                //	toMenu ();
                //	}
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalOrange", PlayerPrefs.GetInt("TotalOrange") + 1);
            Destroy(other.gameObject);
            source.PlayOneShot(OrangeSFX, 0.7F);
            SetCountText();
        }
        if (other.gameObject.tag == "BiggerThan")
        {
            if (InfinityMode == false)
            {
                BiggerThan randomBox      = other.gameObject.GetComponent <BiggerThan> ();
                float      sumBeforeDeath = summa;

                if (summa > randomBox.summaBox)
                {
                    summa = (float)(summa * 1.25);
                    source.PlayOneShot(BigSmallSFX, 0.7F);
                }
                else
                {
                    DeathExplanation.text = sumBeforeDeath + " IS NOT > " + randomBox.summaX + "×" + randomBox.summaY + "\n" + randomBox.summaX + "×" + randomBox.summaY + " = " + randomBox.summaBox.ToString();
                    toMenu();
                }
            }

            if (InfinityMode == true)
            {
                summa = (float)(summa * 1.1);
            }

            PlayerPrefs.SetInt("TotalBigger", PlayerPrefs.GetInt("TotalBigger") + 1);
            Destroy(other.gameObject);
            SetCountText();

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
        }
        if (other.gameObject.tag == "BiggerThanExponent")
        {
            if (InfinityMode == false)
            {
                BiggerThanExponent randomBox = other.gameObject.GetComponent <BiggerThanExponent> ();
                float sumBeforeDeath         = summa;

                if (summa > randomBox.summaBox)
                {
                    summa = (float)(summa * 1.1);
                    source.PlayOneShot(BigSmallSFX, 0.7F);
                }
                else
                {
                    if (sumBeforeDeath < 1000000)
                    {
                        DeathExplanation.text = sumBeforeDeath + " IS NOT > " + randomBox.summaX + "^" + randomBox.summaY + "\n" + randomBox.summaX + "^" + randomBox.summaY + " = " + randomBox.summaBox.ToString();
                    }
                    else
                    {
                        DeathExplanation.text = (sumBeforeDeath / 1000000).ToString("0.###") + "M" + " IS NOT > " + randomBox.summaX + "^" + randomBox.summaY + "\n" + randomBox.summaX + "^" + randomBox.summaY + " = " + (randomBox.summaBox / 1000000).ToString("0.###") + "M";
                    }
                    toMenu();
                }
            }

            if (InfinityMode == true)
            {
                summa = (float)(summa * 1.1);
            }


            PlayerPrefs.SetInt("TotalBigger", PlayerPrefs.GetInt("TotalBigger") + 1);
            Destroy(other.gameObject);
            SetCountText();

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
        }


        if (other.gameObject.tag == "SmallerThan")
        {
            if (InfinityMode == false)
            {
                SmallerThan randomBox      = other.gameObject.GetComponent <SmallerThan> ();
                float       sumBeforeDeath = summa;

                if (summa < randomBox.summaBox)
                {
                    summa = (float)(summa * 1.1);
                    source.PlayOneShot(BigSmallSFX, 0.7F);
                }
                else
                {
                    DeathExplanation.text = sumBeforeDeath + " IS NOT < " + randomBox.summaX + "×" + randomBox.summaY + "\n" + randomBox.summaX + "×" + randomBox.summaY + " = " + randomBox.summaBox.ToString();
                    toMenu();
                }
            }

            if (InfinityMode == true)
            {
                summa = (float)(summa * 1.1);
            }

            PlayerPrefs.SetInt("TotalSmaller", PlayerPrefs.GetInt("TotalSmaller") + 1);
            Destroy(other.gameObject);
            SetCountText();

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
        }
        if (other.gameObject.tag == "SmallerThanExponent")
        {
            if (InfinityMode == false)
            {
                SmallerThanExponent randomBox = other.gameObject.GetComponent <SmallerThanExponent> ();
                float sumBeforeDeath          = summa;

                if (summa < randomBox.summaBox)
                {
                    summa = (float)(summa * 1.1);
                    source.PlayOneShot(BigSmallSFX, 0.7F);
                }
                else
                {
                    if (sumBeforeDeath < 1000000)
                    {
                        DeathExplanation.text = sumBeforeDeath + " IS NOT < " + randomBox.summaX + "^" + randomBox.summaY + "\n" + randomBox.summaX + "^" + randomBox.summaY + " = " + randomBox.summaBox.ToString();
                    }
                    else
                    {
                        DeathExplanation.text = (sumBeforeDeath / 1000000).ToString("0.###") + "M" + " IS NOT < " + randomBox.summaX + "^" + randomBox.summaY + "\n" + randomBox.summaX + "^" + randomBox.summaY + " = " + (randomBox.summaBox / 1000000).ToString("0.###") + "M";
                    }
                    toMenu();
                }
            }

            if (InfinityMode == true)
            {
                summa = (float)(summa * 1.1);
            }

            PlayerPrefs.SetInt("TotalSmaller", PlayerPrefs.GetInt("TotalSmaller") + 1);
            Destroy(other.gameObject);
            SetCountText();

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
        }



        if (other.gameObject.CompareTag("BlueRandom"))
        {
            BlueBox randomBox = other.gameObject.GetComponent <BlueBox> ();
            summa = summa * randomBox.summaBox;             //gåa med siffran

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }

            PlayerPrefs.SetInt("TotalBlue", PlayerPrefs.GetInt("TotalBlue") + 1);
            Destroy(other.gameObject);
            source.PlayOneShot(BlueSFX, 0.7F);
            SetCountText();
        }

        if (other.gameObject.CompareTag("Black"))
        {
            Destroy(other.gameObject);
            // eventuellt nå ljud
        }
        if (other.gameObject.CompareTag("Prim"))
        {
            other.gameObject.SetActive(false);
            if (summa == 0 || summa == 1)
            {
                toMenu();
            }
            else
            {
                for (int a = 2; a <= summa / 2; a++)
                {
                    if (summa % a == 0)
                    {
                        toMenu();
                    }
                }
                summa = summa * 3;                 //trippla

                if (LoadingBar.fillAmount <= 1)
                {
                    LoadingBar.fillAmount += 0.05f;
                }

                SetCountText();
            }
        }



        if (other.gameObject.tag == "Reverse")
        {
            RandomTimer = Random.Range(4, 7);

            summa = (float)(summa * 1.25);

            if (InfinityMode == false)
            {
                if (ReverseMode == false)
                {
                    ReverseMode = true;
                    Reverse.SetActive(true);
                }

                ReverseTimer = 0;
                //	if (ReverseMode == true) {
                //			ReverseMode = false;
                //			Reverse.SetActive (false);
                //		}
            }

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
            PlayerPrefs.SetInt("TotalReverse", PlayerPrefs.GetInt("TotalReverse") + 1);
            source.PlayOneShot(ReverseSFX, 0.7F);
            Destroy(other.gameObject);
        }

        if (other.gameObject.tag == "Infinity")
        {
            if (InfinityMode == false)
            {
                InfinityMode = true;
                ReverseMode  = false;
                Reverse.SetActive(false);
                Infinity.SetActive(true);
            }

            InfinityTimer = 0;

            if (LoadingBar.fillAmount <= 1)
            {
                LoadingBar.fillAmount += 0.05f;
            }
            Destroy(other.gameObject);
        }



        if (summa < 0)         // if our player is dead
        {
            toMenu();
            // Hä jag ocksåöud och döimering, sedan vä-2 sek, sedan en restart/till main menu med touch-knappar
        }



        InfinityTimer += 1;

        if (InfinityTimer == 6)
        {
            InfinityMode = false;
            Infinity.SetActive(false);
        }

        ReverseTimer += 1;


        if (ReverseTimer == RandomTimer)
        {
            ReverseMode = false;
            Reverse.SetActive(false);
        }
    }