【发布时间】:2020-01-21 00:27:07
【问题描述】:
我创建了一个每日奖励系统,其中玩家每天可以获得大约 3 个 500 硬币,例如1/3金币。我用Admob Unity Plugin给玩家显示奖励视频,点击按钮获得500金币,按钮可以点击3次,玩家每观看一次奖励视频,获得500金币。
我的问题:
1:如果用户第一次点击奖励按钮并完整观看奖励视频,我的int将增加到1并且玩家奖励500个硬币 - (所以是500个硬币的1/3)
2:如果用户第二次点击了奖励按钮,但又决定关闭奖励视频,int将不增加,玩家不奖励500 个硬币 - (仍然是 500 个硬币的 1/3)
3:但如果用户决定点击奖励按钮,然后决定完整观看新的奖励视频,int 将增加 2(而不是 1)并且玩家现在奖励 1,000 金币(而不是 500)-(现在是 3/3 有 1,500 金币)
注意:此顺序不是特定的,用户可以从一开始或在 int 达到 3/3 之前执行此方法,并且用户想要多次执行此方法,只需关闭奖励视频很多时间(未完成视频)直到满意,然后将奖励视频完整观看 3 次。
我不会包含我的每日奖励脚本,因为我不认为它会导致我的问题。 请问哪位大神能帮帮我,谢谢!!!!!!
这是我的奖励脚本:
{
public Admob ad;
public int clickInt = 0;
public Text clickText;
public Image coinImage;
public Button rewardButton;
void Awake()
{
if (PlayerPrefs.HasKey("amount"))
{
clickInt = PlayerPrefs.GetInt("amount");
}
}
void Start ()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#endif
}
// Update is called once per frame
void Update()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
}
#elif UNITY_ANDROID
ad = Admob.Instance ();
if (ad.isRewardedVideoReady ()) {
coinImage.enabled = true;
} else {
ad.loadRewardedVideo ("ca-app-pub-…………………/……………");
coinImage.enabled = false;
}
if (clickInt == 1) {
clickText.text = "1/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt == 2) {
clickText.text = "2/3 Daily uses";
rewardButton.interactable = true;
} else if (clickInt >= 3) {
clickInt = 3;
}
if (clickInt == 3) {
clickText.text = "3/3 Daily uses";
rewardButton.interactable = false;
}
#endif
}
public void Free_500_Coins()
{
#if UNITY_EDITOR
Debug.Log("Unable to play ad in the EDITOR");
clickInt += 1;
ShopManager.Playercurrency += 500;
#elif UNITY_ANDROID
if (ad.isRewardedVideoReady ()) {
Admob.Instance().interstitalRewardHandler += onInterstitalRewardVideoEvent;
coinImage.enabled = true;
ad.showRewardedVideo ();
} else {
ad.loadRewardedVideo ("ca-app-pub-............/...........");
coinImage.enabled = false;
}
#endif
}
void onInterstitalRewardVideoEvent(string eventNames, string msgs)
{
if (eventNames == "onRewarded")
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
Debug.Log("Well Done! You got 500 coins");
clickInt += 1;
ShopManager.Playercurrency += 500;
Debug.Log("handler AdmobEventsHandler---" + eventNames + " " + msgs);
}
}
public void OnDestroy()
{
Admob.Instance().interstitalRewardHandler -= onInterstitalRewardVideoEvent;
}
}```
【问题讨论】: