Beispiel #1
0
    // Update is called once per frame
    public void Stop()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[1]);

        GamePlay.Instance.GameStatus = GameState.Tutorial;
        gameObject.SetActive(false);
    }
Beispiel #2
0
    IEnumerator MoveToPlace(Transform place)
    {
        transform.parent = place;
        AnimationCurve curveX = new AnimationCurve(new Keyframe(0, transform.localPosition.x), new Keyframe(1, 0));
        AnimationCurve curveY = new AnimationCurve(new Keyframe(0, transform.localPosition.y), new Keyframe(1, 0));

        curveY.AddKey(0.5f, transform.localPosition.y + 3);
        float   startTime   = Time.time;
        Vector3 startPos    = transform.localPosition;
        float   speed       = Random.Range(0.4f, 0.6f);
        float   distCovered = 0;

        while (distCovered < 1)
        {
            if (distCovered > 0.8f && distCovered < 0.81f)
            {
                SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[0]);
            }
            distCovered             = (Time.time - startTime) * speed;
            transform.localPosition = new Vector3(curveX.Evaluate(distCovered), curveY.Evaluate(distCovered), 0);

            yield return(new WaitForEndOfFrame());
        }
        GetComponent <CircleCollider2D>().isTrigger = false;
    }
Beispiel #3
0
    void ShowGameOver()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().gameOver);

        GameObject.Find("Canvas").transform.Find("MenuGameOver").gameObject.SetActive(true);
        gameObject.SetActive(false);
    }
Beispiel #4
0
    void DestroySingle(GameObject obj, float speed = 0.1f)
    {
        Camera.main.GetComponent <MainScript>().bounceCounter = 0;
        int scoreCounter = 0;
        int rate         = 0;
        int soundPool    = 0;

        if (obj.name.IndexOf("ball") == 0)
        {
            obj.layer = 0;
        }
        obj.GetComponent <ball>().growUp();
        soundPool++;

        if (obj.tag == "light")
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().spark);
            obj.GetComponent <ball>().DestroyLine();
        }

        if (scoreCounter > 3)
        {
            rate         += 10;
            scoreCounter += rate;
        }
        scoreCounter += 10;
        obj.GetComponent <ball>().Destroyed = true;
        MainScript.Instance.PopupScore(scoreCounter, transform.position);
    }
Beispiel #5
0
    public void CloseMenu()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
        if (gameObject.name == "MenuPreGameOver")
        {
            ShowGameOver();
        }
        if (gameObject.name == "MenuComplete")
        {
            Application.LoadLevel("Map");
        }
        if (gameObject.name == "MenuGameOver")
        {
            Application.LoadLevel("Map");
        }

        if (Application.loadedLevelName == "Game" || Application.loadedLevelName == "game")
        {
            if (GamePlay.Instance.GameStatus == GameState.Pause)
            {
                GamePlay.Instance.GameStatus = GameState.WaitAfterClose;
            }
        }
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[1]);

        gameObject.SetActive(false);
    }
Beispiel #6
0
 public void BuyLifeShop()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     if (InitScript.Lifes < InitScript.CapOfLife)
     {
         GameObject.Find("Canvas").transform.Find("LiveShop").gameObject.SetActive(true);
     }
 }
Beispiel #7
0
 public void ShowFirework()
 {
     fireworks++;
     if (fireworks <= 2)
     {
         SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().hit);
     }
 }
Beispiel #8
0
    void OnEnable()
    {
        //这里对平台做个判断,Windows平台单独处理一下分辨率
#if UNITY_STANDALONE_WIN
        Screen.SetResolution(360, 540, false);
#endif

        if (PlayOnEnable)
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[0]);
        }
        if (name == "MenuPlay")
        {
            for (int i = 1; i <= 3; i++)
            {
                transform.Find("Image").Find("Star" + i).gameObject.SetActive(false);
            }
            int stars = PlayerPrefs.GetInt(string.Format("Level.{0:000}.StarsCount", PlayerPrefs.GetInt("OpenLevel")), 0);
            if (stars > 0)
            {
                for (int i = 1; i <= stars; i++)
                {
                    transform.Find("Image").Find("Star" + i).gameObject.SetActive(true);
                }
            }
            else
            {
                for (int i = 1; i <= 3; i++)
                {
                    transform.Find("Image").Find("Star" + i).gameObject.SetActive(false);
                }
            }
        }

        if (name == "Settings" || name == "MenuPause")
        {
            if (PlayerPrefs.GetInt("Sound") == 0)
            {
                transform.Find("Image/Sound/SoundOff").gameObject.SetActive(true);
            }
            else
            {
                transform.Find("Image/Sound/SoundOff").gameObject.SetActive(false);
            }

            if (PlayerPrefs.GetInt("Music") == 0)
            {
                transform.Find("Image/Music/MusicOff").gameObject.SetActive(true);
            }
            else
            {
                transform.Find("Image/Music/MusicOff").gameObject.SetActive(false);
            }
        }
    }
