init
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edd16bf2e418bec43bc774c7fc6c60d6
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026145
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,140 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 游戏入口。
|
||||
/// </summary>
|
||||
public partial class GameEntry : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取游戏基础组件。
|
||||
/// </summary>
|
||||
public static BaseComponent Base { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置组件。
|
||||
/// </summary>
|
||||
public static ConfigComponent Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据结点组件。
|
||||
/// </summary>
|
||||
public static DataNodeComponent DataNode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据表组件。
|
||||
/// </summary>
|
||||
public static DataTableComponent DataTable { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取调试组件。
|
||||
/// </summary>
|
||||
public static DebuggerComponent Debugger { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载组件。
|
||||
/// </summary>
|
||||
public static DownloadComponent Download { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体组件。
|
||||
/// </summary>
|
||||
public static EntityComponent Entity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取事件组件。
|
||||
/// </summary>
|
||||
public static EventComponent Event { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件系统组件。
|
||||
/// </summary>
|
||||
public static FileSystemComponent FileSystem { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取有限状态机组件。
|
||||
/// </summary>
|
||||
public static FsmComponent Fsm { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取本地化组件。
|
||||
/// </summary>
|
||||
public static LocalizationComponent Localization { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取网络组件。
|
||||
/// </summary>
|
||||
public static NetworkComponent Network { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取对象池组件。
|
||||
/// </summary>
|
||||
public static ObjectPoolComponent ObjectPool { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取流程组件。
|
||||
/// </summary>
|
||||
public static ProcedureComponent Procedure { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源组件。
|
||||
/// </summary>
|
||||
public static ResourceComponent Resource { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取场景组件。
|
||||
/// </summary>
|
||||
public static SceneComponent Scene { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取配置组件。
|
||||
/// </summary>
|
||||
public static SettingComponent Setting { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音组件。
|
||||
/// </summary>
|
||||
public static SoundComponent Sound { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组件。
|
||||
/// </summary>
|
||||
public static UIComponent UI { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取网络组件。
|
||||
/// </summary>
|
||||
public static WebRequestComponent WebRequest { get; private set; }
|
||||
|
||||
private static void InitBuiltinComponents()
|
||||
{
|
||||
Base = UnityGameFramework.Runtime.GameEntry.GetComponent<BaseComponent>();
|
||||
Config = UnityGameFramework.Runtime.GameEntry.GetComponent<ConfigComponent>();
|
||||
DataNode = UnityGameFramework.Runtime.GameEntry.GetComponent<DataNodeComponent>();
|
||||
DataTable = UnityGameFramework.Runtime.GameEntry.GetComponent<DataTableComponent>();
|
||||
Debugger = UnityGameFramework.Runtime.GameEntry.GetComponent<DebuggerComponent>();
|
||||
Download = UnityGameFramework.Runtime.GameEntry.GetComponent<DownloadComponent>();
|
||||
Entity = UnityGameFramework.Runtime.GameEntry.GetComponent<EntityComponent>();
|
||||
Event = UnityGameFramework.Runtime.GameEntry.GetComponent<EventComponent>();
|
||||
FileSystem = UnityGameFramework.Runtime.GameEntry.GetComponent<FileSystemComponent>();
|
||||
Fsm = UnityGameFramework.Runtime.GameEntry.GetComponent<FsmComponent>();
|
||||
Localization = UnityGameFramework.Runtime.GameEntry.GetComponent<LocalizationComponent>();
|
||||
Network = UnityGameFramework.Runtime.GameEntry.GetComponent<NetworkComponent>();
|
||||
ObjectPool = UnityGameFramework.Runtime.GameEntry.GetComponent<ObjectPoolComponent>();
|
||||
Procedure = UnityGameFramework.Runtime.GameEntry.GetComponent<ProcedureComponent>();
|
||||
Resource = UnityGameFramework.Runtime.GameEntry.GetComponent<ResourceComponent>();
|
||||
Scene = UnityGameFramework.Runtime.GameEntry.GetComponent<SceneComponent>();
|
||||
Setting = UnityGameFramework.Runtime.GameEntry.GetComponent<SettingComponent>();
|
||||
Sound = UnityGameFramework.Runtime.GameEntry.GetComponent<SoundComponent>();
|
||||
UI = UnityGameFramework.Runtime.GameEntry.GetComponent<UIComponent>();
|
||||
WebRequest = UnityGameFramework.Runtime.GameEntry.GetComponent<WebRequestComponent>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98387342fa09ebd46a2ab54100d80c2f
|
||||
timeCreated: 1528026146
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GeometryTD.CustomComponent;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏入口。
|
||||
/// </summary>
|
||||
public partial class GameEntry : MonoBehaviour
|
||||
{
|
||||
public static BuiltinDataComponent BuiltinData { get; private set; }
|
||||
|
||||
public static HPBarComponent HPBar { get; private set; }
|
||||
|
||||
public static EnemyManagerComponent EnemyManager { get; private set; }
|
||||
|
||||
private static void InitCustomComponents()
|
||||
{
|
||||
BuiltinData = UnityGameFramework.Runtime.GameEntry.GetComponent<BuiltinDataComponent>();
|
||||
HPBar = UnityGameFramework.Runtime.GameEntry.GetComponent<HPBarComponent>();
|
||||
EnemyManager = UnityGameFramework.Runtime.GameEntry.GetComponent<EnemyManagerComponent>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f95ee7b97daca3f44a2f5cf743bb39ac
|
||||
timeCreated: 1528026146
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏入口。
|
||||
/// </summary>
|
||||
public partial class GameEntry : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
InitBuiltinComponents();
|
||||
InitCustomComponents();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d09b8a3e8c0e7e4dbcfd2fa52bf69ea
|
||||
timeCreated: 1528026145
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20cdfc6b68f9f074a88435387f8f30a3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Components
|
||||
{
|
||||
public class InputComponent : MonoBehaviour
|
||||
{
|
||||
private PlayerInputActions _inputActions;
|
||||
private bool _isListening = false;
|
||||
|
||||
private Vector3 _direction = Vector3.zero;
|
||||
public Vector3 Direction => _direction;
|
||||
|
||||
public void OnInit()
|
||||
{
|
||||
_inputActions = new();
|
||||
}
|
||||
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (_isListening && _inputActions != null)
|
||||
{
|
||||
ReadInput();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_inputActions = null;
|
||||
_isListening = false;
|
||||
}
|
||||
|
||||
private void ReadInput()
|
||||
{
|
||||
Vector2 rawDir = _inputActions.Game.Move.ReadValue<Vector2>();
|
||||
_direction = new Vector3(rawDir.x, 0, rawDir.y);
|
||||
}
|
||||
|
||||
public void SetListening(bool isListening)
|
||||
{
|
||||
_isListening = isListening;
|
||||
if (_isListening)
|
||||
{
|
||||
_inputActions.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
_inputActions.Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f754cc5f339dcfa4aaec3aa32260c4b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Components
|
||||
{
|
||||
public class MovementComponent : MonoBehaviour
|
||||
{
|
||||
private bool _isMoving = false;
|
||||
private Vector3 _direction = Vector3.forward;
|
||||
private float _speed = 0;
|
||||
private Transform _cachedTransform;
|
||||
|
||||
public void OnInit(float speed, Transform transform)
|
||||
{
|
||||
_speed = speed;
|
||||
_cachedTransform = transform;
|
||||
}
|
||||
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (_isMoving && _cachedTransform != null)
|
||||
{
|
||||
Move(elapseSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_speed = 0;
|
||||
_cachedTransform = null;
|
||||
_isMoving = false;
|
||||
}
|
||||
|
||||
private void Move(float deltaTime = 0)
|
||||
{
|
||||
_cachedTransform.Translate(_direction * _speed * deltaTime);
|
||||
}
|
||||
|
||||
public void SetMove(bool isMoving) => _isMoving = isMoving;
|
||||
public void SetDirection(Vector3 direction) => _direction = direction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9baf591df06b9bb44ba5313457ba84b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ba0562010e2da46883baefb271f573
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026146
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class BuiltinDataComponent : GameFrameworkComponent
|
||||
{
|
||||
[FormerlySerializedAs("m_BuildInfoTextAsset")] [SerializeField] private TextAsset _buildInfoTextAsset = null;
|
||||
|
||||
[FormerlySerializedAs("m_DefaultDictionaryTextAsset")] [SerializeField] private TextAsset _defaultDictionaryTextAsset = null;
|
||||
|
||||
[FormerlySerializedAs("m_UpdateResourceFormTemplate")] [SerializeField] private UpdateResourceForm _updateResourceFormTemplate = null;
|
||||
|
||||
private BuildInfo _buildInfo = null;
|
||||
|
||||
public BuildInfo BuildInfo => _buildInfo;
|
||||
|
||||
public UpdateResourceForm UpdateResourceFormTemplate => _updateResourceFormTemplate;
|
||||
|
||||
public void InitBuildInfo()
|
||||
{
|
||||
if (_buildInfoTextAsset == null || string.IsNullOrEmpty(_buildInfoTextAsset.text))
|
||||
{
|
||||
Log.Info("Build info can not be found or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
_buildInfo = Utility.Json.ToObject<BuildInfo>(_buildInfoTextAsset.text);
|
||||
if (_buildInfo == null)
|
||||
{
|
||||
Log.Warning("Parse build info failure.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitDefaultDictionary()
|
||||
{
|
||||
if (_defaultDictionaryTextAsset == null || string.IsNullOrEmpty(_defaultDictionaryTextAsset.text))
|
||||
{
|
||||
Log.Info("Default dictionary can not be found or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GameEntry.Localization.ParseData(_defaultDictionaryTextAsset.text))
|
||||
{
|
||||
Log.Warning("Parse default dictionary failure.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfb0b001fcb30fe45ac95ddb8c28ba57
|
||||
timeCreated: 1528026146
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 259253e364fe32a4195e182f78b8cc54
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using GeometryTD.Entity;
|
||||
using GeometryTD.Entity.EntityData;
|
||||
using GameFramework.Event;
|
||||
using GeometryTD;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class EnemyManagerComponent : GameFrameworkComponent
|
||||
{
|
||||
private EntityComponent _entity;
|
||||
|
||||
private float _spawnEnemyInterval = 5f;
|
||||
private float _spawnEnemyTimer;
|
||||
private float _spawnEnemyAccelerate = 0.5f;
|
||||
private int _spawnEnemyCount = 5;
|
||||
private int _spawnEnemyMaxCount = 5000;
|
||||
private int _currentEnemyCount;
|
||||
private int _spawnDistanceFromPlayer = 10;
|
||||
private int _currentSpawnEnemyId = 0;
|
||||
|
||||
private Transform _player;
|
||||
|
||||
public void OnInit()
|
||||
{
|
||||
_entity = GameEntry.Entity;
|
||||
|
||||
GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
|
||||
GameEntry.Event.Subscribe(ShowEntityFailureEventArgs.EventId, OnShowEntityFailure);
|
||||
GameEntry.Event.Subscribe(HideEntityCompleteEventArgs.EventId, OnHideEntityComplete);
|
||||
}
|
||||
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
_spawnEnemyTimer += elapseSeconds;
|
||||
if (_spawnEnemyTimer < _spawnEnemyInterval) return;
|
||||
SpawnEnemy();
|
||||
_spawnEnemyTimer = 0;
|
||||
_spawnEnemyInterval = Mathf.Max(0.1f, _spawnEnemyInterval - _spawnEnemyAccelerate);
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
|
||||
GameEntry.Event.Unsubscribe(ShowEntityFailureEventArgs.EventId, OnShowEntityFailure);
|
||||
GameEntry.Event.Unsubscribe(HideEntityCompleteEventArgs.EventId, OnHideEntityComplete);
|
||||
}
|
||||
|
||||
private void SpawnEnemy()
|
||||
{
|
||||
if (_player == null) return;
|
||||
for (int i = 0; i < _spawnEnemyCount; i++)
|
||||
{
|
||||
if (_currentEnemyCount >= _spawnEnemyMaxCount) break;
|
||||
_entity.ShowEnemy(new EnemyData(_currentSpawnEnemyId % _spawnEnemyMaxCount, 1001, _player,
|
||||
GetRandomPosition(), 10, 2));
|
||||
_currentSpawnEnemyId++;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 GetRandomPosition()
|
||||
{
|
||||
float x = Random.Range(-1f, 1f);
|
||||
float z = Random.Range(-1f, 1f);
|
||||
Vector3 dir = new Vector3(x, 0, z).normalized;
|
||||
return _player.position + dir * _spawnDistanceFromPlayer;
|
||||
}
|
||||
|
||||
private void OnShowEntitySuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is ShowEntitySuccessEventArgs ne)
|
||||
{
|
||||
if (ne.EntityLogicType == typeof(Enemy))
|
||||
{
|
||||
_currentEnemyCount++;
|
||||
}
|
||||
|
||||
if (ne.EntityLogicType == typeof(Player))
|
||||
{
|
||||
_player = ne.Entity.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShowEntityFailure(object sender, GameEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnHideEntityComplete(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is HideEntityCompleteEventArgs ne)
|
||||
{
|
||||
if (ne.EntityGroup.Name == "Enemy")
|
||||
{
|
||||
_currentEnemyCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d840df1b53db744cb522b82426f2cd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f75cb14d28565904e89eb5765829c210
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026155
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,123 @@
|
||||
using GameFramework.ObjectPool;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.Entity;
|
||||
using GeometryTD;
|
||||
using GeometryTD.PoolObjectBase;
|
||||
using GeometryTD.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
public class HPBarComponent : GameFrameworkComponent
|
||||
{
|
||||
[FormerlySerializedAs("m_HPBarItemTemplate")] [SerializeField]
|
||||
private HPBarItem _hpBarItemTemplate = null;
|
||||
|
||||
[FormerlySerializedAs("m_HPBarInstanceRoot")] [SerializeField]
|
||||
private Transform _hpBarInstanceRoot = null;
|
||||
|
||||
[FormerlySerializedAs("m_InstancePoolCapacity")] [SerializeField]
|
||||
private int _instancePoolCapacity = 16;
|
||||
|
||||
private IObjectPool<HPBarItemObject> _hpBarItemObjectPool = null;
|
||||
private List<HPBarItem> _activeHPBarItems = null;
|
||||
private Canvas _cachedCanvas = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_hpBarInstanceRoot == null)
|
||||
{
|
||||
Log.Error("You must set HP bar instance root first.");
|
||||
return;
|
||||
}
|
||||
|
||||
_cachedCanvas = _hpBarInstanceRoot.GetComponent<Canvas>();
|
||||
_hpBarItemObjectPool =
|
||||
GameEntry.ObjectPool.CreateSingleSpawnObjectPool<HPBarItemObject>("HPBarItem", _instancePoolCapacity);
|
||||
_activeHPBarItems = new List<HPBarItem>();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
for (int i = _activeHPBarItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
HPBarItem hpBarItem = _activeHPBarItems[i];
|
||||
if (hpBarItem.Refresh())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
HideHPBar(hpBarItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowHPBar(EntityBase entity, float fromHPRatio, float toHPRatio)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
Log.Warning("Entity is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
HPBarItem hpBarItem = GetActiveHPBarItem(entity);
|
||||
if (hpBarItem == null)
|
||||
{
|
||||
hpBarItem = CreateHPBarItem(entity);
|
||||
_activeHPBarItems.Add(hpBarItem);
|
||||
}
|
||||
|
||||
hpBarItem.Init(entity, _cachedCanvas, fromHPRatio, toHPRatio);
|
||||
}
|
||||
|
||||
private void HideHPBar(HPBarItem hpBarItem)
|
||||
{
|
||||
hpBarItem.Reset();
|
||||
_activeHPBarItems.Remove(hpBarItem);
|
||||
_hpBarItemObjectPool.Unspawn(hpBarItem);
|
||||
}
|
||||
|
||||
private HPBarItem GetActiveHPBarItem(EntityBase entity)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _activeHPBarItems.Count; i++)
|
||||
{
|
||||
if (_activeHPBarItems[i].Owner == entity)
|
||||
{
|
||||
return _activeHPBarItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private HPBarItem CreateHPBarItem(EntityBase entity)
|
||||
{
|
||||
HPBarItem hpBarItem = null;
|
||||
HPBarItemObject hpBarItemObject = _hpBarItemObjectPool.Spawn();
|
||||
if (hpBarItemObject != null)
|
||||
{
|
||||
hpBarItem = (HPBarItem)hpBarItemObject.Target;
|
||||
}
|
||||
else
|
||||
{
|
||||
hpBarItem = Instantiate(_hpBarItemTemplate);
|
||||
Transform transform = hpBarItem.GetComponent<Transform>();
|
||||
transform.SetParent(_hpBarInstanceRoot);
|
||||
transform.localScale = Vector3.one;
|
||||
_hpBarItemObjectPool.Register(HPBarItemObject.Create(hpBarItem), true);
|
||||
}
|
||||
|
||||
return hpBarItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 879e921586721514f9f85de777050af4
|
||||
timeCreated: 1528026155
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
using GeometryTD.UI;
|
||||
|
||||
namespace CustomComponent
|
||||
{
|
||||
public class UIRouterComponent : GameFrameworkComponent
|
||||
{
|
||||
private readonly Dictionary<UIFormType, IUIFormController> _routeControllers = new();
|
||||
|
||||
public void BindUIUseCase(UIFormType uiFormType, IUIUseCase useCase)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
controller.BindUseCase(useCase);
|
||||
}
|
||||
|
||||
public int? OpenUI(UIFormType uiFormType, object userData = null)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
return controller.OpenUI(userData);
|
||||
}
|
||||
|
||||
public void CloseUI(UIFormType uiFormType)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
controller.CloseUI();
|
||||
}
|
||||
|
||||
private IUIFormController GetOrCreateController(UIFormType uiFormType)
|
||||
{
|
||||
if (_routeControllers.TryGetValue(uiFormType, out IUIFormController controller))
|
||||
{
|
||||
return controller;
|
||||
}
|
||||
|
||||
string typename = $"UI.{uiFormType}Controller";
|
||||
Type controllerType = Type.GetType(typename);
|
||||
if (controllerType == null)
|
||||
{
|
||||
controller = new DefaultUIFormController(uiFormType);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller = (IUIFormController)Activator.CreateInstance(controllerType);
|
||||
}
|
||||
|
||||
_routeControllers.Add(uiFormType, controller);
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach (KeyValuePair<UIFormType, IUIFormController> pair in _routeControllers)
|
||||
{
|
||||
pair.Value.CloseUI();
|
||||
}
|
||||
|
||||
_routeControllers.Clear();
|
||||
}
|
||||
|
||||
private class DefaultUIFormController : IUIFormController
|
||||
{
|
||||
private readonly UIFormType _uiFormType;
|
||||
private int? _lastSerialId;
|
||||
|
||||
public DefaultUIFormController(UIFormType uiFormType)
|
||||
{
|
||||
_uiFormType = uiFormType;
|
||||
}
|
||||
|
||||
public int? OpenUI(object userData = null)
|
||||
{
|
||||
_lastSerialId = GameEntry.UI.OpenUIForm(_uiFormType, userData);
|
||||
return _lastSerialId;
|
||||
}
|
||||
|
||||
public void CloseUI()
|
||||
{
|
||||
if (_lastSerialId.HasValue)
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(_lastSerialId.Value);
|
||||
_lastSerialId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
UGuiForm uiForm = GameEntry.UI.GetUIForm(_uiFormType);
|
||||
if (uiForm != null)
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(uiForm);
|
||||
}
|
||||
}
|
||||
|
||||
public void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c27ab66e930c72847aef7dd05aff8953
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35199cfd0c69c8c42895c16263b21b7b
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026146
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
public static class BinaryReaderExtension
|
||||
{
|
||||
public static Color32 ReadColor32(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte());
|
||||
}
|
||||
|
||||
public static Color ReadColor(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Color(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static DateTime ReadDateTime(this BinaryReader binaryReader)
|
||||
{
|
||||
return new DateTime(binaryReader.ReadInt64());
|
||||
}
|
||||
|
||||
public static Quaternion ReadQuaternion(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Rect ReadRect(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Rect(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector2 ReadVector2(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector3 ReadVector3(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector4 ReadVector4(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector4(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f303871e05cae2d489d6ba3adb6e39d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 底座组件表
|
||||
/// </summary>
|
||||
public class DRBaseComp : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取底座组件编号
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取底座组件实体编号
|
||||
/// </summary>
|
||||
public int EntityId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取底座组件名
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取底座组件攻击速度数组
|
||||
/// </summary>
|
||||
public float[] AttackSpeed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取攻击属性
|
||||
/// </summary>
|
||||
public AttackPropertyType AttackPropertyType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取属性约束
|
||||
/// </summary>
|
||||
public string Constraint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取可能出现的 Tag
|
||||
/// </summary>
|
||||
public TagType[] PossibleTag { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityId = int.Parse(columnStrings[index++]);
|
||||
Name = columnStrings[index++];
|
||||
AttackSpeed = GenerateAttackSpeed(columnStrings[index++]);
|
||||
AttackPropertyType = EnumUtility<AttackPropertyType>.Get(columnStrings[index++]);
|
||||
Constraint = columnStrings[index++];
|
||||
PossibleTag = GeneratePossibleTag(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private float[] GenerateAttackSpeed(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new float[] { };
|
||||
string[] attackSpeedRaws = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = attackSpeedRaws.Length;
|
||||
var attackSpeed = new float[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
attackSpeed[i] = float.Parse(attackSpeedRaws[i]);
|
||||
}
|
||||
|
||||
return attackSpeed;
|
||||
}
|
||||
|
||||
private TagType[] GeneratePossibleTag(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new TagType[] { };
|
||||
string[] tagTypes = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = tagTypes.Length;
|
||||
var tags = new TagType[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
tags[i] = EnumUtility<TagType>.Get(tagTypes[i]);
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85195852df394f6e8fbafe84b0b2faf2
|
||||
timeCreated: 1772076506
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 轴承组件表
|
||||
/// </summary>
|
||||
public class DRBearingComp : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取轴承组件编号
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取轴承组件实体编号
|
||||
/// </summary>
|
||||
public int EntityId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取轴承组件名
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取轴承组件旋转速度数组
|
||||
/// </summary>
|
||||
public float[] RotateSpeed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取攻击范围
|
||||
/// </summary>
|
||||
public float[] AttackRange { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取属性约束
|
||||
/// </summary>
|
||||
public string Constraint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取可能出现的 Tag
|
||||
/// </summary>
|
||||
public TagType[] PossibleTag { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityId = int.Parse(columnStrings[index++]);
|
||||
Name = columnStrings[index++];
|
||||
RotateSpeed = GenerateFloatArray(columnStrings[index++]);
|
||||
AttackRange = GenerateFloatArray(columnStrings[index++]);
|
||||
Constraint = columnStrings[index++];
|
||||
PossibleTag = GeneratePossibleTag(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private float[] GenerateFloatArray(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new float[] { };
|
||||
string[] raws = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = raws.Length;
|
||||
var array = new float[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
array[i] = float.Parse(raws[i]);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
private TagType[] GeneratePossibleTag(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new TagType[] { };
|
||||
string[] tagTypes = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = tagTypes.Length;
|
||||
var tags = new TagType[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
tags[i] = EnumUtility<TagType>.Get(tagTypes[i]);
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 242724cea5be4f87b50be1db1d260b57
|
||||
timeCreated: 1772077331
|
||||
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
// 此文件由工具自动生成,请勿直接修改。
|
||||
// 生成时间:2021-06-16 21:54:35.576
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体表。
|
||||
/// </summary>
|
||||
public class DREntity : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a48a9c6b974d6674f8a0421fc603dc56
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
// 此文件由工具自动生成,请勿直接修改。
|
||||
// 生成时间:2021-06-16 21:54:35.591
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐配置表。
|
||||
/// </summary>
|
||||
public class DRMusic : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取音乐编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5539646031a664344b90aeb64f92930d
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 枪口组件表
|
||||
/// </summary>
|
||||
public class DRMuzzleComp : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取枪口组件编号
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取枪口组件实体编号
|
||||
/// </summary>
|
||||
public int EntityId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取枪口组件名
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取枪口组件攻击伤害数组
|
||||
/// </summary>
|
||||
public int[] AttackDamage { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取攻击伤害浮动
|
||||
/// </summary>
|
||||
public float DamageRandomRate { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取枪口攻击方式
|
||||
/// </summary>
|
||||
public AttackMethodType AttackMethodType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取属性约束
|
||||
/// </summary>
|
||||
public string Constraint { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取可能出现的 Tag
|
||||
/// </summary>
|
||||
public TagType[] PossibleTag { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityId = int.Parse(columnStrings[index++]);
|
||||
Name = columnStrings[index++];
|
||||
AttackDamage = GenerateAttackDamage(columnStrings[index++]);
|
||||
DamageRandomRate = float.Parse(columnStrings[index++]);
|
||||
AttackMethodType = EnumUtility<AttackMethodType>.Get(columnStrings[index++]);
|
||||
Constraint = columnStrings[index++];
|
||||
PossibleTag = GeneratePossibleTag(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private int[] GenerateAttackDamage(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new int[] { };
|
||||
string[] raws = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = raws.Length;
|
||||
var damages = new int[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
damages[i] = int.Parse(raws[i]);
|
||||
}
|
||||
|
||||
return damages;
|
||||
}
|
||||
|
||||
private TagType[] GeneratePossibleTag(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return new TagType[] { };
|
||||
string[] tagTypes = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = tagTypes.Length;
|
||||
var tags = new TagType[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
tags[i] = EnumUtility<TagType>.Get(tagTypes[i]);
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afa6dac48ea94dfd80cb9b05a4f7ee40
|
||||
timeCreated: 1772077515
|
||||
@@ -0,0 +1,87 @@
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 场景配置表。
|
||||
/// </summary>
|
||||
public class DRScene : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取场景编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取背景音乐编号。
|
||||
/// </summary>
|
||||
public int BackgroundMusicId
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
BackgroundMusicId = int.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
BackgroundMusicId = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ce61902e6e3c23409f9ef10ccc8c550
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 声音配置表。
|
||||
/// </summary>
|
||||
public class DRSound : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取优先级(默认0,128最高,-128最低)。
|
||||
/// </summary>
|
||||
public int Priority
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否循环。
|
||||
/// </summary>
|
||||
public bool Loop
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音量(0~1)。
|
||||
/// </summary>
|
||||
public float Volume
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音空间混合量(0为2D,1为3D,中间值混合效果)。
|
||||
/// </summary>
|
||||
public float SpatialBlend
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音最大距离。
|
||||
/// </summary>
|
||||
public float MaxDistance
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
Priority = int.Parse(columnStrings[index++]);
|
||||
Loop = bool.Parse(columnStrings[index++]);
|
||||
Volume = float.Parse(columnStrings[index++]);
|
||||
SpatialBlend = float.Parse(columnStrings[index++]);
|
||||
MaxDistance = float.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
Priority = binaryReader.Read7BitEncodedInt32();
|
||||
Loop = binaryReader.ReadBoolean();
|
||||
Volume = binaryReader.ReadSingle();
|
||||
SpatialBlend = binaryReader.ReadSingle();
|
||||
MaxDistance = binaryReader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc0abcc42a26c844d91d422da22eb94d
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using GeometryTD.CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 枪口组件表
|
||||
/// </summary>
|
||||
public class DRTag : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Tag 编号
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Tag 名
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
public RarityType MinRarity { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
Name = columnStrings[index++];
|
||||
MinRarity = EnumUtility<RarityType>.Get(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ab12ad6f5d94463828cffb4e14a5cf4
|
||||
timeCreated: 1772077822
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
// 此文件由工具自动生成,请勿直接修改。
|
||||
// 生成时间:2021-06-16 21:54:35.652
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面配置表。
|
||||
/// </summary>
|
||||
public class DRUIForm : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组名称。
|
||||
/// </summary>
|
||||
public string UIGroupName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否允许多个界面实例。
|
||||
/// </summary>
|
||||
public bool AllowMultiInstance
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被其覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
UIGroupName = columnStrings[index++];
|
||||
AllowMultiInstance = bool.Parse(columnStrings[index++]);
|
||||
PauseCoveredUIForm = bool.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
UIGroupName = binaryReader.ReadString();
|
||||
AllowMultiInstance = binaryReader.ReadBoolean();
|
||||
PauseCoveredUIForm = binaryReader.ReadBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f28db9f996bc3d04eb73541b1f8b1036
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,108 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
// 此文件由工具自动生成,请勿直接修改。
|
||||
// 生成时间:2021-06-16 21:54:35.666
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 声音配置表。
|
||||
/// </summary>
|
||||
public class DRUISound : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取优先级(默认0,128最高,-128最低)。
|
||||
/// </summary>
|
||||
public int Priority
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音量(0~1)。
|
||||
/// </summary>
|
||||
public float Volume
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
Priority = int.Parse(columnStrings[index++]);
|
||||
Volume = float.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
Priority = binaryReader.Read7BitEncodedInt32();
|
||||
Volume = binaryReader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d69c673440234c24a9718897060d4e14
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.DataTable;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.DataTable
|
||||
{
|
||||
public static class DataTableExtension
|
||||
{
|
||||
private const string DataRowClassPrefixName = "GeometryTD.DataTable.DR";
|
||||
internal static readonly char[] DataSplitSeparators = new char[] { '\t' };
|
||||
internal static readonly char[] DataTrimSeparators = new char[] { '\"' };
|
||||
|
||||
public static void LoadDataTable(this DataTableComponent dataTableComponent, string dataTableName, string dataTableAssetName, object userData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dataTableName))
|
||||
{
|
||||
Log.Warning("Data table name is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] splitedNames = dataTableName.Split('_');
|
||||
if (splitedNames.Length > 2)
|
||||
{
|
||||
Log.Warning("Data table name is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
string dataRowClassName = DataRowClassPrefixName + splitedNames[0];
|
||||
Type dataRowType = Type.GetType(dataRowClassName);
|
||||
if (dataRowType == null)
|
||||
{
|
||||
Log.Warning("Can not get data row type with class name '{0}'.", dataRowClassName);
|
||||
return;
|
||||
}
|
||||
|
||||
string name = splitedNames.Length > 1 ? splitedNames[1] : null;
|
||||
DataTableBase dataTable = dataTableComponent.CreateDataTable(dataRowType, name);
|
||||
dataTable.ReadData(dataTableAssetName, Constant.AssetPriority.DataTableAsset, userData);
|
||||
}
|
||||
|
||||
public static Color32 ParseColor32(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Color32(byte.Parse(splitedValue[0]), byte.Parse(splitedValue[1]), byte.Parse(splitedValue[2]), byte.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Color ParseColor(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Color(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Quaternion ParseQuaternion(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Quaternion(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Rect ParseRect(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Rect(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Vector2 ParseVector2(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector2(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]));
|
||||
}
|
||||
|
||||
public static Vector3 ParseVector3(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector3(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]));
|
||||
}
|
||||
|
||||
public static Vector4 ParseVector4(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector4(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23740ffb8ecb90b48ad986504e1d2474
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5479812568543994bbbcdbee6c42fce1
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d30f1c0886d45b40b4497064082c7f1
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9bfd67d99634cc45a60985500514160
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace GeometryTD
|
||||
{
|
||||
public static partial class Constant
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源优先级。
|
||||
/// </summary>
|
||||
public static class AssetPriority
|
||||
{
|
||||
public const int ConfigAsset = 100;
|
||||
public const int DataTableAsset = 100;
|
||||
public const int DictionaryAsset = 100;
|
||||
public const int FontAsset = 50;
|
||||
public const int MusicAsset = 20;
|
||||
public const int SceneAsset = 0;
|
||||
public const int SoundAsset = 30;
|
||||
public const int UIFormAsset = 50;
|
||||
public const int UISoundAsset = 30;
|
||||
|
||||
public const int MyAircraftAsset = 90;
|
||||
public const int PlayerAsset = 90;
|
||||
public const int AircraftAsset = 80;
|
||||
public const int ThrusterAsset = 30;
|
||||
public const int WeaponAsset = 30;
|
||||
public const int ArmorAsset = 30;
|
||||
public const int BulletAsset = 80;
|
||||
public const int AsteroiAsset = 80;
|
||||
public const int EnemyAsset = 80;
|
||||
public const int EffectAsset = 80;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be044f4c80eead74cb105ed3c02de870
|
||||
timeCreated: 1528830649
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD
|
||||
{
|
||||
public static partial class Constant
|
||||
{
|
||||
/// <summary>
|
||||
/// 层。
|
||||
/// </summary>
|
||||
public static class Layer
|
||||
{
|
||||
public const string DefaultLayerName = "Default";
|
||||
public static readonly int DefaultLayerId = LayerMask.NameToLayer(DefaultLayerName);
|
||||
|
||||
public const string UILayerName = "UI";
|
||||
public static readonly int UILayerId = LayerMask.NameToLayer(UILayerName);
|
||||
|
||||
public const string TargetableObjectLayerName = "Targetable Object";
|
||||
public static readonly int TargetableObjectLayerId = LayerMask.NameToLayer(TargetableObjectLayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a43e7bbaf538cc045aaacf091c7d612e
|
||||
timeCreated: 1528026149
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace GeometryTD
|
||||
{
|
||||
public static partial class Constant
|
||||
{
|
||||
public static class Setting
|
||||
{
|
||||
public const string Language = "Setting.Language";
|
||||
public const string SoundGroupMuted = "Setting.{0}Muted";
|
||||
public const string SoundGroupVolume = "Setting.{0}Volume";
|
||||
public const string MusicMuted = "Setting.MusicMuted";
|
||||
public const string MusicVolume = "Setting.MusicVolume";
|
||||
public const string SoundMuted = "Setting.SoundMuted";
|
||||
public const string SoundVolume = "Setting.SoundVolume";
|
||||
public const string UISoundMuted = "Setting.UISoundMuted";
|
||||
public const string UISoundVolume = "Setting.UISoundVolume";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28dc5d8fb274e45429ff40494dedac8a
|
||||
timeCreated: 1528026149
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af9011f89c35904448c0225db21e8266
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026149
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public class BuildInfo
|
||||
{
|
||||
public string GameVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int InternalGameVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string CheckVersionUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string WindowsAppUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string MacOSAppUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string IOSAppUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public string AndroidAppUrl
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 265686b0408d79949a657768398c72cc
|
||||
timeCreated: 1528026149
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct ImpactData
|
||||
{
|
||||
private readonly CampType m_Camp;
|
||||
private readonly int m_HP;
|
||||
private readonly int m_Attack;
|
||||
private readonly int m_Defense;
|
||||
|
||||
public ImpactData(CampType camp, int hp, int attack, int defense)
|
||||
{
|
||||
m_Camp = camp;
|
||||
m_HP = hp;
|
||||
m_Attack = attack;
|
||||
m_Defense = defense;
|
||||
}
|
||||
|
||||
public CampType Camp
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Camp;
|
||||
}
|
||||
}
|
||||
|
||||
public int HP
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_HP;
|
||||
}
|
||||
}
|
||||
|
||||
public int Attack
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Attack;
|
||||
}
|
||||
}
|
||||
|
||||
public int Defense
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Defense;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22538aa3f76228d48819a9942febb66d
|
||||
timeCreated: 1528026149
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public class VersionInfo
|
||||
{
|
||||
// 是否需要强制更新游戏应用
|
||||
public bool ForceUpdateGame
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 最新的游戏版本号
|
||||
public string LatestGameVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 最新的游戏内部版本号
|
||||
public int InternalGameVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 最新的资源内部版本号
|
||||
public int InternalResourceVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 资源更新下载地址
|
||||
public string UpdatePrefixUri
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 资源版本列表长度
|
||||
public int VersionListLength
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 资源版本列表哈希值
|
||||
public int VersionListHashCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 资源版本列表压缩后长度
|
||||
public int VersionListCompressedLength
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
// 资源版本列表压缩后哈希值
|
||||
public int VersionListCompressedHashCode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1245482e9f20354796d50d6d85d2fe0
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fc27161191c61549a74f80fd54e9645
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public enum AttackMethodType : byte
|
||||
{
|
||||
None = 0,
|
||||
NormalBullet = 1,
|
||||
Range
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 750ce9d0ead04808820adc476d1b5721
|
||||
timeCreated: 1772074485
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public enum AttackPropertyType : byte
|
||||
{
|
||||
None = 0,
|
||||
Physical = 1,
|
||||
Fire = 2,
|
||||
Water = 3,
|
||||
Earth = 4,
|
||||
Poison = 5,
|
||||
Ice = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b2f3f99110c421b9eadcd8a282c900d
|
||||
timeCreated: 1772075049
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 阵营类型。
|
||||
/// </summary>
|
||||
public enum CampType : byte
|
||||
{
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 第一玩家阵营。
|
||||
/// </summary>
|
||||
Player,
|
||||
|
||||
/// <summary>
|
||||
/// 第一敌人阵营。
|
||||
/// </summary>
|
||||
Enemy,
|
||||
|
||||
/// <summary>
|
||||
/// 第一中立阵营。
|
||||
/// </summary>
|
||||
Neutral,
|
||||
|
||||
/// <summary>
|
||||
/// 第二玩家阵营。
|
||||
/// </summary>
|
||||
Player2,
|
||||
|
||||
/// <summary>
|
||||
/// 第二敌人阵营。
|
||||
/// </summary>
|
||||
Enemy2,
|
||||
|
||||
/// <summary>
|
||||
/// 第二中立阵营
|
||||
/// </summary>
|
||||
Neutral2,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61f18b2b0752f32449d9978f481a75fc
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public enum RarityType
|
||||
{
|
||||
None = 0,
|
||||
White = 1,
|
||||
Green = 2,
|
||||
Blue = 3,
|
||||
Purple = 4,
|
||||
Red = 5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47354d3cc3704bd2ae6a9ee37504f5c5
|
||||
timeCreated: 1772077899
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 关系类型。
|
||||
/// </summary>
|
||||
public enum RelationType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 未知的。
|
||||
/// </summary>
|
||||
Unknown,
|
||||
|
||||
/// <summary>
|
||||
/// 友好的。
|
||||
/// </summary>
|
||||
Friendly,
|
||||
|
||||
/// <summary>
|
||||
/// 中立的。
|
||||
/// </summary>
|
||||
Neutral,
|
||||
|
||||
/// <summary>
|
||||
/// 敌对的。
|
||||
/// </summary>
|
||||
Hostile
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c5c37ca396eb9d47a70999b5825152b
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public enum SceneType : byte
|
||||
{
|
||||
Launch = 0,
|
||||
Menu = 1,
|
||||
Main = 2,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20fc28f41ef04f8fa4fbfb9189b58d0d
|
||||
timeCreated: 1768899171
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
public enum TagType : byte
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 元素
|
||||
/// </summary>
|
||||
Fire,
|
||||
BurnSpread,
|
||||
IgniteBurst,
|
||||
Inferno,
|
||||
|
||||
/// <summary>
|
||||
/// 控制
|
||||
/// </summary>
|
||||
Ice,
|
||||
FreezeMask,
|
||||
Shatter,
|
||||
AbsoluteZero,
|
||||
|
||||
/// <summary>
|
||||
/// 穿透
|
||||
/// </summary>
|
||||
Pierce,
|
||||
Crit,
|
||||
Overpenetrate,
|
||||
Execution,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57ef8237f3c54734a73490efebd43a8d
|
||||
timeCreated: 1772075096
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace GeometryTD.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面编号。
|
||||
/// </summary>
|
||||
public enum UIFormType : byte
|
||||
{
|
||||
Undefined = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 弹出框。
|
||||
/// </summary>
|
||||
DialogForm = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 主菜单。
|
||||
/// </summary>
|
||||
MenuForm = 100,
|
||||
|
||||
/// <summary>
|
||||
/// 设置。
|
||||
/// </summary>
|
||||
SettingForm = 101,
|
||||
|
||||
/// <summary>
|
||||
/// 关于。
|
||||
/// </summary>
|
||||
AboutForm = 102,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75fd10c7585513846ab25372be0590b7
|
||||
timeCreated: 1528026162
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7330dc72b718ca14ea10a999060be9f8
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Editor;
|
||||
using UnityGameFramework.Editor.ResourceTools;
|
||||
|
||||
namespace GeometryTD.Editor
|
||||
{
|
||||
public static class GameFrameworkConfigs
|
||||
{
|
||||
[BuildSettingsConfigPath]
|
||||
public static string BuildSettingsConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/BuildSettings.xml"));
|
||||
|
||||
[ResourceCollectionConfigPath]
|
||||
public static string ResourceCollectionConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceCollection.xml"));
|
||||
|
||||
[ResourceEditorConfigPath]
|
||||
public static string ResourceEditorConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceEditor.xml"));
|
||||
|
||||
[ResourceBuilderConfigPath]
|
||||
public static string ResourceBuilderConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceBuilder.xml"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36618c709c84656438dd91e565226606
|
||||
timeCreated: 1528026150
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
using GameFramework;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Editor.ResourceTools;
|
||||
|
||||
namespace GeometryTD.Editor
|
||||
{
|
||||
public sealed class GeometryTDBuildEventHandler : IBuildEventHandler
|
||||
{
|
||||
public bool ContinueOnFailure
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPreprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
{
|
||||
string streamingAssetsPath = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string[] fileNames = Directory.GetFiles(streamingAssetsPath, "*", SearchOption.AllDirectories);
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
if (fileName.Contains(".gitkeep"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
File.Delete(fileName);
|
||||
}
|
||||
|
||||
Utility.Path.RemoveEmptyDirectory(streamingAssetsPath);
|
||||
}
|
||||
|
||||
public void OnPostprocessAllPlatforms(string productName, string companyName, string gameIdentifier, string gameFrameworkVersion, string unityVersion, string applicableGameVersion, int internalResourceVersion,
|
||||
Platform platforms, AssetBundleCompressionType assetBundleCompression, string compressionHelperTypeName, bool additionalCompressionSelected, bool forceRebuildAssetBundleSelected, string buildEventHandlerTypeName, string outputDirectory, BuildAssetBundleOptions buildAssetBundleOptions,
|
||||
string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, string buildReportPath)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPreprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnBuildAssetBundlesComplete(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, AssetBundleManifest assetBundleManifest)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnOutputUpdatableVersionListData(Platform platform, string versionListPath, int versionListLength, int versionListHashCode, int versionListCompressedLength, int versionListCompressedHashCode)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPostprocessPlatform(Platform platform, string workingPath, bool outputPackageSelected, string outputPackagePath, bool outputFullSelected, string outputFullPath, bool outputPackedSelected, string outputPackedPath, bool isSuccess)
|
||||
{
|
||||
if (!outputPackageSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform != Platform.Windows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string streamingAssetsPath = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "StreamingAssets"));
|
||||
string[] fileNames = Directory.GetFiles(outputPackagePath, "*", SearchOption.AllDirectories);
|
||||
foreach (string fileName in fileNames)
|
||||
{
|
||||
string destFileName = Utility.Path.GetRegularPath(Path.Combine(streamingAssetsPath, fileName.Substring(outputPackagePath.Length)));
|
||||
FileInfo destFileInfo = new FileInfo(destFileName);
|
||||
if (!destFileInfo.Directory.Exists)
|
||||
{
|
||||
destFileInfo.Directory.Create();
|
||||
}
|
||||
|
||||
File.Copy(fileName, destFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64311189c3f9ae140b59a31db9831950
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class SceneSwitchLeft
|
||||
{
|
||||
static SceneSwitchLeft()
|
||||
{
|
||||
// 注册到全局工具栏绘制事件
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
|
||||
static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
// 在 Scene 视图的左上角绘制一个下拉菜单
|
||||
Handles.BeginGUI();
|
||||
|
||||
GUILayout.BeginArea(new Rect(10, 10, 200, 100));
|
||||
if (EditorGUILayout.DropdownButton(new GUIContent("快速切换场景"), FocusType.Passive, EditorStyles.toolbarDropDown))
|
||||
{
|
||||
ShowSceneMenu();
|
||||
}
|
||||
GUILayout.EndArea();
|
||||
|
||||
Handles.EndGUI();
|
||||
}
|
||||
|
||||
static void ShowSceneMenu()
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
|
||||
// 查找项目中所有启用(Enabled)的场景
|
||||
string[] sceneGuids = AssetDatabase.FindAssets("t:Scene");
|
||||
|
||||
foreach (string guid in sceneGuids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
string name = Path.GetFileNameWithoutExtension(path);
|
||||
|
||||
menu.AddItem(new GUIContent(name), false, () => {
|
||||
if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
{
|
||||
EditorSceneManager.OpenScene(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7f70b2d5386e4941ab913255891bb99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7c4b051e63f0c2418a55e8817bf4ba9
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58efe0589d7e90f498c8bcbbf94c6be4
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026151
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class EnemyData : EntityDataBase
|
||||
{
|
||||
[SerializeField] private CampType _camp = CampType.Enemy;
|
||||
|
||||
[SerializeField] private int _maxHealth = 0;
|
||||
|
||||
[SerializeField] private float _speed = 0;
|
||||
|
||||
[SerializeField] private Transform _player = null;
|
||||
|
||||
public EnemyData(int entityId, int typeId, Transform player, Vector3 pos, int maxHp, float speed) : base(
|
||||
entityId, typeId)
|
||||
{
|
||||
_maxHealth = maxHp;
|
||||
_speed = speed;
|
||||
Position = pos;
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public CampType Camp
|
||||
{
|
||||
get => _camp;
|
||||
set => _camp = value;
|
||||
}
|
||||
|
||||
public int MaxHealth
|
||||
{
|
||||
get => _maxHealth;
|
||||
set => _maxHealth = value;
|
||||
}
|
||||
|
||||
public float Speed
|
||||
{
|
||||
get => _speed;
|
||||
set => _speed = value;
|
||||
}
|
||||
|
||||
public Transform Player
|
||||
{
|
||||
get => _player;
|
||||
set => _player = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b802c30cc274e04929b8659ec631e84
|
||||
timeCreated: 1768890974
|
||||
@@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_Id = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int m_TypeId = 0;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 m_Position = Vector3.zero;
|
||||
|
||||
[SerializeField]
|
||||
private Quaternion m_Rotation = Quaternion.identity;
|
||||
|
||||
public EntityDataBase(int entityId, int typeId)
|
||||
{
|
||||
m_Id = entityId;
|
||||
m_TypeId = typeId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体编号。
|
||||
/// </summary>
|
||||
public int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型编号。
|
||||
/// </summary>
|
||||
public int TypeId => m_TypeId;
|
||||
|
||||
/// <summary>
|
||||
/// 实体位置。
|
||||
/// </summary>
|
||||
public Vector3 Position
|
||||
{
|
||||
get => m_Position;
|
||||
set => m_Position = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体朝向。
|
||||
/// </summary>
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get => m_Rotation;
|
||||
set => m_Rotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afb91fe3ed8105e4a96b7bd5917ecc2b
|
||||
timeCreated: 1528026152
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using GeometryTD.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class PlayerData : EntityDataBase
|
||||
{
|
||||
[SerializeField] private CampType _camp = CampType.Player;
|
||||
|
||||
[SerializeField] private int _maxHealth = 0;
|
||||
|
||||
[SerializeField] private float _speed = 0;
|
||||
|
||||
public PlayerData(int entityId, int typeId, int maxHp, float speed) : base(entityId, typeId)
|
||||
{
|
||||
_maxHealth = maxHp;
|
||||
_speed = speed;
|
||||
}
|
||||
|
||||
public CampType Camp
|
||||
{
|
||||
get => _camp;
|
||||
set => _camp = value;
|
||||
}
|
||||
|
||||
public int MaxHealth
|
||||
{
|
||||
get => _maxHealth;
|
||||
set => _maxHealth = value;
|
||||
}
|
||||
|
||||
public float Speed
|
||||
{
|
||||
get => _speed;
|
||||
set => _speed = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b69d3168ac4f442994f8dc4d906daa60
|
||||
timeCreated: 1768890638
|
||||
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.DataTable;
|
||||
using System;
|
||||
using GeometryTD.CustomUtility;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Entity;
|
||||
using GeometryTD.Entity.EntityData;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD
|
||||
{
|
||||
public static class EntityExtension
|
||||
{
|
||||
private static int s_SerialId = 0;
|
||||
|
||||
public static EntityBase GetGameEntity(this EntityComponent entityComponent, int entityId)
|
||||
{
|
||||
UnityGameFramework.Runtime.Entity entity = entityComponent.GetEntity(entityId);
|
||||
if (entity == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (EntityBase)entity.Logic;
|
||||
}
|
||||
|
||||
public static void HideEntity(this EntityComponent entityComponent, EntityBase entity)
|
||||
{
|
||||
entityComponent.HideEntity(entity.Entity);
|
||||
}
|
||||
|
||||
public static void AttachEntity(this EntityComponent entityComponent, EntityBase entityBase, int ownerId,
|
||||
string parentTransformPath = null, object userData = null)
|
||||
{
|
||||
entityComponent.AttachEntity(entityBase.Entity, ownerId, parentTransformPath, userData);
|
||||
}
|
||||
|
||||
public static void ShowPlayer(this EntityComponent entityComponent, PlayerData data)
|
||||
{
|
||||
entityComponent.ShowEntity(typeof(Player), "Player", Constant.AssetPriority.PlayerAsset, data);
|
||||
}
|
||||
|
||||
public static void ShowEnemy(this EntityComponent entityComponent, EnemyData data)
|
||||
{
|
||||
entityComponent.ShowEntity(typeof(Enemy), "Enemy", Constant.AssetPriority.EnemyAsset, data);
|
||||
}
|
||||
|
||||
private static void ShowEntity(this EntityComponent entityComponent, Type logicType, string entityGroup,
|
||||
int priority, EntityDataBase data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
Log.Warning("Data is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
IDataTable<DREntity> dtEntity = GameEntry.DataTable.GetDataTable<DREntity>();
|
||||
DREntity drEntity = dtEntity.GetDataRow(data.TypeId);
|
||||
if (drEntity == null)
|
||||
{
|
||||
Log.Warning("Can not load entity id '{0}' from data table.", data.TypeId.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
entityComponent.ShowEntity(data.Id, logicType, AssetUtility.GetEntityAsset(drEntity.AssetName), entityGroup,
|
||||
priority, data);
|
||||
}
|
||||
|
||||
public static int GenerateSerialId(this EntityComponent entityComponent)
|
||||
{
|
||||
return --s_SerialId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 626632079980ad34595c3b43a062a664
|
||||
timeCreated: 1528026153
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74fbdf043ed3bc141a0a0b09756bc7d2
|
||||
folderAsset: yes
|
||||
timeCreated: 1528026153
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using Components;
|
||||
using GeometryTD.Entity.EntityData;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Entity
|
||||
{
|
||||
public class Enemy : EntityBase
|
||||
{
|
||||
private Transform _target;
|
||||
private float _speed;
|
||||
private MovementComponent _movementComponent;
|
||||
private float _attackRange = 1f;
|
||||
private float _attackRangeSquared;
|
||||
|
||||
protected override void OnInit(object userData)
|
||||
{
|
||||
base.OnInit(userData);
|
||||
|
||||
_movementComponent = GetComponent<MovementComponent>();
|
||||
}
|
||||
|
||||
protected override void OnShow(object userData)
|
||||
{
|
||||
base.OnShow(userData);
|
||||
|
||||
if (userData is EnemyData enemyData)
|
||||
{
|
||||
_speed = enemyData.Speed;
|
||||
_target = enemyData.Player;
|
||||
}
|
||||
|
||||
_movementComponent.OnInit(_speed, this.CachedTransform);
|
||||
_movementComponent.SetMove(true);
|
||||
_attackRangeSquared = _attackRange * _attackRange;
|
||||
}
|
||||
|
||||
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
float distanceSquared = (this.CachedTransform.position - _target.position).sqrMagnitude;
|
||||
if (distanceSquared < _attackRangeSquared)
|
||||
{
|
||||
// 攻击
|
||||
_movementComponent.SetMove(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_movementComponent.SetMove(true);
|
||||
_movementComponent.SetDirection(GetTargetDirection());
|
||||
}
|
||||
|
||||
_movementComponent.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
}
|
||||
|
||||
protected override void OnHide(bool isShutdown, object userData)
|
||||
{
|
||||
_movementComponent.SetMove(false);
|
||||
|
||||
base.OnHide(isShutdown, userData);
|
||||
}
|
||||
|
||||
private Vector3 GetTargetDirection()
|
||||
{
|
||||
return new Vector3(_target.position.x - this.CachedTransform.position.x, 0f,
|
||||
_target.position.z - this.CachedTransform.position.z).normalized;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user