备份CatanBuilding瘦身独立工程
This commit is contained in:
22
Assets/Scripts/UI/FishMap/FishAttribute.cs
Normal file
22
Assets/Scripts/UI/FishMap/FishAttribute.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishAttribute : MonoBehaviour
|
||||
{
|
||||
public Button button;
|
||||
public Image icon;
|
||||
public TMP_Text text_name;
|
||||
public TMP_Text text_num_before;
|
||||
public TMP_Text text_num_after;
|
||||
public TMP_Text text_num_max;
|
||||
private void Reset()
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
icon = transform.Find("bg_attribute/icon").GetComponent<Image>();
|
||||
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
|
||||
text_num_before = transform.Find("text_num_before").GetComponent<TMP_Text>();
|
||||
text_num_after = transform.Find("text_num_before/text_num_after").GetComponent<TMP_Text>();
|
||||
text_num_max = transform.Find("text_num_max").GetComponent<TMP_Text>();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishMap/FishAttribute.cs.meta
Normal file
11
Assets/Scripts/UI/FishMap/FishAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f262b560d4a554a4db1ce22e285efdb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Assets/Scripts/UI/FishMap/FishCardUI.cs
Normal file
127
Assets/Scripts/UI/FishMap/FishCardUI.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishCardUI : MonoBehaviour
|
||||
{
|
||||
public Image bg_card;
|
||||
public TMP_Text text_name;
|
||||
public TMP_Text text_map;
|
||||
public GameObject mask_fish;
|
||||
public Image img_icon_hd;
|
||||
public Image icon_tag;
|
||||
public Image bar;
|
||||
public GameObject up;
|
||||
public GameObject bg_bar;
|
||||
public TMP_Text text_bar;
|
||||
public TMP_Text text_level;
|
||||
public GameObject bg_num;
|
||||
public TMP_Text text_num;
|
||||
public GameObject text_empty;
|
||||
public GameObject mask_empty;
|
||||
public GameObject newGo;
|
||||
public RewardItem transfer;
|
||||
public FishData data;
|
||||
cfg.FishCard fishCard;
|
||||
public int curProficiency;
|
||||
public int curShowNum = 0;
|
||||
ShowImageData imageData = null;
|
||||
public void Init()
|
||||
{
|
||||
transfer.gameObject.SetActive(false);
|
||||
text_map.gameObject.SetActive(false);
|
||||
if (data != null)
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
curProficiency = curShowNum > 0 ? curShowNum : GContext.container.Resolve<PlayerFishData>().GetCardDataProficiency(data.FishCardID);
|
||||
|
||||
text_name.text = LocalizationMgr.GetText(data.Name_l10n_key);
|
||||
fishCard = GContext.container.Resolve<Tables>().TbFishCard[data.FishCardID];
|
||||
string spriteName = "fishiconhd_empty_02";
|
||||
if (data.Quality < 3)
|
||||
{
|
||||
spriteName = "fishiconhd_empty_01";
|
||||
}
|
||||
else if (data.Quality > 3)
|
||||
{
|
||||
spriteName = "fishiconhd_empty_03";
|
||||
}
|
||||
img_icon_hd.sprite = uiService.GetSprite(spriteName);
|
||||
if (imageData == null)
|
||||
{
|
||||
imageData = new ShowImageData(img_icon_hd);
|
||||
}
|
||||
imageData.SetName(fishCard.Icon);
|
||||
uiService.SetImageSprite(imageData, BasePanel.PanelName);
|
||||
|
||||
//设置img_icon颜色为纯白色
|
||||
img_icon_hd.color = curProficiency > 0 ?
|
||||
Color.white :
|
||||
//设置img_icon颜色为纯黑色60%透明度
|
||||
new Color(0, 0, 0, 0.6f);
|
||||
mask_fish.gameObject.SetActive(false);
|
||||
img_icon_hd.gameObject.SetActive(true);
|
||||
uiService.SetImageSprite(bg_card, $"bg_fishcard_{data.Quality}", BasePanel.PanelName);
|
||||
uiService.SetImageSprite(icon_tag, $"icon_fish_rate_tag_{data.Quality}", BasePanel.PanelName);
|
||||
|
||||
SetProficiency();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetProficiency()
|
||||
{
|
||||
curProficiency = curShowNum > 0 ? curShowNum : GContext.container.Resolve<PlayerFishData>().GetCardDataProficiency(data.FishCardID);
|
||||
//显示锁头
|
||||
newGo.SetActive(GContext.container.Resolve<PlayerFishData>().GetDataNewFish(data.ID) && curProficiency > 0);
|
||||
mask_empty.SetActive(curProficiency == 0);
|
||||
text_empty.SetActive(curProficiency == 0);
|
||||
bg_bar.gameObject.SetActive(curProficiency > 0);
|
||||
text_level.gameObject.SetActive(curProficiency > 0);
|
||||
icon_tag.gameObject.SetActive(curProficiency > 0);
|
||||
up.SetActive(false);
|
||||
int level = GContext.container.Resolve<PlayerFishData>().GetDataLevel(data.ID);
|
||||
text_level.text = level.ToString();
|
||||
bg_num.gameObject.SetActive(false);
|
||||
if (curProficiency > 0)
|
||||
{
|
||||
if (level < fishCard.MaxLevel)
|
||||
{
|
||||
int endWeight = fishCard.CardsRequiredList[level];
|
||||
int startWeight = level > 0 ? fishCard.CardsRequiredList[level - 1] : 0;
|
||||
bar.fillAmount = (curProficiency - startWeight) / (float)(endWeight - startWeight);
|
||||
if (curProficiency >= endWeight)
|
||||
{
|
||||
up.SetActive(true);
|
||||
newGo.SetActive(false);
|
||||
}
|
||||
|
||||
text_bar.text = $"{curProficiency - startWeight}/{endWeight - startWeight}";
|
||||
}
|
||||
else if (level >= fishCard.MaxLevel)
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
text_bar.text = LocalizationMgr.GetText("UI_FishingPanel_101007");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
}
|
||||
}
|
||||
public void SetNum(int count)
|
||||
{
|
||||
text_map.gameObject.SetActive(true);
|
||||
var mapData = GContext.container.Resolve<Tables>().TbMapData.GetOrDefault(data.AreaID);
|
||||
text_map.text = LocalizationMgr.GetText(mapData.Name_l10n_key);
|
||||
up.SetActive(false);
|
||||
//text_level.gameObject.SetActive(false);
|
||||
//if (count > 1)
|
||||
{
|
||||
bg_num.gameObject.SetActive(true);
|
||||
text_num.text = $"x{count}";
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishMap/FishCardUI.cs.meta
Normal file
11
Assets/Scripts/UI/FishMap/FishCardUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6023a137e546da34db5452d910a26c52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
103
Assets/Scripts/UI/FishMap/FishMapItem.cs
Normal file
103
Assets/Scripts/UI/FishMap/FishMapItem.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
|
||||
public class FishMapItem : PanelItemBase<FishMapItemData>
|
||||
{
|
||||
Transform root;
|
||||
Image img_map;
|
||||
private GameObject mask;
|
||||
Image bar;
|
||||
private TMP_Text text_bar;
|
||||
GameObject newGo;
|
||||
private GameObject redpoint;
|
||||
Button btn_item;
|
||||
private GameObject mask_empty;
|
||||
private TMP_Text text_require;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
root = transform.Find("p_icon_item/icon_item1/btn_green");
|
||||
img_map = root.Find("mask_map/img_map").GetComponent<Image>();
|
||||
bar = root.Find("mask_empty/bg_bar/bar").GetComponent<Image>();
|
||||
text_bar = root.Find("mask_empty/bg_bar/text_progress").GetComponent<TMP_Text>();
|
||||
newGo = root.Find("new").gameObject;
|
||||
redpoint = root.Find("redpoint").gameObject;
|
||||
btn_item = root.GetComponent<Button>();
|
||||
mask_empty = root.Find("mask_empty").gameObject;
|
||||
text_require = root.Find("mask_empty/text_require").GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
btn_item.onClick.AddListener(OnBtnItem);
|
||||
}
|
||||
|
||||
public override void OffsetX(float _offsetX, float width)
|
||||
{
|
||||
transform.localScale = Vector3.one * Mathf.Clamp(1 - Mathf.Abs(_offsetX) / width * 0.2f, 0.75f, 1);
|
||||
float offset;
|
||||
if (transform.localScale.x < 0.8f)
|
||||
{
|
||||
offset = (0.8f - transform.localScale.x) * width * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
transform.GetChild(0).localPosition = _offsetX > 0 ? Vector3.left * offset : Vector3.right * offset;
|
||||
|
||||
if (Mathf.Abs(_offsetX) < width / 2)
|
||||
{
|
||||
//即将选中
|
||||
OnCenter();
|
||||
}
|
||||
}
|
||||
|
||||
//当靠近中心时回调
|
||||
public void OnCenter()
|
||||
{
|
||||
data.ChangeMapName(data.index, data.name);
|
||||
}
|
||||
public void SetRed()
|
||||
{
|
||||
redpoint.SetActive(data.isRedPoint);
|
||||
}
|
||||
public override void OnInit()
|
||||
{
|
||||
transform.localScale = Vector3.one * 0.75f;
|
||||
SetRed();
|
||||
SetIsNew();
|
||||
bar.fillAmount = data.progress;
|
||||
text_bar.text = data.progressText;
|
||||
// img_map.material = data.unLock ? null : AssetManager.LoadAsset<Material>("ImageGrayMaskMat");
|
||||
mask_empty.SetActive(!data.unLock);
|
||||
text_require.text = data.levelRequired.ToString();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(img_map, data.icon);
|
||||
}
|
||||
|
||||
public void SetIsNew()
|
||||
{
|
||||
newGo.SetActive(data.isNew);
|
||||
}
|
||||
}
|
||||
|
||||
public class FishMapItemData
|
||||
{
|
||||
public int ID;
|
||||
public List<int> fishList;
|
||||
public string name;
|
||||
public float progress;
|
||||
public string icon;
|
||||
public string progressText;
|
||||
public bool unLock;
|
||||
public bool isNew;
|
||||
public bool isRedPoint;
|
||||
public int index;
|
||||
public Action<int, string> ChangeMapName;
|
||||
public int levelRequired;
|
||||
}
|
||||
11
Assets/Scripts/UI/FishMap/FishMapItem.cs.meta
Normal file
11
Assets/Scripts/UI/FishMap/FishMapItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70f42da3ac1ddad4290f1a656a3e8f27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
144
Assets/Scripts/UI/FishMap/MapCardInfo.cs
Normal file
144
Assets/Scripts/UI/FishMap/MapCardInfo.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MapCardInfo : MonoBehaviour
|
||||
{
|
||||
public Button btn_close;
|
||||
public FishCardUI fish_card;
|
||||
public MapFishAttribute mapFishAttribute;
|
||||
public TMP_Text text_level_max;
|
||||
public Button btn_upgrade;
|
||||
public Button btn_upgrade_gray;
|
||||
public GameObject max_level;
|
||||
public GameObject arrow;
|
||||
public TMP_Text text_level_num_before;
|
||||
public TMP_Text text_level_num_after;
|
||||
public Button btn_arrow_left;
|
||||
public Button btn_arrow_right;
|
||||
public int currentIndex;
|
||||
public FishData data;
|
||||
public List<FishData> dataList;
|
||||
public List<GameObject> levelup;
|
||||
private void Start()
|
||||
{
|
||||
btn_upgrade.onClick.AddListener(OnClickUp);
|
||||
btn_arrow_left.onClick.AddListener(OnLeftClick);
|
||||
btn_arrow_right.onClick.AddListener(OnRightClick);
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
for (int i = 0; i < levelup.Count; i++)
|
||||
{
|
||||
levelup[i].gameObject.SetActive(false);
|
||||
}
|
||||
SetData();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
//左右滑动屏幕一半距离触发OnLeftClick或OnRightClick
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
OnBeginDrag();
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
OnEndDrag();
|
||||
}
|
||||
}
|
||||
float beginDragPosX = 0;
|
||||
void OnBeginDrag()
|
||||
{
|
||||
beginDragPosX = Input.mousePosition.x;
|
||||
}
|
||||
void OnEndDrag()
|
||||
{
|
||||
//滑动屏幕一半距离触发OnLeftClick或OnRightClick
|
||||
if (Mathf.Abs(Input.mousePosition.x - beginDragPosX) > Screen.width / 4)
|
||||
{
|
||||
if (Input.mousePosition.x > beginDragPosX)
|
||||
{
|
||||
OnLeftClick();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnRightClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnLeftClick()
|
||||
{
|
||||
currentIndex -= 1;
|
||||
if (currentIndex < 0)
|
||||
{
|
||||
currentIndex = dataList.Count - 1;
|
||||
}
|
||||
SetData();
|
||||
}
|
||||
|
||||
void OnRightClick()
|
||||
{
|
||||
currentIndex += 1;
|
||||
if (currentIndex >= dataList.Count)
|
||||
{
|
||||
currentIndex = 0;
|
||||
}
|
||||
SetData();
|
||||
}
|
||||
void SetData()
|
||||
{
|
||||
if (dataList == null || dataList.Count <= currentIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
data = dataList[currentIndex];
|
||||
SetProficiency();
|
||||
fish_card.data = data;
|
||||
fish_card.Init();
|
||||
}
|
||||
void OnClickUp()
|
||||
{
|
||||
GContext.container.Resolve<PlayerFishData>().UpDateLevel(data.ID);
|
||||
for (int i = 0; i < levelup.Count; i++)
|
||||
{
|
||||
levelup[i].gameObject.SetActive(false);
|
||||
levelup[i].gameObject.SetActive(true);
|
||||
}
|
||||
SetProficiency();
|
||||
fish_card.SetProficiency();
|
||||
}
|
||||
|
||||
void SetProficiency()
|
||||
{
|
||||
int level = GContext.container.Resolve<PlayerFishData>().GetDataLevel(data.ID);
|
||||
int curProficiency = GContext.container.Resolve<PlayerFishData>().GetCardDataProficiency(data.FishCardID);
|
||||
cfg.FishCard fishCard = GContext.container.Resolve<Tables>().TbFishCard[data.FishCardID];
|
||||
max_level.SetActive(level >= fishCard.MaxLevel);
|
||||
text_level_max.gameObject.SetActive(level >= fishCard.MaxLevel);
|
||||
arrow.SetActive(level < fishCard.MaxLevel);
|
||||
if (level < fishCard.MaxLevel)
|
||||
{
|
||||
text_level_num_before.text = level.ToString();
|
||||
text_level_num_after.text = $"{level + 1}";
|
||||
int endWeight = fishCard.CardsRequiredList[level];
|
||||
btn_upgrade.gameObject.SetActive(curProficiency >= endWeight);
|
||||
btn_upgrade_gray.gameObject.SetActive(curProficiency < endWeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_level_max.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", fishCard.MaxLevel);
|
||||
btn_upgrade.gameObject.SetActive(false);
|
||||
btn_upgrade_gray.gameObject.SetActive(false);
|
||||
}
|
||||
SetFishAttribute();
|
||||
}
|
||||
void SetFishAttribute()
|
||||
{
|
||||
mapFishAttribute.SetFishAttribute(data);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishMap/MapCardInfo.cs.meta
Normal file
11
Assets/Scripts/UI/FishMap/MapCardInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca64a03b2fbe8e344ad6c404a97aa137
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/Scripts/UI/FishMap/MapFishAttribute.cs
Normal file
52
Assets/Scripts/UI/FishMap/MapFishAttribute.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using UnityEngine;
|
||||
|
||||
public class MapFishAttribute : MonoBehaviour
|
||||
{
|
||||
public FishAttribute[] fishAttributes;
|
||||
private void Reset()
|
||||
{
|
||||
fishAttributes = GetComponentsInChildren<FishAttribute>();
|
||||
}
|
||||
public void SetFishAttribute(FishData data)
|
||||
{
|
||||
int level = GContext.container.Resolve<PlayerFishData>().GetDataLevel(data.ID);
|
||||
cfg.FishCard fishCard = GContext.container.Resolve<Tables>().TbFishCard[data.FishCardID];
|
||||
if (level >= fishCard.MaxLevel)
|
||||
{
|
||||
fishAttributes[0].text_num_max.gameObject.SetActive(true);
|
||||
fishAttributes[0].text_num_before.gameObject.SetActive(false);
|
||||
fishAttributes[0].text_num_max.text = fishCard.WeightMagList[fishCard.MaxLevel - 1].ToPercentageString();
|
||||
|
||||
fishAttributes[1].text_num_max.gameObject.SetActive(true);
|
||||
fishAttributes[1].text_num_before.gameObject.SetActive(false);
|
||||
fishAttributes[1].text_num_max.text = fishCard.DamageMagList[fishCard.MaxLevel - 1].ToPercentageString();
|
||||
}
|
||||
else
|
||||
{
|
||||
fishAttributes[0].text_num_max.gameObject.SetActive(false);
|
||||
fishAttributes[0].text_num_before.gameObject.SetActive(true);
|
||||
fishAttributes[0].text_num_before.text = level == 0 ? "0%" : fishCard.WeightMagList[level - 1].ToPercentageString();
|
||||
fishAttributes[0].text_num_after.text = fishCard.WeightMagList[level].ToPercentageString();
|
||||
|
||||
fishAttributes[1].text_num_max.gameObject.SetActive(false);
|
||||
fishAttributes[1].text_num_before.gameObject.SetActive(true);
|
||||
fishAttributes[1].text_num_before.text = level == 0 ? "0%" : fishCard.DamageMagList[level - 1].ToPercentageString();
|
||||
fishAttributes[1].text_num_after.text = fishCard.DamageMagList[level].ToPercentageString();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRewardShowData(FishData data, float startAtrribute1, float startAtrribute2)
|
||||
{
|
||||
int level = GContext.container.Resolve<PlayerFishData>().GetDataLevel(data.ID);
|
||||
cfg.FishCard fishCard = GContext.container.Resolve<Tables>().TbFishCard[data.FishCardID];
|
||||
|
||||
fishAttributes[0].text_num_before.text = startAtrribute1.ToPercentageString();
|
||||
fishAttributes[0].text_num_after.text = fishCard.WeightMagList[level - 1].ToPercentageString();
|
||||
|
||||
fishAttributes[1].text_num_before.text = startAtrribute2.ToPercentageString();
|
||||
fishAttributes[1].text_num_after.text = fishCard.DamageMagList[level - 1].ToPercentageString();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FishMap/MapFishAttribute.cs.meta
Normal file
11
Assets/Scripts/UI/FishMap/MapFishAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44f740286571a8b4a90ce01e88f05226
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user