Exemple #1
0
    public void ReturnHome(bool audio = true)
    {
        GetComponent <ScoreController> ().EndGame = true;

        Level levelConfig = GetComponent <LevelController> ().CurLevelConfig;
        // 替换等级名称
        var levelText = StartCanvas.transform.Find("UILevelButton/Text").gameObject;

        levelText.GetComponent <Text> ().text = levelConfig.name;
        // 替换等级图片
        var sprite = Resources.Load("UI/level_" + levelConfig.quality, typeof(Sprite)) as Sprite;         // replace sprite color

        StartCanvas.transform.Find("UILevelButton").GetComponent <Image>().sprite = sprite;
        // 显示ui
        this.ShowOneUI("Start");
        if (audio)
        {
            TouchHandler.PlayClickAudio();              // 播放按钮声音
        }
        // 版本号
        var versionText = StartCanvas.transform.Find("UIVersion").GetComponent <Text> ();

        versionText.text = Application.version;
        // 停止bgm
        this.StopBgm();
    }
Exemple #2
0
    // use a basket prop
    public void UseBasket()
    {
        if (CurThrowObject == null || CurThrowObject.tag == "Basket")         // have a basket, do nothing
        {
            return;
        }
        if (GetComponent <GoldController> ().Basket <= 0)        // 道具不够,显示商店,让玩家购买
        {
            GetComponent <GoldController>().ShowShopCanvas();
            this.PauseGame();
            return;
        }
        Destroy(CurThrowObject);                                // destroy current ball
        this.GenerateBasket(Role.transform.position.x + 0.48f); // generate a new basket
        GetComponent <GoldController> ().Basket--;              // change prop num
        var ani = GameCanvas.transform.Find("UIBasketButton/-1").gameObject;

        ani.SetActive(true);
        GetComponent <AnimatorScript>().AddRising(ani, 0.5f, 1, new AnimatorDelegate(this.PropsCallback));
        TouchHandler.PlayClickAudio();                             // 播放按钮声音

        int guide = PlayerPrefs.GetInt(GameConsts.GUIDE_LOCAL, 0); // 需要做新手引导

        if (guide == 0)
        {
            this.ShowGuideTxt(true);
        }

        // umeng
        GA.Use("Basket", 1, 15);
    }
Exemple #3
0
    // use a wind shield prop
    public void UseWindShield()
    {
        if (GetComponent <WindController> ().IsWindMask())        // used one, do nothing
        {
            return;
        }
        if (CurThrowObject == null)         // throwing, do nothing
        {
            return;
        }
        if (GetComponent <GoldController> ().WindShield <= 0)        // 道具不够,显示商店,让玩家购买
        {
            GetComponent <GoldController>().ShowShopCanvas();
            this.PauseGame();
            return;
        }
        GetComponent <WindController> ().ChangeWindMask(true); // wind mask
        GetComponent <GoldController> ().WindShield--;         // change prop num
        var ani = GameCanvas.transform.Find("UIWindSheildButton/-1").gameObject;

        ani.SetActive(true);
        GetComponent <AnimatorScript>().AddRising(ani, 0.5f, 1, new AnimatorDelegate(this.PropsCallback));
        TouchHandler.PlayClickAudio();          // 播放按钮声音

        // umeng
        GA.Use("WindShield", 1, 15);
    }
Exemple #4
0
 public void ResumeGame()
 {
     this.ShowOneUI();
     Time.timeScale = 1;
     TouchHandler.PlayClickAudio();                     // 播放按钮声音
     GetComponent <AdvertisementShower> ().LoadAdmob(); // 提前加载广告
 }
Exemple #5
0
    public void ShowLevelCanvas()
    {
        var sceneController = GetComponent <SceneController> ();

        sceneController.ShowOneUI("Level");
        var levels  = LevelCanvas.transform.Find("UILevels"); // all level item ui
        int itemNum = levels.childCount;                      // level item num

        for (int i = 0; i < itemNum; i++)
        {
            var levelItem = levels.GetChild(i).gameObject;
            this.DealLevelItem(levelItem, i + 1, i + 1 > _level);
        }

        this.DealMaxLevelUI(LevelCanvas);

        var curLevelUI = LevelCanvas.transform.Find("UICurLevel").gameObject;          // level ui

        this.DealLevelItem(curLevelUI, _level, false);
        var nextLevelUI = LevelCanvas.transform.Find("UINextLevel").gameObject;          // next level ui

        this.DealLevelItem(nextLevelUI, _level + 1, true);
        this.DealCondition(_level + 1, LevelCanvas); // condition
        TouchHandler.PlayClickAudio();               // 播放按钮声音
    }
