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); }
private void PopUpShare() { EndCanvas.transform.Find("UIFreeButton").gameObject.SetActive(true); EndCanvas.transform.Find("UIShareButton").gameObject.SetActive(true); EndCanvas.transform.Find("UIHomeButton").gameObject.SetActive(true); EndCanvas.transform.Find("UIStartButton").gameObject.SetActive(true); EndCanvas.transform.Find("UIShopButton").gameObject.SetActive(true); string imagePath = ""; // 截图文件的路径 #if UNITY_IPHONE imagePath = Application.persistentDataPath; #elif UNITY_ANDROID imagePath = Application.persistentDataPath; #elif UNITY_EDITOR imagePath = Application.dataPath; imagePath = imagePath.Replace("/Assets", null); #endif imagePath = imagePath + "/Screenshot.png"; string shareText = UITextScript.GetTextByKey("feed"); #if UNITY_IPHONE TouchScreenKeyboard.hideInput = false; ShowShare(imagePath + "\t" + shareText); #endif }
// 购买金币 public void BuyGold(string id) { TouchHandler.PlayClickAudio(); // 播放按钮声音 // 显示提示框 GetComponent <SceneController>().ShowNoitceCanvas(UITextScript.GetTextByKey("window_waiting"), 30); if (IsProductAvailable()) { BuyProduct(id); } }
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 }
// 提示罚丢 public void ShowMiss() { // miss文字 string str = "Text/word_miss" + UITextScript.GetLangSuffix(); TextController.ReplaceSprite(str, WarningText); // 显示 this.ShowWarning(true); this.ShowPrompt(false); // 倒计时 _curShowTime = MaxShowTime; }
// 显示双倍和三倍 public void ShowMultiScore(int time) { // 多倍的文字 string str = "Text/word_" + time + UITextScript.GetLangSuffix(); TextController.ReplaceSprite(str, PromptText); TextController.ReplaceSprite("Text/word_x" + time, ChangeText); // 显示 this.ShowPrompt(true); this.ShowWarning(false); // 倒计时 _curShowTime = MaxShowTime; }
private static void LoadConfig() { XmlDocument doc = new XmlDocument(); // load xml file doc.Load(GameConsts.LEVEL_CONFIG_URL); levels = new Dictionary <int, Level> (); // load level config XmlNode levelDocs = doc.SelectSingleNode("AngryShot").SelectSingleNode("Levels"); foreach (XmlNode levelDoc in levelDocs) { XmlElement _level = (XmlElement)levelDoc; Level level = new Level(); level.id = int.Parse(_level.GetAttribute("id")); string key = _level.GetAttribute("name"); level.name = UITextScript.GetTextByKey(key); level.quality = int.Parse(_level.GetAttribute("quality")); XmlNodeList levelConditionDocs = levelDoc.SelectSingleNode("conditions").SelectNodes("condition"); level.conditions = new Condition[levelConditionDocs.Count]; int i = 0; foreach (XmlNode levelConditionDoc in levelConditionDocs) { XmlElement _condition = levelConditionDoc as XmlElement; if (_condition == null) { continue; } Condition c = new Condition(); c.id = int.Parse(_condition.GetAttribute("id")); c.num = int.Parse(_condition.GetAttribute("num")); level.conditions[i++] = c; } levels[level.id] = level; } achievements = new Dictionary <int, Achievement> (); // load achievement config XmlNodeList achievementDocs = doc.SelectSingleNode("AngryShot").SelectSingleNode("Achievements").SelectNodes("Achievement"); foreach (XmlNode achievementDoc in achievementDocs) { XmlElement _achievement = (XmlElement)achievementDoc; Achievement achievement = new Achievement(); achievement.id = int.Parse(_achievement.GetAttribute("id")); string key = achievementDoc.SelectSingleNode("txt").InnerText; achievement.txt = UITextScript.GetTextByKey(key); achievements[achievement.id] = achievement; } }
// 提示空心 public void ShowAirball(int time) { // airball文字 string str = "Text/word_cleanshot" + UITextScript.GetLangSuffix(); TextController.ReplaceSprite(str, PromptText); // 具体时间 TextController.ReplaceSprite("Number/AddTime/" + time, ChangeText); // 显示 this.ShowPrompt(true); this.ShowWarning(false); // 倒计时 _curShowTime = MaxShowTime; }
// 提示超屏球 public void ShowCrazyShoot() { // 超屏文字 string str = "Text/word_angryshot" + UITextScript.GetLangSuffix(); TextController.ReplaceSprite(str, PromptText); // 三倍文字 TextController.ReplaceSprite("Text/word_x3", ChangeText); // 显示 this.ShowPrompt(true); this.ShowWarning(false); // 倒计时 _curShowTime = MaxShowTime; }
void OnApplicationPause(bool paused) { #if UNITY_IPHONE || UNITY_ANDROID //程序进入后台时 if (paused) { //每天12, 19点推送 NotificationMessage(UITextScript.GetTextByKey("push_day"), 12, true); NotificationMessage(UITextScript.GetTextByKey("push_night"), 19, true); } else { //程序从后台进入前台时 CleanNotification(); } CloseShare(); #endif }
private static void LoadConfig() { items = new Dictionary <int, Item> (); XmlDocument doc = new XmlDocument(); // load xml file doc.Load(GameConsts.ITEM_CONFIG_URL); XmlNodeList itemDocs = doc.SelectSingleNode("AngryShot").SelectSingleNode("items").SelectNodes("item"); foreach (XmlNode itemDoc in itemDocs) { XmlElement _item = (XmlElement)itemDoc; Item item = new Item(); item.id = int.Parse(_item.GetAttribute("id")); item.name = UITextScript.GetTextByKey(itemDoc.SelectSingleNode("name").InnerText); item.desc = UITextScript.GetTextByKey(itemDoc.SelectSingleNode("desc").InnerText); item.price = int.Parse(itemDoc.SelectSingleNode("price").InnerText); items[item.id] = item; } }