- 规范 UI 设计成为:
- UIForm 负责展示
- Controller 负责控制
- UseCase 负责业务逻辑
- RawData 负责提供原始数据
- Context 负责为 UIForm 提供数据
- 添加和补充一系列 UI 功能
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
using CustomComponent;
|
||||
using StarForce;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -22,11 +23,14 @@ public partial class GameEntry : MonoBehaviour
|
||||
|
||||
public static SpriteCacheComponent SpriteCache { get; private set; }
|
||||
|
||||
public static UIRouterComponent UIRouter { 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>();
|
||||
SpriteCache = UnityGameFramework.Runtime.GameEntry.GetComponent<SpriteCacheComponent>();
|
||||
UIRouter = UnityGameFramework.Runtime.GameEntry.GetComponent<UIRouterComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ namespace Components
|
||||
/// </summary>
|
||||
[SerializeField] private Transform[] _weaponSlots;
|
||||
|
||||
public IReadOnlyList<WeaponBase> Weapons => _weapons;
|
||||
public IReadOnlyList<PropItem> Props => _props;
|
||||
public int WeaponCapacity => _weaponCapacity;
|
||||
|
||||
public void OnInit(Player player, int weaponCapacity)
|
||||
{
|
||||
_weaponCapacity = weaponCapacity;
|
||||
@@ -97,4 +101,4 @@ namespace Components
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,10 @@ namespace Components
|
||||
{
|
||||
_maxHealthStat = _statComponent.GetStat(StatType.MaxHealth);
|
||||
_maxHealthStatCallback = (modifier, isApply) =>
|
||||
{
|
||||
_statComponent.UpdateStat(_maxHealthStat, modifier, isApply);
|
||||
GameEntry.Event.Fire(this, PlayerHealthChangeEventArgs.Create(0, CurrentHealth, MaxHealth));
|
||||
};
|
||||
_statComponent.Subscribe(StatType.MaxHealth, _maxHealthStatCallback);
|
||||
|
||||
_defenseStat = _statComponent.GetStat(StatType.Defense);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c13ac6879bf568a42b12d798738efd84
|
||||
guid: bce93539c13d79d4fb88e16597c05a27
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Definition.Enum;
|
||||
using UnityGameFramework.Runtime;
|
||||
using 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ec6493d4e6c45d489e1dd3d5c6228a6
|
||||
guid: b3695ff420be99d44ab812d7e1863044
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,207 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// 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.517
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 战机表。
|
||||
/// </summary>
|
||||
public class DRAircraft : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取战机编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取推进器编号。
|
||||
/// </summary>
|
||||
public int ThrusterId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器编号0。
|
||||
/// </summary>
|
||||
public int WeaponId0 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器编号1。
|
||||
/// </summary>
|
||||
public int WeaponId1 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器编号2。
|
||||
/// </summary>
|
||||
public int WeaponId2 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取装甲编号0。
|
||||
/// </summary>
|
||||
public int ArmorId0 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取装甲编号1。
|
||||
/// </summary>
|
||||
public int ArmorId1 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取装甲编号2。
|
||||
/// </summary>
|
||||
public int ArmorId2 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取死亡特效编号。
|
||||
/// </summary>
|
||||
public int DeadEffectId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取死亡声音编号。
|
||||
/// </summary>
|
||||
public int DeadSoundId { 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++;
|
||||
ThrusterId = int.Parse(columnStrings[index++]);
|
||||
WeaponId0 = int.Parse(columnStrings[index++]);
|
||||
WeaponId1 = int.Parse(columnStrings[index++]);
|
||||
WeaponId2 = int.Parse(columnStrings[index++]);
|
||||
ArmorId0 = int.Parse(columnStrings[index++]);
|
||||
ArmorId1 = int.Parse(columnStrings[index++]);
|
||||
ArmorId2 = int.Parse(columnStrings[index++]);
|
||||
DeadEffectId = int.Parse(columnStrings[index++]);
|
||||
DeadSoundId = 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();
|
||||
ThrusterId = binaryReader.Read7BitEncodedInt32();
|
||||
WeaponId0 = binaryReader.Read7BitEncodedInt32();
|
||||
WeaponId1 = binaryReader.Read7BitEncodedInt32();
|
||||
WeaponId2 = binaryReader.Read7BitEncodedInt32();
|
||||
ArmorId0 = binaryReader.Read7BitEncodedInt32();
|
||||
ArmorId1 = binaryReader.Read7BitEncodedInt32();
|
||||
ArmorId2 = binaryReader.Read7BitEncodedInt32();
|
||||
DeadEffectId = binaryReader.Read7BitEncodedInt32();
|
||||
DeadSoundId = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private KeyValuePair<int, int>[] m_WeaponId = null;
|
||||
|
||||
public int WeaponIdCount
|
||||
{
|
||||
get { return m_WeaponId.Length; }
|
||||
}
|
||||
|
||||
public int GetWeaponId(int id)
|
||||
{
|
||||
foreach (KeyValuePair<int, int> i in m_WeaponId)
|
||||
{
|
||||
if (i.Key == id)
|
||||
{
|
||||
return i.Value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new GameFrameworkException(Utility.Text.Format("GetWeaponId with invalid id '{0}'.", id));
|
||||
}
|
||||
|
||||
public int GetWeaponIdAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= m_WeaponId.Length)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("GetWeaponIdAt with invalid index '{0}'.", index));
|
||||
}
|
||||
|
||||
return m_WeaponId[index].Value;
|
||||
}
|
||||
|
||||
private KeyValuePair<int, int>[] m_ArmorId = null;
|
||||
|
||||
public int ArmorIdCount
|
||||
{
|
||||
get { return m_ArmorId.Length; }
|
||||
}
|
||||
|
||||
public int GetArmorId(int id)
|
||||
{
|
||||
foreach (KeyValuePair<int, int> i in m_ArmorId)
|
||||
{
|
||||
if (i.Key == id)
|
||||
{
|
||||
return i.Value;
|
||||
}
|
||||
}
|
||||
|
||||
throw new GameFrameworkException(Utility.Text.Format("GetArmorId with invalid id '{0}'.", id));
|
||||
}
|
||||
|
||||
public int GetArmorIdAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= m_ArmorId.Length)
|
||||
{
|
||||
throw new GameFrameworkException(Utility.Text.Format("GetArmorIdAt with invalid index '{0}'.", index));
|
||||
}
|
||||
|
||||
return m_ArmorId[index].Value;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
m_WeaponId = new KeyValuePair<int, int>[]
|
||||
{
|
||||
new KeyValuePair<int, int>(0, WeaponId0),
|
||||
new KeyValuePair<int, int>(1, WeaponId1),
|
||||
new KeyValuePair<int, int>(2, WeaponId2),
|
||||
};
|
||||
|
||||
m_ArmorId = new KeyValuePair<int, int>[]
|
||||
{
|
||||
new KeyValuePair<int, int>(0, ArmorId0),
|
||||
new KeyValuePair<int, int>(1, ArmorId1),
|
||||
new KeyValuePair<int, int>(2, ArmorId2),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// 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.539
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 装甲表。
|
||||
/// </summary>
|
||||
public class DRArmor : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取装甲编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最大生命。
|
||||
/// </summary>
|
||||
public int MaxHP { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取防御力。
|
||||
/// </summary>
|
||||
public int Defense { 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++;
|
||||
MaxHP = int.Parse(columnStrings[index++]);
|
||||
Defense = 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();
|
||||
MaxHP = binaryReader.Read7BitEncodedInt32();
|
||||
Defense = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// 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.557
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 小行星表。
|
||||
/// </summary>
|
||||
public class DRAsteroid : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取小行星编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最大生命。
|
||||
/// </summary>
|
||||
public int MaxHP { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取冲击力。
|
||||
/// </summary>
|
||||
public int Attack { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取速度。
|
||||
/// </summary>
|
||||
public float Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取角速度。
|
||||
/// </summary>
|
||||
public float AngularSpeed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取死亡特效编号。
|
||||
/// </summary>
|
||||
public int DeadEffectId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取死亡声音编号。
|
||||
/// </summary>
|
||||
public int DeadSoundId { 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++;
|
||||
MaxHP = int.Parse(columnStrings[index++]);
|
||||
Attack = int.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
AngularSpeed = float.Parse(columnStrings[index++]);
|
||||
DeadEffectId = int.Parse(columnStrings[index++]);
|
||||
DeadSoundId = 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();
|
||||
MaxHP = binaryReader.Read7BitEncodedInt32();
|
||||
Attack = binaryReader.Read7BitEncodedInt32();
|
||||
Speed = binaryReader.ReadSingle();
|
||||
AngularSpeed = binaryReader.ReadSingle();
|
||||
DeadEffectId = binaryReader.Read7BitEncodedInt32();
|
||||
DeadSoundId = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 836a293c79cb42e42a7235ebdeb3344f
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,16 +18,6 @@ namespace DataTable
|
||||
/// </summary>
|
||||
public GoodsType GoodsType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取最低价格
|
||||
/// </summary>
|
||||
public int MinPrice { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取最高价格
|
||||
/// </summary>
|
||||
public int MaxPrice { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品对应具体类型的表Id
|
||||
/// </summary>
|
||||
@@ -43,8 +33,6 @@ namespace DataTable
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
GoodsType = EnumUtility<GoodsType>.Get(fields[index++]);
|
||||
MinPrice = int.Parse(fields[index++]);
|
||||
MaxPrice = int.Parse(fields[index++]);
|
||||
GoodsTypeId = int.Parse(fields[index++]);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
using Definition.DataStruct;
|
||||
using Newtonsoft.Json;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
public class DRLevelUpReward : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
|
||||
public string Title { get; private set; }
|
||||
|
||||
public string IconAssetName { get; private set; }
|
||||
|
||||
public StatModifier[] Modifiers { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
int index = 0;
|
||||
|
||||
index++;
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
Title = fields[index++];
|
||||
IconAssetName = fields[index++];
|
||||
Modifiers = JsonConvert.DeserializeObject<StatModifier[]>(fields[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7a6297d01a7dc348b1488bf6245cb1b
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
guid: d84933d61f76d7942a903b8db26a3ad6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@@ -1,7 +1,9 @@
|
||||
using Definition.DataStruct;
|
||||
using GameFramework;
|
||||
using Newtonsoft.Json;
|
||||
using StarForce;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
@@ -12,6 +14,9 @@ namespace DataTable
|
||||
public override int Id => m_Id;
|
||||
public string Title { get; private set; }
|
||||
public string IconAssetName { get; private set; }
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
public int Price { get; private set; }
|
||||
public float PriceRandomPercent { get; private set; }
|
||||
public StatModifier[] Modifiers { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
@@ -24,6 +29,9 @@ namespace DataTable
|
||||
index++;
|
||||
Title = fields[index++];
|
||||
IconAssetName = fields[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(fields[index++]);
|
||||
Price = int.Parse(fields[index++]);
|
||||
PriceRandomPercent = float.Parse(fields[index++]);
|
||||
Modifiers = JsonConvert.DeserializeObject<StatModifier[]>(fields[index++]);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// 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.638
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 推进器表。
|
||||
/// </summary>
|
||||
public class DRThruster : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取推进器编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取。
|
||||
/// </summary>
|
||||
public float Speed { 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++;
|
||||
Speed = 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();
|
||||
Speed = binaryReader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,16 @@ namespace DataTable
|
||||
/// 获取武器名称。
|
||||
/// </summary>
|
||||
public string Title { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取图标资源名称。
|
||||
/// </summary>
|
||||
public string IconAssetName { get; private set; }
|
||||
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
public int Price { get; private set; }
|
||||
public float PriceRandomPercent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器伤害。
|
||||
/// </summary>
|
||||
@@ -51,7 +55,7 @@ namespace DataTable
|
||||
/// 获取武器攻击音效。
|
||||
/// </summary>
|
||||
public int AttackSoundId { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器额外参数。
|
||||
/// </summary>
|
||||
@@ -72,6 +76,9 @@ namespace DataTable
|
||||
index++;
|
||||
Title = columnStrings[index++];
|
||||
IconAssetName = columnStrings[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(columnStrings[index++]);
|
||||
Price = int.Parse(columnStrings[index++]);
|
||||
PriceRandomPercent = float.Parse(columnStrings[index++]);
|
||||
Attack = int.Parse(columnStrings[index++]);
|
||||
Cooldown = float.Parse(columnStrings[index++]);
|
||||
AttackRange = float.Parse(columnStrings[index++]);
|
||||
@@ -80,7 +87,7 @@ namespace DataTable
|
||||
Modifiers = Utility.Json.ToObject<StatModifier[]>(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,44 @@
|
||||
using Components;
|
||||
using DataTable;
|
||||
using Definition.Enum;
|
||||
|
||||
namespace Definition.DataStruct
|
||||
{
|
||||
public class PropItem
|
||||
{
|
||||
private DRProp _prop;
|
||||
|
||||
private readonly StatModifier[] _modifiers;
|
||||
public string Title { get; private set; }
|
||||
public string IconAssetName { get; private set; }
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
public StatModifier[] Modifiers => _modifiers;
|
||||
|
||||
public PropItem(DRProp prop)
|
||||
{
|
||||
_prop = prop;
|
||||
if (prop == null) return;
|
||||
|
||||
_modifiers = prop.Modifiers;
|
||||
Title = prop.Title;
|
||||
Rarity = prop.Rarity;
|
||||
IconAssetName = prop.IconAssetName;
|
||||
}
|
||||
|
||||
public PropItem(StatModifier[] modifiers)
|
||||
{
|
||||
_modifiers = modifiers;
|
||||
}
|
||||
|
||||
public PropItem(StatModifier[] modifiers, ItemRarity rarity, string title, string iconAssetName)
|
||||
{
|
||||
_modifiers = modifiers;
|
||||
Title = title;
|
||||
Rarity = rarity;
|
||||
IconAssetName = iconAssetName;
|
||||
}
|
||||
|
||||
public void OnAttach(StatComponent statComponent)
|
||||
{
|
||||
foreach (var modifier in _prop.Modifiers)
|
||||
if (_modifiers == null || statComponent == null) return;
|
||||
foreach (var modifier in _modifiers)
|
||||
{
|
||||
statComponent.AddModifier(modifier);
|
||||
}
|
||||
@@ -22,7 +46,8 @@ namespace Definition.DataStruct
|
||||
|
||||
public void OnDetach(StatComponent statComponent)
|
||||
{
|
||||
foreach (var modifier in _prop.Modifiers)
|
||||
if (_modifiers == null || statComponent == null) return;
|
||||
foreach (var modifier in _modifiers)
|
||||
{
|
||||
statComponent.RemoveModifier(modifier);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Definition.Enum
|
||||
{
|
||||
public enum ItemRarity
|
||||
{
|
||||
None,
|
||||
White = 1,
|
||||
Green = 2,
|
||||
Blue,
|
||||
Purple,
|
||||
Red
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9b85e7308914ee49bacd872a67716aa
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
guid: bb7ab0222a370b649956dacb56a122fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@@ -12,7 +12,7 @@ namespace Definition.Enum
|
||||
/// </summary>
|
||||
public enum UIFormType : byte
|
||||
{
|
||||
Undefined = 0,
|
||||
TUIForm = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 弹出框。
|
||||
@@ -58,5 +58,10 @@ namespace Definition.Enum
|
||||
/// 升级选择。
|
||||
/// </summary>
|
||||
LevelUpForm = 204,
|
||||
|
||||
/// <summary>
|
||||
/// 物品信息展示页
|
||||
/// </summary>
|
||||
DisplayItemInfoForm = 205,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,20 @@ namespace Entity.EntityData
|
||||
/// </summary>
|
||||
public int Attack => _drWeapon.Attack;
|
||||
|
||||
/// <summary>
|
||||
/// 武器名称。
|
||||
/// </summary>
|
||||
public string Title => _drWeapon.Title;
|
||||
|
||||
/// <summary>
|
||||
/// 图标资源名称。
|
||||
/// </summary>
|
||||
public string IconAssetName => _drWeapon.IconAssetName;
|
||||
|
||||
public ItemRarity Rarity => _drWeapon.Rarity;
|
||||
|
||||
public int Price => _drWeapon.Price;
|
||||
|
||||
/// <summary>
|
||||
/// 攻击间隔。
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Components;
|
||||
using CustomEvent;
|
||||
using DataTable;
|
||||
@@ -63,6 +64,8 @@ namespace Entity
|
||||
{
|
||||
value -= _expRequires[_currentLevel + 1];
|
||||
_currentLevel++;
|
||||
PendingLevelPoints++;
|
||||
GameEntry.Event.Fire(this, PlayerLevelUpEventArgs.Create());
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, PlayerExpChangeEventArgs.Create(value, _expRequires[_currentLevel + 1]));
|
||||
@@ -71,7 +74,19 @@ namespace Entity
|
||||
}
|
||||
|
||||
public int CurrentLevel => _currentLevel;
|
||||
|
||||
|
||||
public int PendingLevelPoints { get; set; }
|
||||
|
||||
public IReadOnlyList<WeaponBase> Weapons => _backpackComponent != null ? _backpackComponent.Weapons : null;
|
||||
public IReadOnlyList<PropItem> Props => _backpackComponent != null ? _backpackComponent.Props : null;
|
||||
public int WeaponCapacity => _backpackComponent != null ? _backpackComponent.WeaponCapacity : 0;
|
||||
|
||||
public bool AddProp(PropItem prop)
|
||||
{
|
||||
if (prop == null || _backpackComponent == null) return false;
|
||||
return _backpackComponent.AttachProp(prop);
|
||||
}
|
||||
|
||||
public bool Enable
|
||||
{
|
||||
get => _enable;
|
||||
|
||||
@@ -24,10 +24,15 @@ namespace Entity
|
||||
public abstract class WeaponBase : EntityBase
|
||||
{
|
||||
protected const string AttachPoint = "Weapon Point";
|
||||
|
||||
protected bool _isAttacking = false;
|
||||
|
||||
protected bool _isEnabled = false;
|
||||
|
||||
public WeaponData WeaponData;
|
||||
|
||||
public bool IsAttacking => _isAttacking;
|
||||
|
||||
protected WeaponStateBase _currentState;
|
||||
|
||||
#region FSM
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace Entity
|
||||
Log.Error("WeaponKnife data is invalid.");
|
||||
return;
|
||||
}
|
||||
WeaponData = _weaponData;
|
||||
|
||||
_collider = GetComponent<Collider>();
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
@@ -329,4 +330,4 @@ namespace Entity
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class DisplayItemHideEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(DisplayItemHideEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
|
||||
public DisplayItemHideEventArgs()
|
||||
{
|
||||
}
|
||||
|
||||
public static DisplayItemHideEventArgs Create()
|
||||
{
|
||||
var args = ReferencePool.Acquire<DisplayItemHideEventArgs>();
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a515c94c54304c79b0fa4761f07a732d
|
||||
timeCreated: 1771071838
|
||||
@@ -0,0 +1,41 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class DisplayItemShowEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(DisplayItemShowEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public int Index { get; private set; }
|
||||
|
||||
public bool IsWeapon { get; private set; }
|
||||
|
||||
public Vector3 TargetPos { get; private set; }
|
||||
|
||||
public DisplayItemShowEventArgs()
|
||||
{
|
||||
Index = -1;
|
||||
IsWeapon = false;
|
||||
}
|
||||
|
||||
public static DisplayItemShowEventArgs Create(int index, bool isWeapon, Vector3 targetPos)
|
||||
{
|
||||
var args = ReferencePool.Acquire<DisplayItemShowEventArgs>();
|
||||
args.Index = index;
|
||||
args.IsWeapon = isWeapon;
|
||||
args.TargetPos = targetPos;
|
||||
return args;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
Index = -1;
|
||||
IsWeapon = false;
|
||||
TargetPos = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51bff2c6818f44398b4b8f7d1448b310
|
||||
timeCreated: 1771071724
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ee8d2a2a12545b8b8cfc85c5fe912ed
|
||||
timeCreated: 1771071689
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fc42c90ffa598d4e89c908ad82116d8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuAboutButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuAboutButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuAboutButtonClickEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuAboutButtonClickEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e945cefd12dc05428a0b4d287784707
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
guid: f58e49962f2db9140aaf209ca65dd2f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuFileButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuFileButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuFileButtonClickEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuFileButtonClickEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e093cff04ac83fc47ae21bd659b338ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuGuideButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuGuideButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuGuideButtonClickEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuGuideButtonClickEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b39712010e7085f428e9ef9727bda043
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuQuitButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuQuitButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuQuitButtonClickEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuQuitButtonClickEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c008a5618fa012842992de55bef3791c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuSelectRoleConfirmEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSelectRoleConfirmEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuSelectRoleConfirmEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuSelectRoleConfirmEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c360f9423f498704dbb32820841451c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuSelectRoleReturnEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSelectRoleReturnEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuSelectRoleReturnEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuSelectRoleReturnEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25cf88630e365d2428872f6bae81001e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuSelectRoleSelectedEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSelectRoleSelectedEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public int RoleId { get; private set; } = -1;
|
||||
|
||||
public static MenuSelectRoleSelectedEventArgs Create(int roleId)
|
||||
{
|
||||
var args = ReferencePool.Acquire<MenuSelectRoleSelectedEventArgs>();
|
||||
args.RoleId = roleId;
|
||||
return args;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
RoleId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c99f1c134cc628142a36d21c209ed507
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuSettingButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSettingButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuSettingButtonClickEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuSettingButtonClickEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5de2367f2bc83642bbbdc02081ae804
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class MenuStartGameEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuStartGameEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuStartGameEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuStartGameEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217b0022ddd4a4545a8d8e3d8158a967
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+5
-5
@@ -3,22 +3,22 @@ using GameFramework.Event;
|
||||
|
||||
namespace CustomEvent
|
||||
{
|
||||
public class ShopRefreshEventArgs : GameEventArgs
|
||||
public class RefreshEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(ShopRefreshEventArgs).GetHashCode();
|
||||
public static readonly int EventId = typeof(RefreshEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public int Cost { get; private set; }
|
||||
|
||||
public ShopRefreshEventArgs()
|
||||
public RefreshEventArgs()
|
||||
{
|
||||
Cost = 0;
|
||||
}
|
||||
|
||||
public static ShopRefreshEventArgs Create(int cost)
|
||||
public static RefreshEventArgs Create(int cost)
|
||||
{
|
||||
var args = ReferencePool.Acquire<ShopRefreshEventArgs>();
|
||||
var args = ReferencePool.Acquire<RefreshEventArgs>();
|
||||
|
||||
args.Cost = cost;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//------------------------------------------------------------
|
||||
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using GameFramework.Resource;
|
||||
@@ -112,7 +113,7 @@ namespace Procedure
|
||||
if (m_VersionInfo.ForceUpdateGame)
|
||||
{
|
||||
// 需要强制更新游戏应用
|
||||
GameEntry.UI.OpenDialog(new DialogParams
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DialogForm, new DialogFormRawData
|
||||
{
|
||||
Mode = 2,
|
||||
Title = GameEntry.Localization.GetString("ForceUpdate.Title"),
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Procedure
|
||||
"Prop",
|
||||
"Role",
|
||||
"Level",
|
||||
"LevelUpReward"
|
||||
};
|
||||
|
||||
private Dictionary<string, bool> _loadedFlag = new Dictionary<string, bool>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using GameFramework;
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using System.Collections.Generic;
|
||||
using Definition.Enum;
|
||||
using StarForce;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
@@ -46,7 +47,7 @@ namespace Procedure
|
||||
|
||||
if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
|
||||
{
|
||||
GameEntry.UI.OpenDialog(new DialogParams
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DialogForm, new DialogFormRawData
|
||||
{
|
||||
Mode = 2,
|
||||
Title = GameEntry.Localization.GetString("UpdateResourceViaCarrierDataNetwork.Title"),
|
||||
|
||||
@@ -11,9 +11,13 @@ namespace Procedure
|
||||
public override GameStateType GameStateType => GameStateType.Battle;
|
||||
|
||||
private EnemyManagerComponent _enemyManager = null;
|
||||
|
||||
private int _currentLevel = 0;
|
||||
|
||||
private bool _levelOver;
|
||||
|
||||
private Player Player => _procedureGame.Player;
|
||||
|
||||
private ProcedureGame _procedureGame = null;
|
||||
|
||||
public void LevelOver()
|
||||
@@ -35,8 +39,8 @@ namespace Procedure
|
||||
_currentLevel = _procedureGame.CurrentLevel;
|
||||
_levelOver = false;
|
||||
_enemyManager.OnInit(_currentLevel, this);
|
||||
Player player = _procedureGame.Player;
|
||||
if (player != null) player.Enable = false;
|
||||
|
||||
if (Player != null) Player.Enable = true;
|
||||
}
|
||||
|
||||
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||
@@ -47,7 +51,7 @@ namespace Procedure
|
||||
if (_levelOver)
|
||||
{
|
||||
procedureOwner.SetData<VarByte>("CurrentLevel", (byte)(_currentLevel + 1));
|
||||
_procedureGame.BattleToShop();
|
||||
_procedureGame.BattleToShopOrLevelUp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +61,7 @@ namespace Procedure
|
||||
_enemyManager.OnReset();
|
||||
|
||||
// 停止玩家逻辑
|
||||
Player player = _procedureGame.Player;
|
||||
player.Enable = false;
|
||||
Player.Enable = false;
|
||||
|
||||
// 隐藏所有掉落物实体
|
||||
var entities = GameEntry.Entity.GetEntityGroup("Drop").GetAllEntities();
|
||||
@@ -76,4 +79,4 @@ namespace Procedure
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using Definition.Enum;
|
||||
using GameFramework.Fsm;
|
||||
using GameFramework.Procedure;
|
||||
using UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace Procedure
|
||||
{
|
||||
public class GameStateLevelUp : GameStateBase
|
||||
{
|
||||
public override GameStateType GameStateType => GameStateType.LevelUp;
|
||||
|
||||
private ProcedureGame _procedureGame;
|
||||
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
#region FSM
|
||||
|
||||
public override void OnInit(ProcedureGame master)
|
||||
{
|
||||
Log.Debug("GameStateLevelUp::OnInit");
|
||||
|
||||
_procedureGame = master;
|
||||
|
||||
var useCase = new LevelUpFormUseCase(_procedureGame.Player, this);
|
||||
GameEntry.UIRouter.BindUIUseCase(UIFormType.LevelUpForm, useCase);
|
||||
}
|
||||
|
||||
public override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
Log.Debug("GameStateLevelUp::OnEnter");
|
||||
|
||||
IsCompleted = false;
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.LevelUpForm);
|
||||
}
|
||||
|
||||
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||
float realElapseSeconds)
|
||||
{
|
||||
if (IsCompleted)
|
||||
{
|
||||
_procedureGame.LevelUpToShop();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLeave(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
Log.Debug("GameStateLevelUp::OnLeave");
|
||||
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.LevelUpForm);
|
||||
}
|
||||
|
||||
public override void OnDestroy(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
_procedureGame = null;
|
||||
|
||||
Log.Debug("GameStateLevelUp::OnDestroy");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be7365d38adfd8546a0f4b964a128abb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,161 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CustomEvent;
|
||||
using DataTable;
|
||||
using Definition.Enum;
|
||||
using Entity;
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.Fsm;
|
||||
using GameFramework.Procedure;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Procedure
|
||||
{
|
||||
public class GameStateShop : GameStateBase
|
||||
{
|
||||
#region Property
|
||||
|
||||
public override GameStateType GameStateType => GameStateType.Shop;
|
||||
|
||||
private ProcedureGame _procedureGame;
|
||||
|
||||
private DRGoods[] _drGoods;
|
||||
|
||||
private DRProp[] _drProps;
|
||||
private IDataTable<DRProp> _propDataTable;
|
||||
|
||||
private IDataTable<DRWeapon> _weaponDataTable;
|
||||
|
||||
private ShopFormController _shopFormController;
|
||||
private ShopFormContext _shopFormContext;
|
||||
|
||||
private LevelUpFormController _levelUpFormController;
|
||||
private LevelUpFormContext _levelUpFormContext;
|
||||
|
||||
private int _shopRefreshTime = 0;
|
||||
|
||||
private Player _player => _procedureGame.Player;
|
||||
|
||||
private bool _shopOver = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#region LevelUp
|
||||
|
||||
private LevelUpFormContext BuildLevelUpFormContext(int count = 4)
|
||||
{
|
||||
List<LevelUpPropContext> props = new List<LevelUpPropContext>();
|
||||
int total = _drProps.Length;
|
||||
if (total <= 0)
|
||||
{
|
||||
Log.Error("GameStateShop::BuildLevelUpFormContext(): _drProps == null");
|
||||
return null;
|
||||
}
|
||||
|
||||
count = Mathf.Min(count, total);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int index = Random.Range(0, total);
|
||||
DRProp drProp = _drProps[index];
|
||||
props.Add(new LevelUpPropContext
|
||||
{
|
||||
PropId = drProp.Id,
|
||||
Title = drProp.Title,
|
||||
Type = "Prop",
|
||||
Icon = null,
|
||||
Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers),
|
||||
IconAssetName = drProp.IconAssetName
|
||||
});
|
||||
}
|
||||
|
||||
return new LevelUpFormContext
|
||||
{
|
||||
Level = _player.CurrentLevel,
|
||||
Props = props
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shop
|
||||
|
||||
private void RefreshGoodsItems()
|
||||
{
|
||||
_shopFormContext = BuildShopFormContext();
|
||||
_shopFormContext.RefreshPrice = (_shopRefreshTime + 1) * _procedureGame.CurrentLevel;
|
||||
_shopRefreshTime++;
|
||||
_shopFormController.OpenUI(_shopFormContext);
|
||||
}
|
||||
|
||||
private ShopFormContext BuildShopFormContext()
|
||||
{
|
||||
int currentLevel = _procedureGame.CurrentLevel;
|
||||
var context = new ShopFormContext
|
||||
{
|
||||
CurrentLevel = currentLevel,
|
||||
RefreshPrice = currentLevel,
|
||||
PlayerCoin = _player.Coin,
|
||||
GoodsItems = InitRandomGoodsItems()
|
||||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
private List<GoodsItemContext> InitRandomGoodsItems(int count = -1)
|
||||
{
|
||||
if (_drGoods == null || _drGoods.Length == 0)
|
||||
{
|
||||
Log.Error("GameStateShop::InitRandomGoodsItems(): _drGoods == null");
|
||||
return null;
|
||||
}
|
||||
|
||||
count = Mathf.Max(count, Random.Range(4, 6));
|
||||
int totalCount = _drGoods.Length;
|
||||
List<GoodsItemContext> items = new List<GoodsItemContext>(count);
|
||||
if (totalCount <= 0) return items;
|
||||
count = Mathf.Min(count, totalCount);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int index = Random.Range(0, totalCount);
|
||||
DRGoods drGoods = _drGoods[index];
|
||||
GoodsItemContext goodsItem = new GoodsItemContext
|
||||
{
|
||||
Price = Random.Range(drGoods.MinPrice, drGoods.MaxPrice)
|
||||
};
|
||||
|
||||
if (drGoods.GoodsType == GoodsType.Prop)
|
||||
{
|
||||
DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||
goodsItem.Title = drProp.Title;
|
||||
goodsItem.Type = "Prop";
|
||||
GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||
goodsItem.Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers);
|
||||
}
|
||||
else if (drGoods.GoodsType == GoodsType.Weapon)
|
||||
{
|
||||
DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||
goodsItem.Title = drWeapon.Title;
|
||||
goodsItem.Type = "Weapon";
|
||||
GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||
goodsItem.Description = GoodsItemContext.CreateWeaponDescription(drWeapon);
|
||||
}
|
||||
|
||||
items.Add(goodsItem);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
public bool ShopFinish { get; set; }
|
||||
|
||||
#region FSM
|
||||
|
||||
@@ -163,47 +20,25 @@ namespace Procedure
|
||||
{
|
||||
Log.Debug("GameStateShop::OnInit");
|
||||
_procedureGame = master;
|
||||
|
||||
_levelUpFormController = new LevelUpFormController();
|
||||
_shopFormController = new ShopFormController();
|
||||
|
||||
_drGoods = GameEntry.DataTable.GetDataTable<DRGoods>().ToArray();
|
||||
_propDataTable = GameEntry.DataTable.GetDataTable<DRProp>();
|
||||
_drProps = _propDataTable.ToArray();
|
||||
_weaponDataTable = GameEntry.DataTable.GetDataTable<DRWeapon>();
|
||||
|
||||
_shopOver = false;
|
||||
|
||||
var shopFormUseCase = new ShopFormUseCase(_procedureGame, this);
|
||||
GameEntry.UIRouter.BindUIUseCase(UIFormType.ShopForm, shopFormUseCase);
|
||||
}
|
||||
|
||||
public override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
Log.Debug("GameStateShop::OnEnter");
|
||||
|
||||
GameEntry.Event.Subscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
|
||||
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
ShopFinish = false;
|
||||
|
||||
if (_procedureGame.PlayerPendingLevel != 0)
|
||||
{
|
||||
_levelUpFormContext = BuildLevelUpFormContext();
|
||||
_levelUpFormController.OpenUI(_levelUpFormContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
_shopFormContext = BuildShopFormContext();
|
||||
_shopFormController.OpenUI(_shopFormContext);
|
||||
}
|
||||
|
||||
_shopOver = false;
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.ShopForm);
|
||||
}
|
||||
|
||||
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||
float realElapseSeconds)
|
||||
{
|
||||
if (_shopOver)
|
||||
if (ShopFinish)
|
||||
{
|
||||
_shopFormController?.CloseUI();
|
||||
_procedureGame.ShopToBattle();
|
||||
}
|
||||
}
|
||||
@@ -212,96 +47,16 @@ namespace Procedure
|
||||
{
|
||||
Log.Debug("GameStateShop::OnLeave");
|
||||
|
||||
_shopFormContext = null;
|
||||
_shopFormController.CloseUI();
|
||||
_shopFormController = null;
|
||||
|
||||
_levelUpFormContext = null;
|
||||
_levelUpFormController.CloseUI();
|
||||
_levelUpFormController = null;
|
||||
|
||||
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
GameEntry.Event.Unsubscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
|
||||
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.ShopForm);
|
||||
}
|
||||
|
||||
public override void OnDestroy(IFsm<IProcedureManager> procedureOwner)
|
||||
{
|
||||
_procedureGame = null;
|
||||
_shopFormController = null;
|
||||
_shopFormContext = null;
|
||||
|
||||
_levelUpFormController = null;
|
||||
_levelUpFormContext = null;
|
||||
|
||||
_drGoods = null;
|
||||
_propDataTable = null;
|
||||
_weaponDataTable = null;
|
||||
|
||||
Log.Debug("GameStateShop::OnDestroy");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void ShopRefresh(object sender, EventArgs e)
|
||||
{
|
||||
if (!(e is ShopRefreshEventArgs args)) return;
|
||||
|
||||
if (_player.Coin < args.Cost) return;
|
||||
_player.Coin -= args.Cost;
|
||||
RefreshGoodsItems();
|
||||
}
|
||||
|
||||
|
||||
private void ShopPurchase(object sender, EventArgs e)
|
||||
{
|
||||
if (!(e is ShopPurchaseEventArgs args)) return;
|
||||
|
||||
int index = args.GoodsIndex;
|
||||
|
||||
if (index < 0 && index >= _shopFormContext.GoodsItems.Count)
|
||||
{
|
||||
Log.Warning("GameStateShop::ShopPurchase: Invalid index");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_player.Coin < _shopFormContext.GoodsItems[index].Price) return;
|
||||
_player.Coin -= _shopFormContext.GoodsItems[index].Price;
|
||||
_shopFormContext.GoodsItems.RemoveAt(index);
|
||||
_shopFormController.OpenUI(_shopFormContext);
|
||||
// TODO: OnGoodsPurchased
|
||||
}
|
||||
|
||||
private void ShopContinue(object sender, EventArgs e)
|
||||
{
|
||||
if (!(e is ShopContinueEventArgs)) return;
|
||||
|
||||
_shopOver = true;
|
||||
}
|
||||
|
||||
private void CloseUIFormComplete(object sender, EventArgs e)
|
||||
{
|
||||
if (!(e is CloseUIFormCompleteEventArgs args)) return;
|
||||
|
||||
if (args.UIFormAssetName == nameof(UIFormType.LevelUpForm))
|
||||
{
|
||||
|
||||
if (--_procedureGame.PlayerPendingLevel != 0)
|
||||
{
|
||||
_levelUpFormContext = BuildLevelUpFormContext();
|
||||
_levelUpFormController.OpenUI(_levelUpFormContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
_levelUpFormContext = BuildLevelUpFormContext();
|
||||
_levelUpFormController.OpenUI(_levelUpFormContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using CustomComponent;
|
||||
using CustomEvent;
|
||||
using DataTable;
|
||||
using Definition.Enum;
|
||||
@@ -8,7 +7,6 @@ using Entity.EntityData;
|
||||
using GameFramework.Event;
|
||||
using GameFramework.Fsm;
|
||||
using GameFramework.Procedure;
|
||||
using StarForce;
|
||||
using UnityGameFramework.Runtime;
|
||||
using UI;
|
||||
|
||||
@@ -19,6 +17,7 @@ namespace Procedure
|
||||
None = 0,
|
||||
Battle = 1,
|
||||
Shop = 2,
|
||||
LevelUp = 3,
|
||||
}
|
||||
|
||||
public class ProcedureGame : ProcedureBase
|
||||
@@ -36,31 +35,28 @@ namespace Procedure
|
||||
private Dictionary<GameStateType, GameStateBase> _gameStates;
|
||||
public Player Player;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家升级可分配点数
|
||||
/// </summary>
|
||||
public int PlayerPendingLevel = 0;
|
||||
|
||||
private void InitGameState()
|
||||
{
|
||||
_gameStates = new Dictionary<GameStateType, GameStateBase>
|
||||
{
|
||||
{ GameStateType.Battle, new GameStateBattle() },
|
||||
{ GameStateType.LevelUp, new GameStateLevelUp() },
|
||||
{ GameStateType.Shop, new GameStateShop() },
|
||||
};
|
||||
_gameStates[GameStateType.Battle].OnInit(this);
|
||||
_gameStates[GameStateType.LevelUp].OnInit(this);
|
||||
_gameStates[GameStateType.Shop].OnInit(this);
|
||||
|
||||
_currentGameState = GameStateType.Battle;
|
||||
_gameStates[_currentGameState].OnEnter(_procedureOwner);
|
||||
}
|
||||
|
||||
public void BattleToShop()
|
||||
public void BattleToShopOrLevelUp()
|
||||
{
|
||||
if (_currentGameState == GameStateType.Shop) return;
|
||||
if (_currentGameState == GameStateType.Shop || _currentGameState == GameStateType.LevelUp) return;
|
||||
|
||||
_gameStates[_currentGameState].OnLeave(_procedureOwner);
|
||||
_currentGameState = GameStateType.Shop;
|
||||
_currentGameState = Player.PendingLevelPoints > 0 ? GameStateType.LevelUp : GameStateType.Shop;
|
||||
_gameStates[_currentGameState].OnEnter(_procedureOwner);
|
||||
}
|
||||
|
||||
@@ -73,6 +69,15 @@ namespace Procedure
|
||||
_gameStates[_currentGameState].OnEnter(_procedureOwner);
|
||||
}
|
||||
|
||||
public void LevelUpToShop()
|
||||
{
|
||||
if (_currentGameState == GameStateType.Shop) return;
|
||||
|
||||
_gameStates[_currentGameState].OnLeave(_procedureOwner);
|
||||
_currentGameState = GameStateType.Shop;
|
||||
_gameStates[_currentGameState].OnEnter(_procedureOwner);
|
||||
}
|
||||
|
||||
#region FSM
|
||||
|
||||
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||
@@ -83,14 +88,13 @@ namespace Procedure
|
||||
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
|
||||
GameEntry.Event.Subscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||
|
||||
|
||||
CurrentLevel = 1;
|
||||
_currentPlayerData = new PlayerData(-1, 1001);
|
||||
GameEntry.Entity.ShowPlayer(_currentPlayerData);
|
||||
|
||||
GameEntry.UI.OpenUIForm(UIFormType.HudForm, this);
|
||||
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.HudForm);
|
||||
|
||||
InitGameState();
|
||||
}
|
||||
|
||||
@@ -107,9 +111,11 @@ namespace Procedure
|
||||
var role = GameEntry.DataTable.GetDataTableRow<DRRole>(selectedRoleId);
|
||||
Player.InitRole(role);
|
||||
_hudInitialized = true;
|
||||
InitGameState();
|
||||
}
|
||||
|
||||
_gameStates[_currentGameState].OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
|
||||
if (_hudInitialized)
|
||||
_gameStates[_currentGameState].OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
|
||||
}
|
||||
|
||||
protected override void OnLeave(IFsm<IProcedureManager> procedureOwner, bool isShutdown)
|
||||
@@ -121,12 +127,14 @@ namespace Procedure
|
||||
|
||||
_gameStates.Clear();
|
||||
|
||||
_hudForm.Close();
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.HudForm);
|
||||
|
||||
_hudForm = null;
|
||||
|
||||
Player = null;
|
||||
|
||||
_procedureOwner = null;
|
||||
|
||||
GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
|
||||
|
||||
@@ -141,9 +149,9 @@ namespace Procedure
|
||||
{
|
||||
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
||||
|
||||
if (args.UserData == this)
|
||||
if (args.UIForm.Logic is HudForm hudForm)
|
||||
{
|
||||
_hudForm = args.UIForm.Logic as HudForm;
|
||||
_hudForm = hudForm;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,19 +159,12 @@ namespace Procedure
|
||||
{
|
||||
if (!(e is ShowEntitySuccessEventArgs args)) return;
|
||||
|
||||
if (args.EntityLogicType == typeof(Player))
|
||||
if (args.Entity.Logic is Player player)
|
||||
{
|
||||
Player = args.Entity.Logic as Player;
|
||||
Player = player;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayerLevelUp(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is PlayerLevelUpEventArgs)) return;
|
||||
|
||||
//PlayerPendingLevel++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,4 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using Definition.Enum;
|
||||
using GameFramework.Event;
|
||||
using Scene;
|
||||
using UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -16,31 +8,16 @@ namespace Procedure
|
||||
{
|
||||
public class ProcedureStartMenu : ProcedureBase
|
||||
{
|
||||
private bool _isStartGame = false;
|
||||
private StartMenuForm _startMenuForm = null;
|
||||
private SelectRoleForm _selectRoleForm = null;
|
||||
|
||||
public override bool UseNativeDialog => false;
|
||||
|
||||
private bool _startGame = false;
|
||||
|
||||
private int _selectedRoleId = 0;
|
||||
|
||||
public void StartGame(int roleId)
|
||||
public void StartGame(int selectedRoleId)
|
||||
{
|
||||
_isStartGame = true;
|
||||
_selectedRoleId = roleId;
|
||||
}
|
||||
|
||||
private void OnStartGame(ProcedureOwner procedureOwner)
|
||||
{
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Game);
|
||||
procedureOwner.SetData<VarInt32>("SelectedRoleId", _selectedRoleId);
|
||||
ChangeState<ProcedureChangeScene>(procedureOwner);
|
||||
}
|
||||
|
||||
public void OpenSelectForm()
|
||||
{
|
||||
_startMenuForm.Close();
|
||||
GameEntry.UI.OpenUIForm(UIFormType.SelectRoleForm, this);
|
||||
_selectedRoleId = selectedRoleId;
|
||||
_startGame = true;
|
||||
}
|
||||
|
||||
#region FSM
|
||||
@@ -48,54 +25,29 @@ namespace Procedure
|
||||
protected override void OnEnter(ProcedureOwner procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.StartMenuForm);
|
||||
|
||||
// 1. 初始化变量与事件
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
|
||||
_isStartGame = false;
|
||||
|
||||
// 2. 打开 StartMenuForm
|
||||
GameEntry.UI.OpenUIForm(UIFormType.StartMenuForm, this);
|
||||
var useCase2 = new SelectRoleFormUseCase(this);
|
||||
GameEntry.UIRouter.BindUIUseCase(UIFormType.SelectRoleForm, useCase2);
|
||||
}
|
||||
|
||||
protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
|
||||
{
|
||||
base.OnLeave(procedureOwner, isShutdown);
|
||||
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
|
||||
|
||||
if (_startMenuForm != null)
|
||||
{
|
||||
_startMenuForm.Close(true);
|
||||
_startMenuForm = null;
|
||||
}
|
||||
|
||||
if (_selectRoleForm != null)
|
||||
{
|
||||
_selectRoleForm.Close(true);
|
||||
_selectRoleForm = null;
|
||||
}
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.StartMenuForm);
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.SelectRoleForm);
|
||||
}
|
||||
|
||||
protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
|
||||
|
||||
if (_isStartGame)
|
||||
if (_startGame)
|
||||
{
|
||||
OnStartGame(procedureOwner);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void OnOpenUIFormSuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is OpenUIFormSuccessEventArgs ne)
|
||||
{
|
||||
if (ne.UIForm.Logic is StartMenuForm startMenuForm) _startMenuForm = startMenuForm;
|
||||
if (ne.UIForm.Logic is SelectRoleForm selectRoleForm) _selectRoleForm = selectRoleForm;
|
||||
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.Game);
|
||||
procedureOwner.SetData<VarInt32>("SelectedRoleId", _selectedRoleId);
|
||||
ChangeState<ProcedureChangeScene>(procedureOwner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf6edb3e93c9814dbeb37df22394fed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace UI
|
||||
{
|
||||
public interface IUIFormController
|
||||
{
|
||||
int? OpenUI(object userData = null);
|
||||
void CloseUI();
|
||||
void BindUseCase(IUIUseCase useCase);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08145adf06b2b2c4b9d61d3ef6d39cfc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public interface IUIUseCase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b527e4ad6d6207418137211caa179d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -242,4 +242,4 @@ namespace UI
|
||||
GameEntry.UI.CloseUIForm(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ac4a8b30b5b7684ca58f70386314a4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+3
-15
@@ -157,24 +157,12 @@ namespace UI
|
||||
return uiComponent.OpenUIForm(assetName, drUIForm.UIGroupName, Constant.AssetPriority.UIFormAsset, drUIForm.PauseCoveredUIForm, userData);
|
||||
}
|
||||
|
||||
public static void OpenDialog(this UIComponent uiComponent, DialogParams dialogParams)
|
||||
{
|
||||
if (((ProcedureBase)GameEntry.Procedure.CurrentProcedure).UseNativeDialog)
|
||||
{
|
||||
OpenNativeDialog(dialogParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiComponent.OpenUIForm(UIFormType.DialogForm, dialogParams);
|
||||
}
|
||||
}
|
||||
|
||||
private static void OpenNativeDialog(DialogParams dialogParams)
|
||||
private static void OpenNativeDialog(DialogFormRawData rawData)
|
||||
{
|
||||
// TODO:这里应该弹出原生对话框,先简化实现为直接按确认按钮
|
||||
if (dialogParams.OnClickConfirm != null)
|
||||
if (rawData != null && rawData.OnClickConfirm != null)
|
||||
{
|
||||
dialogParams.OnClickConfirm(dialogParams.UserData);
|
||||
rawData.OnClickConfirm(rawData.UserData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace UI
|
||||
{
|
||||
public abstract class UIFormControllerBase<TContext> : IUIFormController where TContext : UIContext
|
||||
{
|
||||
protected abstract int? OpenUIInternal(TContext context);
|
||||
public abstract int? OpenUI(object userData = null);
|
||||
public abstract void CloseUI();
|
||||
public abstract void BindUseCase(IUIUseCase useCase);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
using Definition.Enum;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class TUIFormController : UIFormControllerBase<UIContext>
|
||||
{
|
||||
private IUIUseCase _useCase;
|
||||
private UIContext _context;
|
||||
private TUIForm _tForm;
|
||||
private int? _tFormSerialId;
|
||||
private bool _pendingRefresh;
|
||||
private bool _isBindEvent;
|
||||
|
||||
private void SubscribeEvents()
|
||||
{
|
||||
if (_isBindEvent) return;
|
||||
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
|
||||
_isBindEvent = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeEvents()
|
||||
{
|
||||
if (!_isBindEvent) return;
|
||||
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
|
||||
_isBindEvent = false;
|
||||
}
|
||||
|
||||
protected override int? OpenUIInternal(UIContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("TUIFormController open failed. context is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_context = context;
|
||||
|
||||
if (_tForm != null && _tFormSerialId.HasValue &&
|
||||
GameEntry.UI.HasUIForm(_tFormSerialId.Value))
|
||||
{
|
||||
_tForm.RefreshUI(_context);
|
||||
return _tFormSerialId;
|
||||
}
|
||||
|
||||
CloseUI();
|
||||
_pendingRefresh = true;
|
||||
SubscribeEvents();
|
||||
_tFormSerialId = GameEntry.UI.OpenUIForm(UIFormType.TUIForm, context);
|
||||
return _tFormSerialId;
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is UIContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("TUIFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(_context);
|
||||
}
|
||||
|
||||
public override void CloseUI()
|
||||
{
|
||||
_pendingRefresh = false;
|
||||
UnsubscribeEvents();
|
||||
|
||||
if (_tFormSerialId.HasValue)
|
||||
{
|
||||
if (GameEntry.UI.HasUIForm(_tFormSerialId.Value))
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(_tFormSerialId.Value);
|
||||
}
|
||||
|
||||
_tForm = null;
|
||||
_tFormSerialId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tForm != null)
|
||||
{
|
||||
_tForm.Close();
|
||||
_tForm = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is IUIUseCase UIFormUseCase))
|
||||
{
|
||||
Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_useCase = UIFormUseCase;
|
||||
}
|
||||
|
||||
private void TryRefreshUI()
|
||||
{
|
||||
if (_context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_tForm == null)
|
||||
{
|
||||
_pendingRefresh = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_tForm.RefreshUI(_context);
|
||||
_pendingRefresh = false;
|
||||
}
|
||||
|
||||
#region EventHanlders
|
||||
|
||||
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is OpenUIFormSuccessEventArgs args))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_tFormSerialId.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.UIForm == null || args.UIForm.SerialId != _tFormSerialId.Value || args.UserData != _context)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_tForm = args.UIForm.Logic as TUIForm;
|
||||
|
||||
if (_tForm == null)
|
||||
{
|
||||
Log.Warning("DialogFormController open success but form logic is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pendingRefresh)
|
||||
{
|
||||
TryRefreshUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseUIFormComplete(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is CloseUIFormCompleteEventArgs args))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.SerialId != _tFormSerialId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_tForm = null;
|
||||
_tFormSerialId = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e46538e3d51b6b4ca463fa6080ad335
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class TUIForm : UGuiForm
|
||||
{
|
||||
|
||||
public void RefreshUI(UIContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (!(userData is UIContext context))
|
||||
{
|
||||
Log.Error("UIContext is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshUI(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8bc5e59a2be3094798c8c46d1a4999f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,16 +5,13 @@
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class CommonButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler,
|
||||
public class CommonButton : MonoBehaviour, IPointerEnterHandler, IPointerDownHandler, IPointerExitHandler,
|
||||
IPointerUpHandler
|
||||
{
|
||||
private const float FadeTime = 0.3f;
|
||||
@@ -27,6 +24,8 @@ namespace UI
|
||||
|
||||
[SerializeField] private UnityEvent _onPointerExitAction = null;
|
||||
|
||||
[SerializeField] private bool _enableFade = true;
|
||||
|
||||
private CanvasGroup _canvasGroup = null;
|
||||
|
||||
private void Awake()
|
||||
@@ -47,22 +46,11 @@ namespace UI
|
||||
}
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(_canvasGroup.FadeToAlpha(OnHoverAlpha, FadeTime));
|
||||
if (_enableFade)
|
||||
StartCoroutine(_canvasGroup.FadeToAlpha(OnHoverAlpha, FadeTime));
|
||||
_onPointerEnterAction.Invoke();
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(_canvasGroup.FadeToAlpha(1f, FadeTime));
|
||||
_onPointerExitAction?.Invoke();
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
@@ -84,45 +72,17 @@ namespace UI
|
||||
_canvasGroup.alpha = OnHoverAlpha;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册鼠标相关事件
|
||||
/// </summary>
|
||||
/// <param name="actionId">0、1、2 分别是 Enter、Click、Exit</param>
|
||||
/// <param name="action">回调事件</param>
|
||||
public void RegisterAction(int actionId, UnityAction action)
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
switch (actionId)
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
{
|
||||
case 0:
|
||||
_onPointerEnterAction.AddListener(action);
|
||||
break;
|
||||
case 1:
|
||||
_onClickAction.AddListener(action);
|
||||
break;
|
||||
case 2:
|
||||
_onPointerExitAction.AddListener(action);
|
||||
break;
|
||||
default:
|
||||
throw new IndexOutOfRangeException("actionId 无效");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void UnRegisterAction(int actionId, UnityAction action)
|
||||
{
|
||||
switch (actionId)
|
||||
{
|
||||
case 0:
|
||||
_onPointerEnterAction.RemoveListener(action);
|
||||
break;
|
||||
case 1:
|
||||
_onClickAction.RemoveListener(action);
|
||||
break;
|
||||
case 2:
|
||||
_onPointerExitAction.RemoveListener(action);
|
||||
break;
|
||||
default:
|
||||
throw new IndexOutOfRangeException("actionId 无效");
|
||||
}
|
||||
StopAllCoroutines();
|
||||
if (_enableFade)
|
||||
StartCoroutine(_canvasGroup.FadeToAlpha(1.0f, FadeTime));
|
||||
_onPointerExitAction.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Definition.Enum;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DisplayItemContext : UIContext
|
||||
{
|
||||
public string IconAssetName;
|
||||
public ItemRarity Rarity;
|
||||
public bool IsWeapon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df1bccc6ff70fbc4089c7809e35c1f61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using Definition.Enum;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DisplayItemInfoFormContext : UIContext
|
||||
{
|
||||
public string IconAssetName;
|
||||
public string Title;
|
||||
public string TypeText;
|
||||
public ItemRarity Rarity;
|
||||
public string Description;
|
||||
public int Price;
|
||||
public bool IsWeapon;
|
||||
public Vector3 TargetPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdcef9502b7fa944ca95cb839fdc60bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user