Exemple #6
0
    public void ShowAds(string source = "")
    {
        if (Advertisement.IsReady())
        {
            Advertisement.Show(null, new ShowOptions {
                resultCallback = result => {                 // 在回调中奖励,更新ui
                    if (result == ShowResult.Finished)
                    {
                        if (NeedTime)                         // 游戏中看视频加10秒
                        {
                            GetComponent <SceneController>().AddGameTime(11);
                            GetComponent <SceneController>().RandomNext();
                        }
                        else                         // 游戏外加10金币
                        {
                            GetComponent <GoldController>().Gold += 10;
                            GetComponent <SceneController>().UpdateCanvasGold();
                            var goldText = RechargeCanvas.transform.Find("UIGoldText");
                            goldText.GetComponent <Text>().text = GetComponent <GoldController>().Gold.ToString();
                        }
                    }
                    GetComponent <SceneController>().HideExtraTime();                    // 如果是加时赛,恢复游戏
                    NeedTime = false;
                }
            });
        }
        else
        {
            GetComponent <SceneController>().ShowNoitceCanvas(UITextScript.GetTextByKey("ui_ad"), 2f);
        }

        TouchHandler.PlayClickAudio();          // 按钮点击音效

        GA.Event(source);
    }
 // 关闭评价弹窗
 public void HideScoreUsCanvas(bool audio)
 {
     if (audio)
     {
         TouchHandler.PlayClickAudio();              // 按钮点击音效
     }
     ScoreUsCanvas.SetActive(false);
 }
 // 评星
 public void ScoreUS()
 {
     TouchHandler.PlayClickAudio();          // 按钮点击音效
     this.HideScoreUsCanvas(false);
             #if UNITY_IPHONE || UNITY_EDITOR
     var url = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=1147038717&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8";
     Application.OpenURL(url);
             #endif
 }
 // 购买金币
 public void BuyGold(string id)
 {
     TouchHandler.PlayClickAudio();          // 播放按钮声音
     // 显示提示框
     GetComponent <SceneController>().ShowNoitceCanvas(UITextScript.GetTextByKey("window_waiting"), 30);
     if (IsProductAvailable())
     {
         BuyProduct(id);
     }
 }
Exemple #10
0
 public void PauseGame(bool showCanvas = false)
 {
     this.StopAllReplayAudio();
     TouchHandler.PlayClickAudio();          // 播放按钮声音
     if (showCanvas)
     {
         GetComponent <LevelController> ().ShowPauseCanvas();
         AdvertisementShower ad = GetComponent <AdvertisementShower>();
         ad.ShowAdmob("admob_active");
     }
     Time.timeScale = 0;
 }
    public void ShowRank()
    {
        TouchHandler.PlayClickAudio();          // 播放按钮声音

                #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_EDITOR
        if (Social.Active == null)         // 没有排行实现
        {
            return;
        }
        Social.ShowLeaderboardUI();
                #endif
    }
    public void WeiXinShare()
    {
        TouchHandler.PlayClickAudio();          // 播放按钮声音

        string shareText = UITextScript.GetTextByKey("wechat_txt");

        shareText = shareText.Replace("{0}", GetComponent <ScoreController> ().CurScore.ToString());

                #if UNITY_IPHONE
        TouchScreenKeyboard.hideInput = false;
        shareToWeiXin(shareText);
                #endif
    }
Exemple #13
0
    public void BuyWindShield(int num)
    {
        int price = ItemConfig.GetItem(2004).price *num;

        if (Gold < price)         // gold not enough
        {
            return;
        }
        WindShield += num;
        Gold       -= price;

        GA.Use("WindShield", num, price);

        TouchHandler.PlayClickAudio();          // 按钮点击音效
    }
Exemple #14
0
    public void BuyLongerLine(int num)
    {
        int price = ItemConfig.GetItem(2003).price *num;

        if (Gold < price)         // gold not enough
        {
            return;
        }
        LongerLine += num;
        Gold       -= price;

        GA.Buy("LongerLine", num, price);

        TouchHandler.PlayClickAudio();          // 按钮点击音效
    }
Exemple #15
0
    public void BuyBasket(int num)
    {
        int price = ItemConfig.GetItem(2001).price *num;

        if (Gold < price)         // gold not enough
        {
            return;
        }
        Basket += num;
        Gold   -= price;

        GA.Buy("Basket", num, price);

        TouchHandler.PlayClickAudio();          // 按钮点击音效
    }
//	private void InitCallback ()
//	{
//		if (FB.IsInitialized) {
//			// Signal an app activation App Event
//			FB.ActivateApp();
//			// Continue with Facebook SDK
//			// ...
//		} else {
//			Debug.Log("Failed to Initialize the Facebook SDK");
//		}
//	}

    public void FBShare()
    {
        TouchHandler.PlayClickAudio();          // 播放按钮声音
        EndCanvas.transform.Find("UIFreeButton").gameObject.SetActive(false);
        EndCanvas.transform.Find("UIShareButton").gameObject.SetActive(false);
        EndCanvas.transform.Find("UIHomeButton").gameObject.SetActive(false);
        EndCanvas.transform.Find("UIStartButton").gameObject.SetActive(false);
        EndCanvas.transform.Find("UIShopButton").gameObject.SetActive(false);
        Application.CaptureScreenshot("Screenshot.png", 0);        // 截取当前图

        Invoke("PopUpShare", 0.5f);

//		if (FB.IsInitialized)
//		{
//			FB.LogInWithPublishPermissions(new List<string>(){"publish_actions"}, LogInCallback);
//		}
    }
Exemple #17
0
//
//	// use a mini ball prop
//	public void UseMiniBall()
//	{
//		if (GetComponent<GoldController> ().MiniBall <= 0) // prop not enough, do nothing
//			return;
//		if (CurThrowObject == null) // throwing, do nothing
//			return;
//		if (CurThrowObject.tag == "Basket")
//		{
//			Destroy (CurThrowObject); // destroy current ball
//			this.GenerateBall(Role.transform.position.x + 0.5f); // generate a new ball
//		}
//		CurThrowObject.transform.localScale = new Vector3 (0.5f, 0.5f, 1); // half the ball
//		CurThrowObject.GetComponent<CircleCollider2D> ().radius /= 2;
//		GetComponent<GoldController> ().MiniBall--; // change prop num
//		TouchHandler.PlayClickAudio (); // 播放按钮声音
//
//		// umeng
//		GA.Use ("MiniBall", 1, 15);
//	}

    // use a longer line prop
    public void UseLongerLine()
    {
        if (Background.GetComponent <LineCreator> ().LongerLine)        // used one, do nothing
        {
            return;
        }
        if (GetComponent <GoldController> ().LongerLine <= 0)        // 道具不够,显示商店,让玩家购买
        {
            GetComponent <GoldController>().ShowShopCanvas();
            this.PauseGame();
            return;
        }
        Background.GetComponent <LineCreator> ().LongerLine = true; // next line is longer
        GetComponent <GoldController> ().LongerLine--;              // change prop
        var ani = GameCanvas.transform.Find("UILongerLineButton/-1").gameObject;

        ani.SetActive(true);
        GetComponent <AnimatorScript>().AddRising(ani, 0.5f, 1, new AnimatorDelegate(this.PropsCallback));
        TouchHandler.PlayClickAudio();          // 播放按钮声音

        // umeng
        GA.Use("LongerLine", 1, 15);
    }
Exemple #18
0
    public void ShowShopCanvas()
    {
        // basket
        Item basketConfig = ItemConfig.GetItem(2001);
        var  basket       = ShopCanvas.transform.Find("Basket").gameObject;
        var  titleText    = basket.transform.Find("TitleText").gameObject;     // name

        titleText.GetComponent <Text> ().text = basketConfig.name;
        var descText = basket.transform.Find("DescText").gameObject;          // desc

        descText.GetComponent <Text> ().text = basketConfig.desc;

        // longer line
        Item longerLineConfig = ItemConfig.GetItem(2003);
        var  longerLine       = ShopCanvas.transform.Find("LongerLine").gameObject;

        titleText = longerLine.transform.Find("TitleText").gameObject;        // name
        titleText.GetComponent <Text> ().text = longerLineConfig.name;
        descText = longerLine.transform.Find("DescText").gameObject;          // desc
        descText.GetComponent <Text> ().text = longerLineConfig.desc;

        // wind shield
        Item windShieldConfig = ItemConfig.GetItem(2004);
        var  windShield       = ShopCanvas.transform.Find("WindShield").gameObject;

        titleText = windShield.transform.Find("TitleText").gameObject;        // name
        titleText.GetComponent <Text> ().text = windShieldConfig.name;
        descText = windShield.transform.Find("DescText").gameObject;          // desc
        descText.GetComponent <Text> ().text = windShieldConfig.desc;

        this.RefreshButtonStatus();

        GetComponent <SceneController> ().ShowOneUI("Shop");

        TouchHandler.PlayClickAudio();          // 按钮点击音效
    }
 // 联系我们
 public void ContactUS()
 {
     TouchHandler.PlayClickAudio();          // 按钮点击音效
     Application.OpenURL("mailto://[email protected]");
 }
