先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
258 lines
9.5 KiB
C#
258 lines
9.5 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
namespace GameCore
|
|
{
|
|
public partial class PlayerItemData
|
|
{
|
|
/// <summary>
|
|
/// 获得膨胀体力后的物品显示
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <param name="dropId"></param>
|
|
/// <param name="index"></param>
|
|
/// <returns></returns>
|
|
public ItemData GetItemDataOneLureInflation(float? inflate, int dropId, int index = 0)
|
|
{
|
|
DropPackageList dropPackageList = _tables.TbDrop.GetOrDefault(dropId)?.DropList;
|
|
if (dropPackageList == null)
|
|
{
|
|
GameDebug.LogError("null dropID" + dropId);
|
|
return null;
|
|
}
|
|
int len = dropPackageList.DropIDList.Count;
|
|
int len2 = dropPackageList.DropCountList.Count;
|
|
if (len != len2)
|
|
{
|
|
if (len > len2)
|
|
{
|
|
len = len2;
|
|
}
|
|
Debug.LogError($"[PlayerItemData]GetItemDataByDropIdAndType: DropPackageList count not equal [DropId]=={dropId}");
|
|
}
|
|
if (index >= len)
|
|
{
|
|
return null;
|
|
}
|
|
ItemData itemData = new ItemData()
|
|
{
|
|
id = dropPackageList.DropIDList[index],
|
|
count = dropPackageList.DropCountList[index]
|
|
};
|
|
|
|
ItemTransition(itemData);
|
|
if (inflate == null)
|
|
{
|
|
inflate = GContext.container.Resolve<PlayerData>().InflationRate;//等级膨胀系数
|
|
}
|
|
itemData.inflate = (float)inflate;
|
|
if (itemData.id == 1001)
|
|
{
|
|
ItemInflation(itemData, inflate);
|
|
}
|
|
return itemData;
|
|
}
|
|
/// <summary>
|
|
/// 获得膨胀体力后的物品显示
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <returns></returns>
|
|
public List<ItemData> GetItemDataByDropIdAndTypeLureInflation(float? inflate, int dropId, int mapId = -1)
|
|
{
|
|
List<ItemData> itemDataList = GetItemDataByDropIdAndType(dropId, mapId);
|
|
LureInflation(itemDataList, inflate);
|
|
return itemDataList;
|
|
}
|
|
/// <summary>
|
|
/// 获得膨胀体力后的物品显示 处理有选定地图鱼卡的情况
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <returns></returns>
|
|
public List<ItemData> GetItemDataByDropIdLureInflation(float? inflate, int dropId, int mapId = -1, bool afterAdding = false)
|
|
{
|
|
List<ItemData> itemDataList = GetItemDataByDropId(dropId, mapId, afterAdding);
|
|
LureInflation(itemDataList, inflate);
|
|
return itemDataList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得膨胀体力后的物品显示
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <param name="dropIDList"></param>
|
|
/// <param name="isShow"></param>
|
|
/// <returns></returns>
|
|
public List<ItemData> GetItemByDropListLureInflation(float? inflate, List<int> dropIDList)
|
|
{
|
|
if (dropIDList == null || dropIDList.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
List<ItemData> itemDataList = new List<ItemData>();
|
|
foreach (var t in dropIDList)
|
|
{
|
|
List<ItemData> itemDatas = GetItemDataByDropIdAndType(t);
|
|
if (itemDatas != null && itemDatas.Count > 0)
|
|
{
|
|
itemDataList.AddRange(itemDatas);
|
|
}
|
|
}
|
|
//itemDataList不需要重复合并
|
|
if (itemDataList.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
LureInflation(itemDataList, inflate);
|
|
return itemDataList;
|
|
}
|
|
/// <summary>
|
|
/// 发放物品 并且膨胀体力
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <param name="dropID"></param>
|
|
/// <param name="isShow"></param>
|
|
/// <param name="rewardType"></param>
|
|
/// <returns></returns>
|
|
public List<ItemData> AddItemByDropLureInflation(float? inflate, int dropID, ChangeSource changeSource, bool isShow = true, RewardType rewardType = RewardType.Normal)
|
|
{
|
|
List<ItemData> itemDataList = GetItemDataByDropIdAndType(dropID);
|
|
if (itemDataList != null)
|
|
{
|
|
LureInflation(itemDataList, inflate);
|
|
if (isShow)
|
|
{
|
|
GContext.Publish(new ShowData(itemDataList, rewardType));
|
|
}
|
|
AddItem(itemDataList, changeSource);
|
|
}
|
|
return itemDataList;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发放物品 并且膨胀体力
|
|
/// </summary>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <param name="dropIDList"></param>
|
|
/// <param name="isShow"></param>
|
|
/// <returns></returns>
|
|
public List<ItemData> AddItemByDropListLureInflation(float? inflate, List<int> dropIDList, ChangeSource changeSource, bool isShow = true, RewardType rewardType = RewardType.Normal)
|
|
{
|
|
if (dropIDList == null || dropIDList.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
List<ItemData> itemDataList = new List<ItemData>();
|
|
foreach (var t in dropIDList)
|
|
{
|
|
List<ItemData> itemDatas = GetItemDataByDropIdAndType(t);
|
|
if (itemDatas != null && itemDatas.Count > 0)
|
|
{
|
|
itemDataList.AddRange(itemDatas);
|
|
}
|
|
}
|
|
//itemDataList不需要重复合并
|
|
if (itemDataList.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
LureInflation(itemDataList, inflate);
|
|
if (isShow)
|
|
{
|
|
GContext.Publish(new ShowData(itemDataList, rewardType));
|
|
}
|
|
AddItem(itemDataList, changeSource);
|
|
return itemDataList;
|
|
}
|
|
/// <summary>
|
|
/// 对 itemDataList 中的体力进行膨胀
|
|
/// </summary>
|
|
/// <param name="itemDataList"></param>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
public void LureInflation(List<ItemData> itemDataList, float? inflate)
|
|
{
|
|
if (inflate == null)
|
|
{
|
|
inflate = GContext.container.Resolve<PlayerData>().InflationRate;//等级膨胀系数
|
|
}
|
|
for (int i = 0; i < itemDataList.Count; i++)
|
|
{
|
|
ItemData itemData = itemDataList[i];
|
|
itemData.inflate = (float)inflate;
|
|
if (itemData.id == 1001)
|
|
{
|
|
itemData.origin = itemData.count;
|
|
itemData.count = IntInflation(itemData.count, inflate);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 智能处理itemData.count的膨胀
|
|
/// </summary>
|
|
/// <param name="itemData"></param>
|
|
/// <param name="inflate"></param>
|
|
/// <returns>True if it needs inflation.</returns>
|
|
public bool LureInflation(ItemData itemData, float? inflate)
|
|
{
|
|
if (itemData.id != 1001)
|
|
return false;
|
|
ItemInflation(itemData, inflate);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 对itemData.count进行膨胀
|
|
/// </summary>
|
|
/// <param name="itemData"></param>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
public void ItemInflation(ItemData itemData, float? inflate)
|
|
{
|
|
itemData.origin = itemData.count;
|
|
if (inflate == null)
|
|
{
|
|
inflate = GContext.container.Resolve<PlayerData>().InflationRate;//等级膨胀系数
|
|
}
|
|
itemData.inflate = (float)inflate;
|
|
itemData.count = IntInflation(itemData.count, inflate);
|
|
}
|
|
/// <summary>
|
|
/// 对数字进行膨胀
|
|
/// </summary>
|
|
/// <param name="origin"></param>
|
|
/// <param name="inflate">体力膨胀系数 == null 当前实时系数</param>
|
|
/// <returns></returns>
|
|
public int IntInflation(int origin, float? inflate)
|
|
{
|
|
if (inflate == null)
|
|
{
|
|
inflate = GContext.container.Resolve<PlayerData>().InflationRate;//等级膨胀系数
|
|
}
|
|
if (inflate > 0)
|
|
{
|
|
float count = origin * (1 + inflate.Value);
|
|
var roundingStep = _tables.TbGlobalConfig.LureScaleRoundingStep;
|
|
int stepCount = roundingStep.Count / 2;
|
|
int step = roundingStep[stepCount * 2];
|
|
for (int i = 0; i < stepCount; i++)
|
|
{
|
|
if (count <= roundingStep[i])
|
|
{
|
|
step = roundingStep[i + stepCount];
|
|
break;
|
|
}
|
|
}
|
|
|
|
float a = count / step;
|
|
var b = Math.Round(a, MidpointRounding.AwayFromZero);
|
|
origin = (int)b * step;
|
|
}
|
|
return origin;
|
|
}
|
|
}
|
|
} |