您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
小编给大家分享一下Unity如何实现单机游戏每日签到系统,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
Unity实现每日签到系统的具体代码,具体内容如下
代码:
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class HallManager : UnitySingleton<HallManager> { public Text textSingInCoinDes, textSingInCoin; public Button btnSignInNormal, btnSignInAd; //------------------------------------------ 签到模块 ------------------------------------------ /// <summary> /// 设置签到数据 /// </summary> public void SetSignInPanelData() { if (string.IsNullOrEmpty(PlayerPrefs.GetString("SignInDay7"))) { for (int i = 0; i < 7; i++) { PlayerPrefs.SetString("SignInDay" + (i + 1), DateTime.Today.AddDays(i).ToShortDateString()); } } for (int i = 0; i < 7; i++) { if (DateTime.Today.ToShortDateString().Equals(PlayerPrefs.GetString("SignInDay" + (i + 1)))) { textSingInCoinDes.text = "今天领取"; textSingInCoin.text = signInCoin[i].ToString(); btnSignInNormal.gameObject.SetActive(true); btnSignInAd.gameObject.SetActive(true); signFinish.gameObject.SetActive(false); } else if ("已签到".Equals(PlayerPrefs.GetString("SignInDay" + (i + 1))) && i != 6) { textSingInCoinDes.text = "明天领取"; textSingInCoin.text = signInCoin[i + 1].ToString(); btnSignInNormal.gameObject.SetActive(false); btnSignInAd.gameObject.SetActive(false); signFinish.gameObject.SetActive(true); } } for (int i = 0; i < 7; i++) { if (DateTime.Today.ToShortDateString().Equals(PlayerPrefs.GetString("SignInDay" + (i + 1))) || "已签到".Equals(PlayerPrefs.GetString("SignInDay" + (i + 1)))) { if ("已签到".Equals(PlayerPrefs.GetString("SignInDay" + (i + 1)))) { signInPanel.transform.Find("Items").GetChild(i).Find("YiQianDao").gameObject.SetActive(true); } else { signInPanel.transform.Find("Items").GetChild(i).Find("YiQianDao").gameObject.SetActive(false); } } } } /// <summary> /// 点击普通签到 /// </summary> void ClickBtnSignInNormal() { for (int i = 0; i < 7; i++) { if (DateTime.Today.ToShortDateString().Equals(PlayerPrefs.GetString("SignInDay" + (i + 1)))) { CoinManager.Instance.AddCoin(signInCoin[i]); PlayerPrefs.SetString("SignInDay" + (i + 1), "已签到"); ShowRewardPanel(signInCoin[i]); } } SetUserInfo(); SetSignInPanelData(); //全屏广告 MobileController.Instance.CallFullScreenAd(FullScreenAdRewardType.None); } /// <summary> /// 点击视频双倍奖励签到 /// </summary> void ClickSignInAd() { MobileController.Instance.CallVedioRewardAd("signIn"); } /// <summary> /// 回调 - 视频双倍奖励签到 /// </summary> public void CallBackSignInReward() { for (int i = 0; i < 7; i++) { if (DateTime.Today.ToShortDateString().Equals(PlayerPrefs.GetString("SignInDay" + (i + 1)))) { CoinManager.Instance.AddCoin(signInCoin[i] * 2); PlayerPrefs.SetString("SignInDay" + (i + 1), "已签到"); ShowRewardPanel(signInCoin[i] * 2); } } SetUserInfo(); SetSignInPanelData(); } }
以上是“Unity如何实现单机游戏每日签到系统”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。