Unity实现单机游戏每日签到系统
程序员文章站
2022-06-18 21:38:13
本文实例为大家分享了unity实现每日签到系统的具体代码,供大家参考,具体内容如下代码:using system;using system.collections;using system.colle...
本文实例为大家分享了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(); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: 鸡中翅要卤多长时间