Beispiel #9
0
    IEnumerator MenuComplete()
    {
        for (int i = 1; i <= MainScript.Instance.stars; i++)
        {
            //  SoundBase.Instance.audio.PlayOneShot( SoundBase.Instance.scoringStar );
            transform.Find("Image").Find("Star" + i).gameObject.SetActive(true);
            yield return(new WaitForSeconds(0.5f));

            SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().hit);
        }
    }
 public void Rotate(Vector3 _dir, Vector3 _ballPos)
 {
     _dir  = MainScript.Instance.boxCatapult.GetComponent <Grid>().transform.position;
     angle = Vector2.Angle(_dir - _ballPos, _ballPos - transform.position) / 4f;
     if (transform.position.x < _ballPos.x)
     {
         angle *= -1;
     }
     newRot   = transform.rotation * Quaternion.AngleAxis(angle, Vector3.back);
     addForce = true;
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().kreakWheel);
 }
Beispiel #11
0
 public void ShowSettings(GameObject menuSettings)
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     if (!menuSettings.activeSelf)
     {
         menuSettings.SetActive(true);
         //           menuSettings.GetComponent<SequencePlayer>().Play();
     }
     else
     {
         menuSettings.SetActive(false);
     }
 }
Beispiel #12
0
 public void BuyBoost(BoostType boostType, int price)
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     if (InitScript.Gems >= price)
     {
         InitScript.Instance.BuyBoost(boostType, 1, price);
         InitScript.Instance.SpendBoost(boostType);
         CloseMenu();
     }
     else
     {
         BuyGames();
     }
 }
Beispiel #13
0
 public void BuyLife(GameObject button)
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     if (InitScript.Gems >= int.Parse(button.transform.Find("Price").GetComponent <Text>().text.Replace("¥", "")))
     {
         InitScript.Instance.SpendGems(int.Parse(button.transform.Find("Price").GetComponent <Text>().text.Replace("¥", "")));
         InitScript.Instance.RestoreLifes();
         CloseMenu();
     }
     else
     {
         GameObject.Find("Canvas").transform.Find("GemsShop").gameObject.SetActive(true);
     }
 }
Beispiel #14
0
    public void ChangeBoost()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[0]);
        Grid.waitForAnim = true;
        GameObject ball1 = boxSecond.GetComponent <Grid>().Busy;

        boxCatapult.GetComponent <Grid>().Busy.GetComponent <ball>().newBall = false;
        iTween.MoveTo(boxSecond.GetComponent <Grid>().Busy, iTween.Hash("position", boxCatapult.transform.position, "time", 0.3, "easetype", iTween.EaseType.linear, "onComplete", "newBall"));
        iTween.MoveTo(boxCatapult.GetComponent <Grid>().Busy, iTween.Hash("position", boxSecond.transform.position, "time", 0.3, "easetype", iTween.EaseType.linear));
        boxSecond.GetComponent <Grid>().Busy   = boxCatapult.GetComponent <Grid>().Busy;
        boxCatapult.GetComponent <Grid>().Busy = ball1;
        //		boxFirst.GetComponent<Grid>().Busy = boxSecond.GetComponent<Grid>().Busy;
        //boxCatapult.GetComponent<Grid>().BounceFrom(boxFirst);
    }
Beispiel #15
0
    void PlaySplash(Vector2 pos)
    {
        StartCoroutine(SoundsCounter());
        if (MainScript.Instance.potSounds < 4)
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().pops);
        }

        GameObject splash = (GameObject)Instantiate(splashPrefab, transform.position + Vector3.up * 0.9f + Vector3.left * 0.35f, Quaternion.identity);

        Destroy(splash, 2f);

        MainScript.Instance.PopupScore(score * MainScript.doubleScore, transform.position + Vector3.up);
    }
Beispiel #16
0
    IEnumerator LoseAction()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().OutOfMoves);
        GameObject.Find("Canvas").transform.Find("OutOfMoves").gameObject.SetActive(true);
        yield return(new WaitForSeconds(1.5f));

        GameObject.Find("Canvas").transform.Find("OutOfMoves").gameObject.SetActive(false);
        if (LevelData.LimitAmount <= 0)
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().gameOver);
            GameObject.Find("Canvas").transform.Find("MenuGameOver").gameObject.SetActive(true);
        }
        // GameObject.Find( "Canvas" ).transform.Find( "MenuPreGameOver" ).gameObject.SetActive( true );
        yield return(new WaitForSeconds(0.1f));
    }
Beispiel #17
0
 public void FireBallBoost()
 {
     if (GamePlay.Instance.GameStatus != GameState.Playing)
     {
         return;
     }
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     if (InitScript.Instance.FireBallBoost > 0)
     {
         if (GamePlay.Instance.GameStatus == GameState.Playing)
         {
             InitScript.Instance.SpendBoost(BoostType.FireBallBoost);
         }
     }
     else
     {
         OpenBoostShop(BoostType.FireBallBoost);
     }
 }
Beispiel #18
0
    public void SoundOff(GameObject Off)
    {
        if (!Off.activeSelf)
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().volume = 0;
            InitScript.sound = false;

            Off.SetActive(true);
        }
        else
        {
            SoundBase.GetInstance().GetComponent <AudioSource>().volume = 1;
            InitScript.sound = true;

            Off.SetActive(false);
        }
        PlayerPrefs.SetInt("Sound", (int)SoundBase.GetInstance().GetComponent <AudioSource>().volume);
        PlayerPrefs.Save();
    }
Beispiel #19
0
    /// <summary>
    /// 当各种界面上的和Play相关的按钮按下时调用的方法
    /// </summary>
    public void Play()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
        //根据绑定的不同GameObejct有不同的功能
        if (gameObject.name == "MenuPreGameOver")
        {
            if (InitScript.Gems >= 12)
            {
                InitScript.Instance.SpendGems(12);
                LevelData.LimitAmount       += 12;
                GamePlay.Instance.GameStatus = GameState.WaitAfterClose;
                gameObject.SetActive(false);
            }
            else
            {
                BuyGames();
            }
        }
        else if (gameObject.name == "MenuGameOver")
        {
            Application.LoadLevel("Map");
        }
        else if (gameObject.name == "MenuPlay")
        {
            Application.LoadLevel("Game");
            if (InitScript.Lifes > 0)
            {
                InitScript.Instance.SpendLife(1);

                Application.LoadLevel("Game");
            }
            else
            {
                BuyLifeShop();
            }
        }
        //如果按下Play按钮,则加载Map场景
        else if (gameObject.name == "PlayMain")
        {
            Application.LoadLevel("Map");
        }
    }
Beispiel #20
0
        public void Awake()
        {
            Instance = this;
            if (Application.loadedLevelName == "Map")
            {
                if (GameObject.Find("Canvas").transform.Find("MenuPlay").gameObject.activeSelf)
                {
                    GameObject.Find("Canvas").transform.Find("MenuPlay").gameObject.SetActive(false);
                }
            }
            RestLifeTimer = PlayerPrefs.GetFloat("RestLifeTimer");

            //			if(InitScript.DateOfExit == "")
            //			print(InitScript.DateOfExit );
            DateOfExit = PlayerPrefs.GetString("DateOfExit", "");

            Gems  = PlayerPrefs.GetInt("Gems");
            Lifes = PlayerPrefs.GetInt("Lifes");

            //当游戏第一次运行时候
            if (PlayerPrefs.GetInt("Lauched") == 0)
            {
                FirstTime = true;
                Lifes     = CapOfLife;
                Gems      = 5;
                //利用PlayerPrefs存储数据
                PlayerPrefs.SetInt("Gems", Gems);
                PlayerPrefs.SetInt("Lifes", Lifes);
                PlayerPrefs.SetInt("Lauched", 1);
                PlayerPrefs.SetInt("Music", 1);
                PlayerPrefs.SetInt("Sound", 1);
                PlayerPrefs.Save();
            }

            GameObject.Find("Music").GetComponent <AudioSource>().volume = PlayerPrefs.GetInt("Music");
            SoundBase.GetInstance().GetComponent <AudioSource>().volume  = PlayerPrefs.GetInt("Sound");

            ReloadBoosts();

            boostPurchased = false;
        }
Beispiel #21
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.collider.name.Contains("ball"))
     {
         StartCoroutine(SoundsCounter());
         if (MainScript.Instance.bugSounds < 5)
         {
             SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().bug);
         }
         col.collider.GetComponent <ball>().HitBug1++;
         MainScript.Instance.PopupScore(col.collider.GetComponent <ball>().HitBug1 *score *(color + 1), transform.position);
         StartCoroutine(StartAnim(col.collider.transform.position));
         if (color == 2)
         {
             SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().combo[5]);
             ChangeColor(1);
             GameObject ball = creatorBall.Instance.createBall(transform.position + Vector3.up * 1, BallColor.random, false);
             ball.GetComponent <ball>().StartFall();
         }
     }
 }
