/// <summary> /// 购买道具 /// </summary> public void BuyPropsCard() { int cardType = Random.Range(1, 4);//Random.Range针对整数随机,返回一个随机整数,在min(包含)和max(排除)之间,左闭右开原则(和float是不一样的) MyCardType = (ePropsCardType)cardType; //本地记录一波道具信息 PlayerPrefs.SetInt(MYCARDTYPE, cardType); //减去消费积分并本地记录一波积分信息 MyScore -= 30; PlayerPrefs.SetInt(MYSCORE, MyScore); propsUIController.RefreshPanel(); }
private void Awake() { //需要早点读取 MyScore = 500; // PlayerPrefs.GetInt(MYSCORE);//读取本地我的积分,默认值0 MyCardType = (ePropsCardType)PlayerPrefs.GetInt(MYCARDTYPE); //读取本地我的道具卡,默认值0 //初始化万能卡使用状态和限定卡限定状态 bComCardUseState = false; bLimitCardState = false; //初始化万能卡信息 comCardImageInfo = new ImageInfo(); comCardImageInfo.id = 10000; comCardImageInfo.isMission = true; comCardImageInfo.isCommonCard = true; }
/// <summary> /// 使用道具卡完毕,重置道具信息 /// </summary> private void UseCardComplete() { MyCardType = ePropsCardType.none; //重置本地记录道具信息 PlayerPrefs.SetInt(MYCARDTYPE, 0); }