260 lines
7.2 KiB
C#
260 lines
7.2 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.U2D;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class RushPanel : BasePanel
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
public Button btnClose;
|
|||
|
|
|||
|
public Button btnGift1;
|
|||
|
private bool isOpen1 = false;
|
|||
|
public Button btnGift2;
|
|||
|
private bool isOpen2 = false;
|
|||
|
public Button btnGift3;
|
|||
|
private bool isOpen3 = false;
|
|||
|
public Button btnGift4;
|
|||
|
private bool isOpen4 = false;
|
|||
|
public Button btnGift5;
|
|||
|
private bool isOpen5 = false;
|
|||
|
public Button btnGift6;
|
|||
|
private bool isOpen6 = false;
|
|||
|
public Button btnGift7;
|
|||
|
private bool isOpen7 = false;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
private PlayerData player;
|
|||
|
|
|||
|
//<2F><>ȡͼ<C8A1><CDBC>
|
|||
|
private SpriteAtlas sa;
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
player = GameDataMgr.Instance.player;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壬<EFBFBD><EFBFBD><CDB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
UpdateGift();
|
|||
|
|
|||
|
btnClose.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
UIManager.Instance.HidePanel<RushPanel>(false);
|
|||
|
});
|
|||
|
btnGift1.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen1)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift1);
|
|||
|
player.rushGiftOpen[0] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift2.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen2)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift2);
|
|||
|
player.rushGiftOpen[1] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift3.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen3)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift3);
|
|||
|
player.rushGiftOpen[2] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift4.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen4)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift4);
|
|||
|
player.rushGiftOpen[3] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift5.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen5)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift5);
|
|||
|
player.rushGiftOpen[4] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift6.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen6)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift6);
|
|||
|
player.rushGiftOpen[5] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
btnGift7.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
if (isOpen7)
|
|||
|
{
|
|||
|
//<2F>رհ<D8B1>ť
|
|||
|
OpenGift(btnGift7);
|
|||
|
player.rushGiftOpen[6] = true;
|
|||
|
GetGold();
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
private void GetGold()
|
|||
|
{
|
|||
|
int gold = 0;
|
|||
|
int valueRan = Random.Range(0, 10); // <20><><EFBFBD><EFBFBD>0<EFBFBD><30>1֮<31><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
if (valueRan < 6)
|
|||
|
{
|
|||
|
// 60% <20><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD> 1-100 <20><><EFBFBD><EFBFBD>
|
|||
|
gold = Random.Range(1, 101);
|
|||
|
}
|
|||
|
else if (valueRan >= 6 && valueRan < 9f)
|
|||
|
{
|
|||
|
// 30% <20><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD> 101-500 <20><><EFBFBD><EFBFBD>
|
|||
|
gold = Random.Range(101, 501);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
// 10% <20><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD> 501-1000 <20><><EFBFBD><EFBFBD>
|
|||
|
gold = Random.Range(501, 1001);
|
|||
|
}
|
|||
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ
|
|||
|
player.gold += gold;
|
|||
|
StartCoroutine(NetMgr.Instance.ChangeDataPost(player));
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD>ͨ<EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private void UpdateGift()
|
|||
|
{
|
|||
|
sa = Resources.Load<SpriteAtlas>("Atlas/OnlinePanel");
|
|||
|
if (player.customLev >= 1 && !isOpen1)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[0])
|
|||
|
{
|
|||
|
btnGift1.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen1 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift1);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 5 && !isOpen2)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[1])
|
|||
|
{
|
|||
|
btnGift2.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen2 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift2);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 10 && !isOpen3)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[2])
|
|||
|
{
|
|||
|
btnGift3.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen3 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift3);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 30 && !isOpen4)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[3])
|
|||
|
{
|
|||
|
btnGift4.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen4 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift4);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 50 && !isOpen5)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[4])
|
|||
|
{
|
|||
|
btnGift5.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen5 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift5);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 80 && !isOpen6)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[5])
|
|||
|
{
|
|||
|
btnGift6.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen6 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift6);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev >= 100 && !isOpen7)
|
|||
|
{
|
|||
|
if (!player.rushGiftOpen[6])
|
|||
|
{
|
|||
|
btnGift7.image.sprite = sa.GetSprite("icn_giftrand");
|
|||
|
isOpen7 = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
OpenGift(btnGift7);
|
|||
|
}
|
|||
|
}
|
|||
|
if (player.customLev < 1)
|
|||
|
{
|
|||
|
btnGift1.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift1.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift2.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift2.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift3.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift3.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift4.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift4.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift5.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift5.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift6.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift6.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
btnGift7.image.sprite = sa.GetSprite("icn_giftrandgray");
|
|||
|
btnGift7.GetComponent<RectTransform>().sizeDelta = new Vector2(108f, 112f);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾͼƬ
|
|||
|
/// </summary>
|
|||
|
/// <param name="btn"></param>
|
|||
|
private void OpenGift(Button btn)
|
|||
|
{
|
|||
|
btn.image.sprite = sa.GetSprite("icn_giftrandopen");
|
|||
|
btn.GetComponent<RectTransform>().sizeDelta = new Vector2(134f, 112f);
|
|||
|
}
|
|||
|
}
|