扩充游戏内容,保持敌人基本行为不变,使用缩放和颜色区分不同敌人
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
@@ -30,6 +31,10 @@ namespace SepCore.DataTable
|
||||
|
||||
public float DropPercent { get; private set; }
|
||||
|
||||
public float Scale { get; private set; } = 1f;
|
||||
|
||||
public Color Color { get; private set; } = Color.white;
|
||||
|
||||
public Dictionary<string, string> Params { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
@@ -50,17 +55,23 @@ namespace SepCore.DataTable
|
||||
DropCoin = int.Parse(columnStrings[index++]);
|
||||
DropExp = int.Parse(columnStrings[index++]);
|
||||
DropPercent = float.Parse(columnStrings[index++]);
|
||||
Scale = float.Parse(columnStrings[index++]);
|
||||
Color = ParseColor(columnStrings[index++]);
|
||||
Params = DeserializeParams(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解参数
|
||||
/// </summary>
|
||||
/// <param name="rawParams"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
private static Color ParseColor(string raw)
|
||||
{
|
||||
if (ColorUtility.TryParseHtmlString(raw.Trim(), out Color color))
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> DeserializeParams(string rawParams)
|
||||
{
|
||||
if (!rawParams.StartsWith('[') || !rawParams.EndsWith(']'))
|
||||
|
||||
@@ -5,5 +5,10 @@ namespace SepCore.Definition
|
||||
None = 0,
|
||||
MeleeEnemy = 1,
|
||||
RemoteEnemy = 2,
|
||||
BatEnemy = 3,
|
||||
SkeletonEnemy = 4,
|
||||
SkeletonGiantEnemy = 5,
|
||||
GhostEnemy = 6,
|
||||
FireMageEnemy = 7,
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,10 @@ namespace SepCore.Entity
|
||||
|
||||
public float DropPercent => _drEnemy.DropPercent;
|
||||
|
||||
public float Scale => _drEnemy.Scale;
|
||||
|
||||
public Color Color => _drEnemy.Color;
|
||||
|
||||
public IReadOnlyDictionary<string, string> Params => _drEnemy.Params;
|
||||
|
||||
public bool TryGetParam(string key, out string value)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
public class BatEnemy : MeleeEnemy
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42fe1320652aa5444ab6b8ed8936d053
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,9 +12,18 @@ public abstract class EnemyBase : TargetableObject
|
||||
public virtual float AttackRange => 1f;
|
||||
|
||||
public virtual void SetTarget(Transform target) => _target = target;
|
||||
|
||||
|
||||
protected EnemyData _enemyData;
|
||||
|
||||
|
||||
protected override void OnShow(object userData)
|
||||
{
|
||||
base.OnShow(userData);
|
||||
|
||||
if (userData is EnemyData enemyData)
|
||||
{
|
||||
ApplyVisualParams(enemyData);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDead(EntityBase attacker)
|
||||
{
|
||||
@@ -35,8 +44,21 @@ public abstract class EnemyBase : TargetableObject
|
||||
};
|
||||
GameEntry.Entity.ShowExpAsync(data).Forget();
|
||||
}
|
||||
|
||||
|
||||
base.OnDead(attacker);
|
||||
}
|
||||
|
||||
private void ApplyVisualParams(EnemyData data)
|
||||
{
|
||||
CachedTransform.localScale = Vector3.one * Mathf.Max(0.1f, data.Scale);
|
||||
|
||||
var renderer = GetComponentInChildren<Renderer>();
|
||||
if (renderer != null)
|
||||
{
|
||||
var block = new MaterialPropertyBlock();
|
||||
block.SetColor("_BaseColor", data.Color);
|
||||
renderer.SetPropertyBlock(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
public class FireMageEnemy : RemoteEnemy
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c04fa71c274a6f4088722608ba26587
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
public class GhostEnemy : RemoteEnemy
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2effd123b7296e448aea20b34fd24ce8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
public class SkeletonEnemy : MeleeEnemy
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21ea777a602cd034cb6177ef0efdea42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
public class SkeletonGiantEnemy : MeleeEnemy
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3698c16c2f366404cbdd54efa880612b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user