1
This commit is contained in:
82
unity/Assets/Script/LevelUpSystem/LevelItem.cs
Normal file
82
unity/Assets/Script/LevelUpSystem/LevelItem.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using Managers;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LevelItem : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public int LevelId;
|
||||
public int PreId;//前置节点
|
||||
public Text need;
|
||||
public Text activeText;
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var date in Date.Instance.UpDate)
|
||||
{
|
||||
if (date.UpId == LevelId)
|
||||
{
|
||||
if(PlayerInfo.Instance.info.UpValue[date.UpId])
|
||||
{
|
||||
activeText.text = "已激活";
|
||||
need.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeText.text = "未激活";
|
||||
need.text = date.useNum.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
foreach (var date in Date.Instance.UpDate)
|
||||
{
|
||||
if (date.UpId == LevelId&&!PlayerInfo.Instance.info.UpInfo[date.UpId])
|
||||
{
|
||||
if(CheckUp(LevelId))
|
||||
{
|
||||
if(!PlayerInfo.Instance.info.BagInfo.ContainsKey(date.userId))
|
||||
{
|
||||
Debug.Log("所用道具不足");
|
||||
return;
|
||||
}
|
||||
if(PlayerInfo.Instance.info.BagInfo[date.userId]>=date.useNum)
|
||||
{
|
||||
PlayerInfo.Instance.BagMgr.UserItem(date.userId, date.useNum);
|
||||
PlayerInfo.Instance.ItemLevel(date);
|
||||
activeText.text = "已激活";
|
||||
need.gameObject.SetActive(false);
|
||||
|
||||
//保存数据
|
||||
PlayerInfo.Instance.info.UpValue[date.UpId] = true;
|
||||
PlayerInfo.Instance.info.UpInfo[date.UpId] = PlayerInfo.Instance.info.UpValue[date.UpId];
|
||||
SaveSystem.SaveDate(PlayerInfo.Instance.info.DatePath, PlayerInfo.Instance.info);
|
||||
|
||||
return;
|
||||
}
|
||||
Debug.Log("所用道具不足");
|
||||
return;
|
||||
}
|
||||
Debug.Log("前置条件没有升级");
|
||||
}
|
||||
}
|
||||
}
|
||||
bool CheckUp(int id)
|
||||
{
|
||||
if(id==0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(!PlayerInfo.Instance.info.UpValue[Date.Instance.UpDate[id].PreId])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
11
unity/Assets/Script/LevelUpSystem/LevelItem.cs.meta
Normal file
11
unity/Assets/Script/LevelUpSystem/LevelItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e8febb475782074d92ed6e2d7d41a8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
unity/Assets/Script/LevelUpSystem/LevelUpDefine.cs
Normal file
17
unity/Assets/Script/LevelUpSystem/LevelUpDefine.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LevelUpDefine
|
||||
{
|
||||
public int UpId;
|
||||
public int PreId;
|
||||
public string UpName;
|
||||
public bool Active;
|
||||
public string Descripet;
|
||||
public int userId;
|
||||
public int useNum;
|
||||
public LotteryType type;
|
||||
public int value;
|
||||
|
||||
}
|
||||
11
unity/Assets/Script/LevelUpSystem/LevelUpDefine.cs.meta
Normal file
11
unity/Assets/Script/LevelUpSystem/LevelUpDefine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2221f9aac6ce9c45818de80359b75bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
unity/Assets/Script/LevelUpSystem/UILevelUp.cs
Normal file
7
unity/Assets/Script/LevelUpSystem/UILevelUp.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UILevelUp : UIWindow
|
||||
{
|
||||
}
|
||||
11
unity/Assets/Script/LevelUpSystem/UILevelUp.cs.meta
Normal file
11
unity/Assets/Script/LevelUpSystem/UILevelUp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29cd9dd5f7ca389448a41d0f0f308267
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user