//	private void ImageCallback(IGraphResult result)
//	{
//		if (FB.IsLoggedIn)
//		{
//			string picId = result.ResultDictionary["id"].ToString();
//			const string APP_ID = "1044752639";
//			var url = new Uri(string.Format(
//				"http://itunes.apple.com/app/id{0}",
//				APP_ID));
//			FB.ShareLink(url, "Angry Shot", "I begin to work hard for shining on basketball court, come on and join me, bro!", new Uri("https://www.facebook.com/photo?fbid=" + picId), ShareCallback);
//		}
//	}

    // 评价弹窗
    public void ShowScoreUsCanvas()
    {
        TouchHandler.PlayClickAudio();          // 按钮点击音效
        ScoreUsCanvas.SetActive(true);
    }
Exemple #21
0
 // 显示设置界面
 public void ShowSettingCanvas()
 {
     this.ShowOneUI("Setting");
     TouchHandler.PlayClickAudio();          // 按钮点击音效
     this.UpdateSoundIcon();
 }
Exemple #22
0
 // 设置声音暂停
 public void SwitchSound()
 {
     AudioPause = !AudioPause;
     TouchHandler.PlayClickAudio();          // 按钮点击音效
     this.UpdateSoundIcon();
 }
 public void ShowRechargeCanvas()
 {
     GetComponent <SceneController> ().ShowOneUI("Recharge");
     TouchHandler.PlayClickAudio();          // 播放按钮声音
 }
 //  粉丝页
 public void LikeUS()
 {
     TouchHandler.PlayClickAudio();          // 按钮点击音效
     Application.OpenURL("https://www.facebook.com/blstudio1st");
 }
Exemple #25
0
    public void RestartNewGame()
    {
        _gameTime = GameMaxTime;         // 初始大一点,之后开始计时
        GetComponent <TimeNumController>().ShowNumber((int)_gameTime);

        _haveExtraTime = true; // 有加时机会

        WowScore    = 0;       // wow score 0
        BulletScore = 0;       // bullet score 0

        // 清除之前的球
        var balls = GameObject.FindGameObjectsWithTag("Ball");

        foreach (var ball in balls)
        {
            if (ball && ball.GetComponent <BallController>())
            {
                Destroy(ball);
            }
        }
        // 清除之前的筐
        var baskets = GameObject.FindGameObjectsWithTag("Basket");

        foreach (var basket in baskets)
        {
            basket.GetComponent <BasketController>().DestoryNow();
        }
        GetComponent <AchievementController> ().GameAddGold = 0;
        GetComponent <AchievementController> ().RestartRecord();  // achievement

        GetComponent <ScoreController> ().EndGame = false;        // score 0
        GetComponent <ScoreController> ().SetScore(0);

        GetComponent <AchievementController>().EndGameAfterPlay = false; // 结束游戏

        GetComponent <WindController> ().RestartGame();                  // 风力

        if (this.CurThrowObject != null)                                 // rethrow
        {
            Destroy(this.CurThrowObject);
            this.CurThrowObject = null;
        }

        // 初始给三个筐
        var boards = GameObject.FindGameObjectsWithTag("Board");

        foreach (var board in boards)
        {
            this.GenerateBasket(2, false);
            CurThrowObject.transform.position = new Vector2(2f, board.transform.position.y);
            CurThrowObject.GetComponent <Rigidbody2D> ().isKinematic = true;            // 把速度变为零,黏住
            board.GetComponent <BoardScript>().Basket = CurThrowObject;
            CurThrowObject.GetComponent <BasketController> ().BeginScore(board, false);
        }

        GetComponent <TimeNumController> ().TimeDecreasing = false;

        this.JudgeNight();                                                         // 判断白天和夜景

        this.RandomNext();                                                         // begin next

        this.ResumeGame();                                                         // hide all ui

        GetComponent <CatController> ().HideAllCat(false);                         // hide cat
        GetComponent <HumanController> ().HideAllHuman(false);                     // hide human

        TouchHandler.PlayClickAudio();                                             // 播放按钮声音

        var camera = GameObject.FindGameObjectWithTag("MainCamera") as GameObject; // 停止震动

        camera.GetComponent <ShakeScreen>().IsShaking = false;

        GetComponent <AdvertisementShower> ().LoadAdmob();         // 提前加载广告

        // 游戏次数
        int gameTimes = PlayerPrefs.GetInt(GameConsts.GAME_TIMES, 0);

        PlayerPrefs.SetInt(GameConsts.GAME_TIMES, gameTimes + 1);
        PlayerPrefs.Save();

        // umeng
        GA.StartLevel("1");
    }