Beispiel #22
0
    IEnumerator MoveOutCor()
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().bugDissapier);

        AnimationCurve curveX = new AnimationCurve(new Keyframe(0, transform.localPosition.x), new Keyframe(1, 0));
        AnimationCurve curveY = new AnimationCurve(new Keyframe(0, transform.localPosition.y), new Keyframe(1, 10));

        curveY.AddKey(0.5f, transform.localPosition.y + 3);
        float   startTime   = Time.time;
        Vector3 startPos    = transform.localPosition;
        float   speed       = 0.6f;
        float   distCovered = 0;

        while (distCovered < 1)
        {
            distCovered             = (Time.time - startTime) * speed;
            transform.localPosition = new Vector3(transform.localPosition.x, curveY.Evaluate(distCovered), 0);

            yield return(new WaitForEndOfFrame());
        }
        transform.parent = null;
        Destroy(gameObject);
    }
Beispiel #23
0
    public void Buy(GameObject pack)
    {
        SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
        if (pack.name == "Pack1")
        {
            InitScript.waitedPurchaseGems = int.Parse(pack.transform.Find("Count").GetComponent <Text>().text.Replace("x ", ""));
        }

        if (pack.name == "Pack2")
        {
            InitScript.waitedPurchaseGems = int.Parse(pack.transform.Find("Count").GetComponent <Text>().text.Replace("x ", ""));
        }
        if (pack.name == "Pack3")
        {
            InitScript.waitedPurchaseGems = int.Parse(pack.transform.Find("Count").GetComponent <Text>().text.Replace("x ", ""));
        }
        if (pack.name == "Pack4")
        {
            InitScript.waitedPurchaseGems = int.Parse(pack.transform.Find("Count").GetComponent <Text>().text.Replace("x ", ""));
        }
        InitScript.Instance.PurchaseSucceded();
        CloseMenu();
    }
Beispiel #24
0
 public void Hit()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().hit);
 }
Beispiel #25
0
 public void PlaySoundButton()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
 }
Beispiel #26
0
 public void OpenBoostShop(BoostType boosType)
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     GameObject.Find("Canvas").transform.Find("BoostShop").gameObject.GetComponent <BoostShop>().SetBoost(boosType);
 }
Beispiel #27
0
    // Update is called once per frame
    void Update()
    {
        if (name == "Moves")
        {
            label.text = "" + LevelData.LimitAmount;
            if (LevelData.LimitAmount <= 5 && GamePlay.Instance.GameStatus == GameState.Playing)
            {
                label.color = Color.red;
                if (!GetComponent <Animation>().isPlaying)
                {
                    GetComponent <Animation>().Play();
                    SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().alert);
                }
            }
        }
        if (name == "Scores" || name == "Score")
        {
            label.text = "" + MainScript.Score;
        }
        if (name == "Level")
        {
            label.text = "" + PlayerPrefs.GetInt("OpenLevel");
        }
        if (name == "Target")
        {
            if (LevelData.mode == ModeGame.Vertical)
            {
                label.text = "" + Mathf.Clamp(MainScript.Instance.TargetCounter1, 0, 6) + "/6";
            }
            else if (LevelData.mode == ModeGame.Rounded)
            {
                label.text = "" + Mathf.Clamp(MainScript.Instance.TargetCounter1, 0, 1) + "/1";
            }
            else if (LevelData.mode == ModeGame.Animals)
            {
                label.text = "" + MainScript.Instance.TargetCounter1 + "/" + MainScript.Instance.TotalTargets;
            }
        }

        if (name == "Lifes")
        {
            label.text = "" + InitScript.Instance.GetLife();
        }

        if (name == "Gems")
        {
            label.text = "" + InitScript.Gems;
        }
        if (name == "5BallsBoost")
        {
            label.text = "" + GetPlus(InitScript.Instance.FiveBallsBoost);
        }
        if (name == "ColorBallBoost")
        {
            label.text = "" + GetPlus(InitScript.Instance.ColorBallBoost);
        }
        if (name == "FireBallBoost")
        {
            label.text = "" + GetPlus(InitScript.Instance.FireBallBoost);
        }
        if (name == "TargetDescription")
        {
            label.text = "" + GetTarget();
        }
    }
Beispiel #28
0
 public void Stop()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().swish[0]);
 }
Beispiel #29
0
 public void BuyGames()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     GameObject.Find("Canvas").transform.Find("GemsShop").gameObject.SetActive(true);
 }
Beispiel #30
0
 public void Next()
 {
     SoundBase.GetInstance().GetComponent <AudioSource>().PlayOneShot(SoundBase.GetInstance().click);
     CloseMenu();
 }