- 补充游戏核心逻辑
- 完成 TodOList P0
- 添加游戏内控制台便于调试
- 增加敌人互斥机制提高运算负载
- 优化互斥算法将游戏性能基准线拉到 1k 敌人
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using Definition.Enum;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class BulletData : EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_OwnerId = 0;
|
||||
|
||||
[SerializeField]
|
||||
private CampType m_OwnerCamp = CampType.Unknown;
|
||||
|
||||
[SerializeField]
|
||||
private int m_Attack = 0;
|
||||
|
||||
[SerializeField]
|
||||
private float m_Speed = 0f;
|
||||
|
||||
public BulletData(int entityId, int typeId, int ownerId, CampType ownerCamp, int attack, float speed)
|
||||
: base(entityId, typeId)
|
||||
{
|
||||
m_OwnerId = ownerId;
|
||||
m_OwnerCamp = ownerCamp;
|
||||
m_Attack = attack;
|
||||
m_Speed = speed;
|
||||
}
|
||||
|
||||
public int OwnerId
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OwnerId;
|
||||
}
|
||||
}
|
||||
|
||||
public CampType OwnerCamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_OwnerCamp;
|
||||
}
|
||||
}
|
||||
|
||||
public int Attack
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Attack;
|
||||
}
|
||||
}
|
||||
|
||||
public float Speed
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,50 +8,51 @@ namespace Entity.EntityData
|
||||
[Serializable]
|
||||
public class EnemyData : TargetableObjectData
|
||||
{
|
||||
[SerializeField] private EnemyType _enemyType;
|
||||
|
||||
[SerializeField] private int _entityTypeId;
|
||||
|
||||
[SerializeField] private float _speedBase = 0;
|
||||
|
||||
|
||||
[SerializeField] private int _dropCoin = 0;
|
||||
|
||||
|
||||
[SerializeField] private int _dropExp = 0;
|
||||
|
||||
|
||||
[SerializeField] private float _dropPercent = 0;
|
||||
|
||||
public EnemyData(int entityId, int typeId, int level) : base(
|
||||
entityId, typeId, CampType.Enemy)
|
||||
public EnemyData(int entityId, EnemyType enemyType, int level) : base(
|
||||
entityId, (int)enemyType, CampType.Enemy)
|
||||
{
|
||||
DREnemy enemyRow = GameEntry.DataTable.GetDataTableRow<DREnemy>(typeId);
|
||||
DREnemy enemyRow = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
|
||||
|
||||
if (enemyRow == null)
|
||||
{
|
||||
throw new Exception($"Enemy data table row is missing, EnemyType='{enemyType}'.");
|
||||
}
|
||||
|
||||
int effectiveLevel = Mathf.Max(1, level);
|
||||
|
||||
_enemyType = enemyType;
|
||||
_entityTypeId = enemyRow.EntityTypeId;
|
||||
MaxHealthBase = enemyRow.MaxHealth + enemyRow.HpAddPerLevel * (effectiveLevel - 1);
|
||||
SpeedBase = enemyRow.Speed;
|
||||
DropCoin = enemyRow.DropCoin;
|
||||
DropExp = enemyRow.DropExp;
|
||||
DropPercent = enemyRow.DropPercent;
|
||||
_speedBase = enemyRow.Speed;
|
||||
_dropCoin = enemyRow.DropCoin;
|
||||
_dropExp = enemyRow.DropExp;
|
||||
_dropPercent = enemyRow.DropPercent;
|
||||
}
|
||||
|
||||
public EnemyType EnemyType => _enemyType;
|
||||
|
||||
public int EntityTypeId => _entityTypeId;
|
||||
|
||||
public override int MaxHealthBase { get; }
|
||||
|
||||
public float SpeedBase
|
||||
{
|
||||
get => _speedBase;
|
||||
set => _speedBase = value;
|
||||
}
|
||||
public float SpeedBase => _speedBase;
|
||||
|
||||
public int DropCoin
|
||||
{
|
||||
get => _dropCoin;
|
||||
set => _dropCoin = value;
|
||||
}
|
||||
public int DropCoin => _dropCoin;
|
||||
|
||||
public int DropExp
|
||||
{
|
||||
get => _dropExp;
|
||||
set => _dropExp = value;
|
||||
}
|
||||
public int DropExp => _dropExp;
|
||||
|
||||
public float DropPercent
|
||||
{
|
||||
get => _dropPercent;
|
||||
set => _dropPercent = value;
|
||||
}
|
||||
public float DropPercent => _dropPercent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DataTable;
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
@@ -10,10 +11,31 @@ namespace Entity.EntityData
|
||||
{
|
||||
private DRWeapon _drWeapon;
|
||||
|
||||
public WeaponData(int entityId, int typeId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, typeId, ownerId, ownerCamp)
|
||||
private int _entityTypeId = 0;
|
||||
|
||||
public WeaponData(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, (int)weaponType, ownerId, ownerCamp)
|
||||
{
|
||||
_drWeapon = GameEntry.DataTable.GetDataTableRow<DRWeapon>(TypeId);
|
||||
_drWeapon = GameEntry.DataTable.GetDataTableRow<DRWeapon>((int)weaponType);
|
||||
|
||||
if (_drWeapon == null)
|
||||
{
|
||||
throw new Exception($"Weapon data table row is missing, WeaponType='{weaponType}'.");
|
||||
}
|
||||
|
||||
_entityTypeId = _drWeapon.EntityTypeId;
|
||||
}
|
||||
|
||||
public WeaponType WeaponType => (WeaponType)_drWeapon.Id;
|
||||
|
||||
public string GetParamsString(string paramsName)
|
||||
{
|
||||
if (!Params.TryGetValue(paramsName.ToLower(), out var value))
|
||||
{
|
||||
throw new Exception($"Parameter '{paramsName}' not found.");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -21,6 +43,8 @@ namespace Entity.EntityData
|
||||
/// </summary>
|
||||
public int Attack => _drWeapon.Attack;
|
||||
|
||||
public int EntityTypeId => _entityTypeId;
|
||||
|
||||
/// <summary>
|
||||
/// 武器名称。
|
||||
/// </summary>
|
||||
@@ -53,7 +77,7 @@ namespace Entity.EntityData
|
||||
/// <summary>
|
||||
/// 额外参数。
|
||||
/// </summary>
|
||||
public string Params => _drWeapon.Pramas;
|
||||
public Dictionary<string, string> Params => _drWeapon.Pramas;
|
||||
|
||||
/// <summary>
|
||||
/// 额外属性。
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
public class WeaponHandgunData : WeaponData
|
||||
{
|
||||
public WeaponHandgunData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponHandgun, ownerId, ownerCamp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16371cc6e2112964d8b5bf7400c862cd
|
||||
timeCreated: 1528026152
|
||||
licenseType: Pro
|
||||
guid: 574d105bf89bf7546a682ed407708034
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@@ -4,7 +4,7 @@ namespace Entity.EntityData
|
||||
{
|
||||
public class WeaponKnifeData : WeaponData
|
||||
{
|
||||
public WeaponKnifeData(int entityId, int typeId, int ownerId, CampType ownerCamp) : base(entityId, typeId,
|
||||
public WeaponKnifeData(int entityId, int ownerId, CampType ownerCamp) : base(entityId, WeaponType.WeaponKnife,
|
||||
ownerId, ownerCamp)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Entity.EntityData
|
||||
{
|
||||
public class WeaponSlashData : WeaponData
|
||||
{
|
||||
public WeaponSlashData(int entityId, int ownerId, CampType ownerCamp)
|
||||
: base(entityId, WeaponType.WeaponSlash, ownerId, ownerCamp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4aa6473525dc4c62aeee02ff562ec453
|
||||
timeCreated: 1771484661
|
||||
Reference in New Issue
Block a user