- 补充游戏核心逻辑
- 完成 TodOList P0
- 添加游戏内控制台便于调试
- 增加敌人互斥机制提高运算负载
- 优化互斥算法将游戏性能基准线拉到 1k 敌人
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Bullet config table.
|
||||
/// Id uses BulletType value.
|
||||
/// </summary>
|
||||
public class DRBullet : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 子弹实体 Id,用于在 DREntity 中查询资源路径
|
||||
/// </summary>
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子弹速度
|
||||
/// </summary>
|
||||
public float Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子弹生存时间
|
||||
/// </summary>
|
||||
public float MaxAliveTime { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
MaxAliveTime = float.Parse(columnStrings[index++]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537419cc75316184b84b9f806b114976
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,12 +5,21 @@ namespace DataTable
|
||||
public class DREnemy : DataRowBase
|
||||
{
|
||||
private int m_id;
|
||||
|
||||
public override int Id => m_id;
|
||||
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
public int MaxHealth { get; private set; }
|
||||
|
||||
public int HpAddPerLevel { get; private set; }
|
||||
|
||||
public float Speed { get; private set; }
|
||||
|
||||
public int DropCoin { get; private set; }
|
||||
|
||||
public int DropExp { get; private set; }
|
||||
|
||||
public float DropPercent { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
@@ -21,6 +30,7 @@ namespace DataTable
|
||||
index++;
|
||||
m_id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
MaxHealth = int.Parse(columnStrings[index++]);
|
||||
HpAddPerLevel = int.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Definition.Enum;
|
||||
using StarForce;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Definition.DataStruct;
|
||||
using CustomUtility;
|
||||
using Definition.Enum;
|
||||
using StarForce;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
@@ -18,7 +17,7 @@ namespace DataTable
|
||||
/// <summary>
|
||||
/// 获取关卡内会生成的实体编号
|
||||
/// </summary>
|
||||
public int[] EntityIds { get; private set; }
|
||||
public EnemyType[] EntityTypes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡内每次生成实体的数量
|
||||
@@ -43,7 +42,7 @@ namespace DataTable
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
GenerateEntityIds(columnStrings[index++]);
|
||||
GenerateEntityTypes(columnStrings[index++]);
|
||||
GenerateEntityCounts(columnStrings[index++]);
|
||||
GenerateIntervals(columnStrings[index++]);
|
||||
Duration = int.Parse(columnStrings[index++]);
|
||||
@@ -56,7 +55,7 @@ namespace DataTable
|
||||
{
|
||||
}
|
||||
|
||||
private void GenerateEntityIds(string raw)
|
||||
private void GenerateEntityTypes(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
@@ -66,10 +65,10 @@ namespace DataTable
|
||||
if (raw.Length == 2) return;
|
||||
string[] entityIds = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = entityIds.Length;
|
||||
EntityIds = new int[length];
|
||||
EntityTypes = new EnemyType[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
EntityIds[i] = int.Parse(entityIds[i]);
|
||||
EntityTypes[i] = EnumUtility<EnemyType>.Get(entityIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using Newtonsoft.Json;
|
||||
using StarForce;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Definition.DataStruct;
|
||||
using GameFramework;
|
||||
using Newtonsoft.Json;
|
||||
using StarForce;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Definition.Enum;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using Entity;
|
||||
using GameFramework;
|
||||
using StarForce;
|
||||
using CustomUtility;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
@@ -22,6 +22,8 @@ namespace DataTable
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器名称。
|
||||
/// </summary>
|
||||
@@ -32,8 +34,19 @@ namespace DataTable
|
||||
/// </summary>
|
||||
public string IconAssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器稀有度
|
||||
/// </summary>
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器价值
|
||||
/// </summary>
|
||||
public int Price { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器价值浮动率
|
||||
/// </summary>
|
||||
public float PriceRandomPercent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +72,7 @@ namespace DataTable
|
||||
/// <summary>
|
||||
/// 获取武器额外参数。
|
||||
/// </summary>
|
||||
public string Pramas { get; private set; }
|
||||
public Dictionary<string, string> Pramas { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器额外属性。
|
||||
@@ -74,6 +87,7 @@ namespace DataTable
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
Title = columnStrings[index++];
|
||||
IconAssetName = columnStrings[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(columnStrings[index++]);
|
||||
@@ -83,7 +97,7 @@ namespace DataTable
|
||||
Cooldown = float.Parse(columnStrings[index++]);
|
||||
AttackRange = float.Parse(columnStrings[index++]);
|
||||
AttackSoundId = int.Parse(columnStrings[index++]);
|
||||
Pramas = columnStrings[index++];
|
||||
Pramas = DeserializeParams(columnStrings[index++]);
|
||||
Modifiers = Utility.Json.ToObject<StatModifier[]>(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
@@ -94,5 +108,30 @@ namespace DataTable
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
|
||||
private Dictionary<string, string> DeserializeParams(string rawParams)
|
||||
{
|
||||
if (!rawParams.StartsWith('[') || !rawParams.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
if (string.IsNullOrEmpty(rawParams)) return dict;
|
||||
|
||||
string[] items = rawParams.Substring(1, rawParams.Length - 2).Split(";");
|
||||
foreach (var item in items)
|
||||
{
|
||||
string entry = item.Trim();
|
||||
if (string.IsNullOrEmpty(entry)) continue;
|
||||
|
||||
string[] pair = entry.Split(':' , StringSplitOptions.RemoveEmptyEntries);
|
||||
if (pair.Length != 2) continue;
|
||||
dict.Add(pair[0].ToLower(), pair[1]);
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user