功能:添加启动器场景并更新项目设置
- 调整了启动器场景名(Assets/Launcher.unity)及对应的元数据文件。 - 添加了README.md项目文档,包含安装说明、项目结构、编码规范、测试指南及依赖项。
This commit is contained in:
parent
88641dae11
commit
d650dd63e7
|
|
@ -56,5 +56,6 @@
|
||||||
"temp/": true,
|
"temp/": true,
|
||||||
"Temp/": true
|
"Temp/": true
|
||||||
},
|
},
|
||||||
"dotnet.defaultSolution": "VampireLike.sln"
|
"dotnet.defaultSolution": "VampireLike.sln",
|
||||||
|
"dotnet.preferCSharpExtension": true
|
||||||
}
|
}
|
||||||
|
|
@ -53,5 +53,10 @@ namespace Definition.Enum
|
||||||
/// 游戏HUD。
|
/// 游戏HUD。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
HudForm = 203,
|
HudForm = 203,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 升级选择。
|
||||||
|
/// </summary>
|
||||||
|
LevelUpForm = 204,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,8 @@ namespace Entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int CurrentLevel => _currentLevel;
|
||||||
|
|
||||||
public bool Enable
|
public bool Enable
|
||||||
{
|
{
|
||||||
get => _enable;
|
get => _enable;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
using GameFramework;
|
||||||
|
using GameFramework.Event;
|
||||||
|
|
||||||
|
namespace CustomEvent
|
||||||
|
{
|
||||||
|
public class LevelUpPropSelectedEventArgs : GameEventArgs
|
||||||
|
{
|
||||||
|
public static readonly int EventId = typeof(LevelUpPropSelectedEventArgs).GetHashCode();
|
||||||
|
|
||||||
|
public override int Id => EventId;
|
||||||
|
|
||||||
|
public int SelectedId { get; private set; }
|
||||||
|
|
||||||
|
public LevelUpPropSelectedEventArgs()
|
||||||
|
{
|
||||||
|
SelectedId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LevelUpPropSelectedEventArgs Create(int propId)
|
||||||
|
{
|
||||||
|
var args = ReferencePool.Acquire<LevelUpPropSelectedEventArgs>();
|
||||||
|
args.SelectedId = propId;
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear()
|
||||||
|
{
|
||||||
|
SelectedId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3183e53376fbf95438a0a938510ce7f1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2540b6786a5c4f3aadd4f57c79b714b9
|
||||||
|
timeCreated: 1770985387
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
using GameFramework;
|
||||||
|
using GameFramework.Event;
|
||||||
|
|
||||||
|
namespace CustomEvent
|
||||||
|
{
|
||||||
|
public class PlayerLevelUpEventArgs : GameEventArgs
|
||||||
|
{
|
||||||
|
public static readonly int EventId = typeof(PlayerLevelUpEventArgs).GetHashCode();
|
||||||
|
|
||||||
|
public override int Id => EventId;
|
||||||
|
|
||||||
|
public PlayerLevelUpEventArgs()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerLevelUpEventArgs Create()
|
||||||
|
{
|
||||||
|
var args = ReferencePool.Acquire<PlayerLevelUpEventArgs>();
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59e602f086ce428396eab715b1277a23
|
||||||
|
timeCreated: 1770989625
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ce83a125a974b49ad8a9251a8d73359
|
||||||
|
timeCreated: 1770985411
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
using GameFramework;
|
||||||
|
using GameFramework.Event;
|
||||||
|
|
||||||
|
namespace CustomEvent
|
||||||
|
{
|
||||||
|
public class ShopContinueEventArgs : GameEventArgs
|
||||||
|
{
|
||||||
|
public static readonly int EventId = typeof(ShopContinueEventArgs).GetHashCode();
|
||||||
|
|
||||||
|
public override int Id => EventId;
|
||||||
|
|
||||||
|
public ShopContinueEventArgs()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShopContinueEventArgs Create()
|
||||||
|
{
|
||||||
|
var args = ReferencePool.Acquire<ShopContinueEventArgs>();
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b09ad1baac8a41338c0e42baf398beb8
|
||||||
|
timeCreated: 1770986449
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using GameFramework;
|
||||||
|
using GameFramework.Event;
|
||||||
|
|
||||||
|
namespace CustomEvent
|
||||||
|
{
|
||||||
|
public class ShopPurchaseEventArgs : GameEventArgs
|
||||||
|
{
|
||||||
|
public static readonly int EventId = typeof(ShopPurchaseEventArgs).GetHashCode();
|
||||||
|
|
||||||
|
public override int Id => EventId;
|
||||||
|
|
||||||
|
public int GoodsIndex { get; private set; }
|
||||||
|
|
||||||
|
public ShopPurchaseEventArgs()
|
||||||
|
{
|
||||||
|
GoodsIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShopPurchaseEventArgs Create(int index)
|
||||||
|
{
|
||||||
|
var args = ReferencePool.Acquire<ShopPurchaseEventArgs>();
|
||||||
|
|
||||||
|
args.GoodsIndex = index;
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear()
|
||||||
|
{
|
||||||
|
GoodsIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 11c82e4a45804087b1aaf337e38a8836
|
||||||
|
timeCreated: 1770986490
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
using GameFramework;
|
||||||
|
using GameFramework.Event;
|
||||||
|
|
||||||
|
namespace CustomEvent
|
||||||
|
{
|
||||||
|
public class ShopRefreshEventArgs : GameEventArgs
|
||||||
|
{
|
||||||
|
public static readonly int EventId = typeof(ShopRefreshEventArgs).GetHashCode();
|
||||||
|
|
||||||
|
public override int Id => EventId;
|
||||||
|
|
||||||
|
public int Cost { get; private set; }
|
||||||
|
|
||||||
|
public ShopRefreshEventArgs()
|
||||||
|
{
|
||||||
|
Cost = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShopRefreshEventArgs Create(int cost)
|
||||||
|
{
|
||||||
|
var args = ReferencePool.Acquire<ShopRefreshEventArgs>();
|
||||||
|
|
||||||
|
args.Cost = cost;
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Clear()
|
||||||
|
{
|
||||||
|
Cost = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7f463ec631b54d9e9feda00be716ae68
|
||||||
|
timeCreated: 1770985436
|
||||||
|
|
@ -1,167 +1,209 @@
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using CustomEvent;
|
||||||
using DataTable;
|
using DataTable;
|
||||||
using Definition.Enum;
|
using Definition.Enum;
|
||||||
using Entity;
|
using Entity;
|
||||||
using GameFramework.DataTable;
|
using GameFramework.DataTable;
|
||||||
using GameFramework.Event;
|
|
||||||
using GameFramework.Fsm;
|
using GameFramework.Fsm;
|
||||||
using GameFramework.Procedure;
|
using GameFramework.Procedure;
|
||||||
using UI;
|
using UI;
|
||||||
|
using UnityEngine;
|
||||||
using UnityGameFramework.Runtime;
|
using UnityGameFramework.Runtime;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace Procedure
|
namespace Procedure
|
||||||
{
|
{
|
||||||
public struct ShopFormContext
|
|
||||||
{
|
|
||||||
public GameStateShop GameStateShop;
|
|
||||||
public int CurrentLevel;
|
|
||||||
public int RefreshPrice;
|
|
||||||
public int PlayerCoin;
|
|
||||||
public List<GoodsItemViewData> GoodsItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GameStateShop : GameStateBase
|
public class GameStateShop : GameStateBase
|
||||||
{
|
{
|
||||||
|
#region Property
|
||||||
|
|
||||||
public override GameStateType GameStateType => GameStateType.Shop;
|
public override GameStateType GameStateType => GameStateType.Shop;
|
||||||
|
|
||||||
private ProcedureGame _procedureGame = null;
|
private ProcedureGame _procedureGame;
|
||||||
private bool _shopOver = false;
|
|
||||||
private ShopForm _shopForm = null;
|
|
||||||
|
|
||||||
private DRGoods[] _drGoods = null;
|
private DRGoods[] _drGoods;
|
||||||
private IDataTable<DRProp> _propDataTable = null;
|
|
||||||
private IDataTable<DRWeapon> _weaponDataTable = null;
|
|
||||||
|
|
||||||
private Player _player = null;
|
private DRProp[] _drProps;
|
||||||
|
private IDataTable<DRProp> _propDataTable;
|
||||||
|
|
||||||
|
private IDataTable<DRWeapon> _weaponDataTable;
|
||||||
|
|
||||||
|
private ShopFormController _shopFormController;
|
||||||
private ShopFormContext _shopFormContext;
|
private ShopFormContext _shopFormContext;
|
||||||
|
|
||||||
public void ShopOver()
|
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)
|
||||||
{
|
{
|
||||||
if (_shopOver) return;
|
List<LevelUpPropContext> props = new List<LevelUpPropContext>();
|
||||||
_shopOver = true;
|
int total = _drProps.Length;
|
||||||
|
if (total <= 0)
|
||||||
|
{
|
||||||
|
Log.Error("GameStateShop::BuildLevelUpFormContext(): _drProps == null");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PurchaseGoods(int index)
|
count = Mathf.Min(count, total);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (_player.Coin < _shopFormContext.GoodsItems[index].Price) return;
|
int index = Random.Range(0, total);
|
||||||
_player.Coin -= _shopFormContext.GoodsItems[index].Price;
|
DRProp drProp = _drProps[index];
|
||||||
//TODO:OnGoodsPurchased
|
props.Add(new LevelUpPropContext
|
||||||
|
{
|
||||||
|
PropId = drProp.Id,
|
||||||
|
Title = drProp.Title,
|
||||||
|
Type = "Prop",
|
||||||
|
Icon = null,
|
||||||
|
Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers),
|
||||||
|
IconAssetName = drProp.IconAssetName
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshGoods()
|
return new LevelUpFormContext
|
||||||
{
|
{
|
||||||
if (_player.Coin < _shopFormContext.RefreshPrice) return;
|
Level = _player.CurrentLevel,
|
||||||
_player.Coin -= _shopFormContext.RefreshPrice;
|
Props = props
|
||||||
_shopFormContext = new ShopFormContext()
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Shop
|
||||||
|
|
||||||
|
private void RefreshGoodsItems()
|
||||||
{
|
{
|
||||||
GameStateShop = this,
|
_shopFormContext = BuildShopFormContext();
|
||||||
CurrentLevel = _procedureGame.CurrentLevel,
|
_shopFormContext.RefreshPrice = (_shopRefreshTime + 1) * _procedureGame.CurrentLevel;
|
||||||
RefreshPrice = _shopFormContext.RefreshPrice + _procedureGame.CurrentLevel,
|
_shopRefreshTime++;
|
||||||
|
_shopFormController.OpenUI(_shopFormContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShopFormContext BuildShopFormContext()
|
||||||
|
{
|
||||||
|
int currentLevel = _procedureGame.CurrentLevel;
|
||||||
|
var context = new ShopFormContext
|
||||||
|
{
|
||||||
|
CurrentLevel = currentLevel,
|
||||||
|
RefreshPrice = currentLevel,
|
||||||
PlayerCoin = _player.Coin,
|
PlayerCoin = _player.Coin,
|
||||||
GoodsItems = InitRandomGoodsItems()
|
GoodsItems = InitRandomGoodsItems()
|
||||||
};
|
};
|
||||||
_shopForm.UpdateForm(_shopFormContext);
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<GoodsItemViewData> InitRandomGoodsItems()
|
private List<GoodsItemContext> InitRandomGoodsItems(int count = -1)
|
||||||
{
|
{
|
||||||
// 1. 随机生成商店商品数量
|
if (_drGoods == null || _drGoods.Length == 0)
|
||||||
int count = Random.Range(4, 6);
|
{
|
||||||
|
Log.Error("GameStateShop::InitRandomGoodsItems(): _drGoods == null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 获取数据表中配置的商品总数
|
count = Mathf.Max(count, Random.Range(4, 6));
|
||||||
int totalCount = _drGoods.Length;
|
int totalCount = _drGoods.Length;
|
||||||
|
List<GoodsItemContext> items = new List<GoodsItemContext>(count);
|
||||||
|
if (totalCount <= 0) return items;
|
||||||
|
count = Mathf.Min(count, totalCount);
|
||||||
|
|
||||||
// 3. 创建要返回的商品列表
|
|
||||||
List<GoodsItemViewData> items = new List<GoodsItemViewData>(count);
|
|
||||||
|
|
||||||
// 4. 填充商品列表
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
// 4.1 获取要添加的商品Id
|
|
||||||
int index = Random.Range(0, totalCount);
|
int index = Random.Range(0, totalCount);
|
||||||
|
DRGoods drGoods = _drGoods[index];
|
||||||
// 4.2 从数据表中获取商品数据
|
GoodsItemContext goodsItem = new GoodsItemContext
|
||||||
var drGoods = _drGoods[index];
|
{
|
||||||
|
Price = Random.Range(drGoods.MinPrice, drGoods.MaxPrice)
|
||||||
// 4.3 构建商品数据类
|
};
|
||||||
var goodsItem = new GoodsItemViewData();
|
|
||||||
|
|
||||||
// 4.4 填充商品数据(价格、名字、类型、图标、描述)
|
|
||||||
goodsItem.Price = Random.Range(drGoods.MinPrice, drGoods.MaxPrice);
|
|
||||||
|
|
||||||
if (drGoods.GoodsType == GoodsType.Prop)
|
if (drGoods.GoodsType == GoodsType.Prop)
|
||||||
{
|
{
|
||||||
DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
|
DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||||
|
|
||||||
goodsItem.Title = drProp.Title;
|
goodsItem.Title = drProp.Title;
|
||||||
goodsItem.Type = "道具";
|
goodsItem.Type = "Prop";
|
||||||
GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
|
GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||||
goodsItem.Description = GoodsItemViewData.CreatePropDescription(drProp.Modifiers);
|
goodsItem.Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers);
|
||||||
}
|
}
|
||||||
else if (drGoods.GoodsType is GoodsType.Weapon)
|
else if (drGoods.GoodsType == GoodsType.Weapon)
|
||||||
{
|
{
|
||||||
DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
|
DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
|
||||||
|
|
||||||
goodsItem.Title = drWeapon.Title;
|
goodsItem.Title = drWeapon.Title;
|
||||||
goodsItem.Type = "武器";
|
goodsItem.Type = "Weapon";
|
||||||
GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
|
GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
|
||||||
goodsItem.Description = GoodsItemViewData.CreateWeaponDescription(drWeapon);
|
goodsItem.Description = GoodsItemContext.CreateWeaponDescription(drWeapon);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Warning("Goods type not supported.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.5 添加到商品列表
|
|
||||||
items.Add(goodsItem);
|
items.Add(goodsItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region FSM
|
#region FSM
|
||||||
|
|
||||||
public override void OnInit(ProcedureGame master)
|
public override void OnInit(ProcedureGame master)
|
||||||
{
|
{
|
||||||
Log.Debug("GameStateShop::OnInit");
|
Log.Debug("GameStateShop::OnInit");
|
||||||
_procedureGame = master;
|
_procedureGame = master;
|
||||||
_shopOver = false;
|
|
||||||
|
_levelUpFormController = new LevelUpFormController();
|
||||||
|
_shopFormController = new ShopFormController();
|
||||||
|
|
||||||
_drGoods = GameEntry.DataTable.GetDataTable<DRGoods>().ToArray();
|
_drGoods = GameEntry.DataTable.GetDataTable<DRGoods>().ToArray();
|
||||||
_propDataTable = GameEntry.DataTable.GetDataTable<DRProp>();
|
_propDataTable = GameEntry.DataTable.GetDataTable<DRProp>();
|
||||||
|
_drProps = _propDataTable.ToArray();
|
||||||
_weaponDataTable = GameEntry.DataTable.GetDataTable<DRWeapon>();
|
_weaponDataTable = GameEntry.DataTable.GetDataTable<DRWeapon>();
|
||||||
|
|
||||||
|
_shopOver = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
public override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||||||
{
|
{
|
||||||
Log.Debug("GameStateShop::OnEnter");
|
Log.Debug("GameStateShop::OnEnter");
|
||||||
|
|
||||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
GameEntry.Event.Subscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
|
||||||
|
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||||
|
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||||
|
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||||
|
|
||||||
|
if (_procedureGame.PlayerPendingLevel != 0)
|
||||||
|
{
|
||||||
|
_levelUpFormContext = BuildLevelUpFormContext();
|
||||||
|
_levelUpFormController.OpenUI(_levelUpFormContext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_shopFormContext = BuildShopFormContext();
|
||||||
|
_shopFormController.OpenUI(_shopFormContext);
|
||||||
|
}
|
||||||
|
|
||||||
_shopOver = false;
|
_shopOver = false;
|
||||||
_player = _procedureGame.Player;
|
|
||||||
|
|
||||||
_shopFormContext = new ShopFormContext()
|
|
||||||
{
|
|
||||||
GameStateShop = this,
|
|
||||||
CurrentLevel = _procedureGame.CurrentLevel,
|
|
||||||
RefreshPrice = _procedureGame.CurrentLevel,
|
|
||||||
PlayerCoin = _player.Coin,
|
|
||||||
GoodsItems = InitRandomGoodsItems()
|
|
||||||
};
|
|
||||||
GameEntry.UI.OpenUIForm(UIFormType.ShopForm, _shopFormContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
public override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
|
||||||
float realElapseSeconds)
|
float realElapseSeconds)
|
||||||
{
|
{
|
||||||
Log.Debug("GameStateShop::OnUpdate");
|
|
||||||
|
|
||||||
if (_shopOver)
|
if (_shopOver)
|
||||||
{
|
{
|
||||||
_shopForm.Close();
|
_shopFormController?.CloseUI();
|
||||||
_procedureGame.ShopToBattle();
|
_procedureGame.ShopToBattle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,14 +212,29 @@ namespace Procedure
|
||||||
{
|
{
|
||||||
Log.Debug("GameStateShop::OnLeave");
|
Log.Debug("GameStateShop::OnLeave");
|
||||||
|
|
||||||
_shopForm = null;
|
_shopFormContext = null;
|
||||||
|
_shopFormController.CloseUI();
|
||||||
|
_shopFormController = null;
|
||||||
|
|
||||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDestroy(IFsm<IProcedureManager> procedureOwner)
|
public override void OnDestroy(IFsm<IProcedureManager> procedureOwner)
|
||||||
{
|
{
|
||||||
_procedureGame = null;
|
_procedureGame = null;
|
||||||
|
_shopFormController = null;
|
||||||
|
_shopFormContext = null;
|
||||||
|
|
||||||
|
_levelUpFormController = null;
|
||||||
|
_levelUpFormContext = null;
|
||||||
|
|
||||||
_drGoods = null;
|
_drGoods = null;
|
||||||
_propDataTable = null;
|
_propDataTable = null;
|
||||||
_weaponDataTable = null;
|
_weaponDataTable = null;
|
||||||
|
|
@ -189,13 +246,59 @@ namespace Procedure
|
||||||
|
|
||||||
#region Event Handlers
|
#region Event Handlers
|
||||||
|
|
||||||
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
private void ShopRefresh(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
if (!(e is ShopRefreshEventArgs args)) return;
|
||||||
if (!(args.UserData is ShopFormContext data)) return;
|
|
||||||
if (data.GameStateShop == this)
|
if (_player.Coin < args.Cost) return;
|
||||||
|
_player.Coin -= args.Cost;
|
||||||
|
RefreshGoodsItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShopPurchase(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_shopForm = args.UIForm.Logic as ShopForm;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ namespace Procedure
|
||||||
private Dictionary<GameStateType, GameStateBase> _gameStates;
|
private Dictionary<GameStateType, GameStateBase> _gameStates;
|
||||||
public Player Player;
|
public Player Player;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 玩家升级可分配点数
|
||||||
|
/// </summary>
|
||||||
|
public int PlayerPendingLevel = 0;
|
||||||
|
|
||||||
private void InitGameState()
|
private void InitGameState()
|
||||||
{
|
{
|
||||||
_gameStates = new Dictionary<GameStateType, GameStateBase>
|
_gameStates = new Dictionary<GameStateType, GameStateBase>
|
||||||
|
|
@ -76,8 +81,9 @@ namespace Procedure
|
||||||
|
|
||||||
_procedureOwner = procedureOwner;
|
_procedureOwner = procedureOwner;
|
||||||
|
|
||||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
|
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
|
GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
|
||||||
|
GameEntry.Event.Subscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||||
|
|
||||||
CurrentLevel = 1;
|
CurrentLevel = 1;
|
||||||
_currentPlayerData = new PlayerData(-1, 1001);
|
_currentPlayerData = new PlayerData(-1, 1001);
|
||||||
|
|
@ -120,8 +126,9 @@ namespace Procedure
|
||||||
Player = null;
|
Player = null;
|
||||||
_procedureOwner = null;
|
_procedureOwner = null;
|
||||||
|
|
||||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
|
GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
|
||||||
GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
|
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
|
GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
|
||||||
|
|
||||||
base.OnLeave(procedureOwner, isShutdown);
|
base.OnLeave(procedureOwner, isShutdown);
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +137,7 @@ namespace Procedure
|
||||||
|
|
||||||
#region Event Handler
|
#region Event Handler
|
||||||
|
|
||||||
private void OnOpenUIFormSuccess(object sender, GameEventArgs e)
|
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
||||||
{
|
{
|
||||||
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
||||||
|
|
||||||
|
|
@ -140,7 +147,7 @@ namespace Procedure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnShowEntitySuccess(object sender, GameEventArgs e)
|
private void ShowEntitySuccess(object sender, GameEventArgs e)
|
||||||
{
|
{
|
||||||
if (!(e is ShowEntitySuccessEventArgs args)) return;
|
if (!(e is ShowEntitySuccessEventArgs args)) return;
|
||||||
|
|
||||||
|
|
@ -150,6 +157,13 @@ namespace Procedure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PlayerLevelUp(object sender, GameEventArgs e)
|
||||||
|
{
|
||||||
|
if (!(e is PlayerLevelUpEventArgs)) return;
|
||||||
|
|
||||||
|
//PlayerPendingLevel++;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 32bf4a12bd0ac2847b19bbb76b7c3dd5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
public class GoodsItemViewData
|
public class GoodsItemContext
|
||||||
{
|
{
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Type;
|
public string Type;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class LevelUpFormContext
|
||||||
|
{
|
||||||
|
public int Level;
|
||||||
|
public List<LevelUpPropContext> Props;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1874c6c7ef990c04ba726a2581cd23ce
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class LevelUpPropContext
|
||||||
|
{
|
||||||
|
public int PropId;
|
||||||
|
public string Title;
|
||||||
|
public string Type;
|
||||||
|
public Sprite Icon;
|
||||||
|
public string Description;
|
||||||
|
public string IconAssetName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 424ceeba7cae4fa4faaeef9035f31e31
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class ShopFormContext
|
||||||
|
{
|
||||||
|
public int CurrentLevel;
|
||||||
|
public int RefreshPrice;
|
||||||
|
public int PlayerCoin;
|
||||||
|
public List<GoodsItemContext> GoodsItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b0ef5183d2f87a54793b86d848e6524a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d69a94fcc50f4c4ca1dc45e4338560e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public interface IFormController<TContext>
|
||||||
|
{
|
||||||
|
int? OpenUI(TContext context);
|
||||||
|
void CloseUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 692b282b1ecbf5a44839d5bf4a03a937
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using CustomEvent;
|
||||||
|
using DataTable;
|
||||||
|
using Definition.Enum;
|
||||||
|
using GameFramework.DataTable;
|
||||||
|
using GameFramework.Event;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityGameFramework.Runtime;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class LevelUpFormController : IFormController<LevelUpFormContext>
|
||||||
|
{
|
||||||
|
private int _currentLevel = 1;
|
||||||
|
private int _buildCount = 4;
|
||||||
|
|
||||||
|
private bool _pendingRefresh;
|
||||||
|
|
||||||
|
private int? _levelUpFormSerialId;
|
||||||
|
private LevelUpForm _levelUpForm;
|
||||||
|
private LevelUpFormContext _context;
|
||||||
|
|
||||||
|
public LevelUpFormController()
|
||||||
|
{
|
||||||
|
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
|
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
~LevelUpFormController()
|
||||||
|
{
|
||||||
|
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
|
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConfigureBuild(int level, int count = 4)
|
||||||
|
{
|
||||||
|
_currentLevel = Mathf.Max(1, level);
|
||||||
|
_buildCount = Mathf.Max(0, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? OpenUI(LevelUpFormContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
Log.Warning("LevelUpFormController.OpenUI() context is null.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
if (_levelUpForm != null)
|
||||||
|
{
|
||||||
|
_levelUpForm.RefreshUI(_context);
|
||||||
|
return _levelUpFormSerialId;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseUI();
|
||||||
|
_pendingRefresh = true;
|
||||||
|
_levelUpFormSerialId = GameEntry.UI.OpenUIForm(UIFormType.LevelUpForm, context);
|
||||||
|
return _levelUpFormSerialId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseUI()
|
||||||
|
{
|
||||||
|
_pendingRefresh = false;
|
||||||
|
|
||||||
|
if (_levelUpFormSerialId.HasValue)
|
||||||
|
{
|
||||||
|
GameEntry.UI.CloseUIForm(_levelUpFormSerialId.Value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_levelUpForm != null)
|
||||||
|
{
|
||||||
|
_levelUpForm.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_context = null;
|
||||||
|
_levelUpForm = null;
|
||||||
|
_levelUpFormSerialId = null;
|
||||||
|
_pendingRefresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnSelectProp(int propId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryRefreshUI()
|
||||||
|
{
|
||||||
|
if (_context == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_levelUpForm == null)
|
||||||
|
{
|
||||||
|
_pendingRefresh = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_levelUpForm.RefreshUI(_context);
|
||||||
|
_pendingRefresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Event Handlers
|
||||||
|
|
||||||
|
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
||||||
|
{
|
||||||
|
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
||||||
|
|
||||||
|
if (!_levelUpFormSerialId.HasValue) return;
|
||||||
|
|
||||||
|
if (args.UIForm == null || args.UIForm.SerialId != _levelUpFormSerialId.Value || args.UserData != _context)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_levelUpForm = args.UIForm.Logic as LevelUpForm;
|
||||||
|
|
||||||
|
if (_levelUpForm == null)
|
||||||
|
{
|
||||||
|
Log.Warning("LevelUpFormController 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 != _levelUpFormSerialId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_levelUpForm = null;
|
||||||
|
_levelUpFormSerialId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 89d85bbc4f7cf8c438c7ee693eaf67cf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
using Definition.Enum;
|
||||||
|
using GameFramework.Event;
|
||||||
|
using UnityGameFramework.Runtime;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class ShopFormController : IFormController<ShopFormContext>
|
||||||
|
{
|
||||||
|
#region Property
|
||||||
|
|
||||||
|
private bool _pendingRefresh;
|
||||||
|
|
||||||
|
private int? _shopFormSerialId;
|
||||||
|
|
||||||
|
private ShopForm _shopForm;
|
||||||
|
|
||||||
|
private ShopFormContext _context;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ShopFormController()
|
||||||
|
{
|
||||||
|
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
|
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
~ShopFormController()
|
||||||
|
{
|
||||||
|
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||||
|
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? OpenUI(ShopFormContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
Log.Warning("ShopFormController.OpenUI() context is null.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
if (_shopForm != null)
|
||||||
|
{
|
||||||
|
_shopForm.RefreshUI(_context);
|
||||||
|
return _shopFormSerialId;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseUI();
|
||||||
|
_pendingRefresh = true;
|
||||||
|
_shopFormSerialId = GameEntry.UI.OpenUIForm(UIFormType.ShopForm, context);
|
||||||
|
return _shopFormSerialId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseUI()
|
||||||
|
{
|
||||||
|
_pendingRefresh = false;
|
||||||
|
|
||||||
|
if (_shopFormSerialId.HasValue)
|
||||||
|
{
|
||||||
|
GameEntry.UI.CloseUIForm(_shopFormSerialId.Value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_shopForm != null)
|
||||||
|
{
|
||||||
|
_shopForm.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryRefreshUI()
|
||||||
|
{
|
||||||
|
if (_context == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_shopForm == null)
|
||||||
|
{
|
||||||
|
_pendingRefresh = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopForm.RefreshUI(_context);
|
||||||
|
_pendingRefresh = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Event Handlers
|
||||||
|
|
||||||
|
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
||||||
|
{
|
||||||
|
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
||||||
|
|
||||||
|
if (!_shopFormSerialId.HasValue) return;
|
||||||
|
|
||||||
|
if (args.UIForm == null || args.UIForm.SerialId != _shopFormSerialId.Value || args.UserData != _context)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopForm = args.UIForm.Logic as ShopForm;
|
||||||
|
|
||||||
|
if (_shopForm == null)
|
||||||
|
{
|
||||||
|
Log.Warning("ShopFormController 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 != _shopFormSerialId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopForm = null;
|
||||||
|
_shopFormSerialId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be57ace1e7b07be429632ea49bcab6c5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7af0b9398035e254cb6de37a6c301552
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using Procedure;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
@ -8,20 +7,21 @@ namespace UI
|
||||||
public class GoodsItem : MonoBehaviour
|
public class GoodsItem : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private Image _iconImage;
|
[SerializeField] private Image _iconImage;
|
||||||
[SerializeField] private TMP_Text _titleText;
|
|
||||||
[SerializeField] private TMP_Text _typeText;
|
|
||||||
[SerializeField] private TMP_Text _descriptionText;
|
|
||||||
[SerializeField] private TMP_Text _costText;
|
|
||||||
[SerializeField] private CommonButton _purchaseButton;
|
|
||||||
|
|
||||||
private int _cost;
|
[SerializeField] private TMP_Text _titleText;
|
||||||
private GameStateShop _stateShop;
|
|
||||||
|
[SerializeField] private TMP_Text _typeText;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text _descriptionText;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text _costText;
|
||||||
|
|
||||||
|
[SerializeField] private CommonButton _purchaseButton;
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
public void Init(GameStateShop stateShop, GoodsItemViewData data)
|
public void Init(GoodsItemContext data)
|
||||||
{
|
{
|
||||||
_stateShop = stateShop;
|
|
||||||
_iconImage.sprite = data.Icon;
|
_iconImage.sprite = data.Icon;
|
||||||
_titleText.text = data.Title;
|
_titleText.text = data.Title;
|
||||||
_typeText.text = data.Type;
|
_typeText.text = data.Type;
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
using CustomEvent;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityGameFramework.Runtime;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class LevelUpForm : UGuiForm
|
||||||
|
{
|
||||||
|
[SerializeField] private TMP_Text _titleText;
|
||||||
|
|
||||||
|
[SerializeField] private LevelUpPropItem[] _propItems;
|
||||||
|
|
||||||
|
private LevelUpFormContext _context;
|
||||||
|
|
||||||
|
public void RefreshUI(LevelUpFormContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
if (_titleText != null)
|
||||||
|
{
|
||||||
|
_titleText.text = $"Level Up (Lv.{_context.Level})";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var propItem in _propItems)
|
||||||
|
{
|
||||||
|
propItem.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_context.Props == null) return;
|
||||||
|
for (int i = 0; i < _propItems.Length; i++)
|
||||||
|
{
|
||||||
|
_propItems[i].gameObject.SetActive(true);
|
||||||
|
_propItems[i].Init(_context.Props[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region FSM
|
||||||
|
|
||||||
|
protected override void OnOpen(object userData)
|
||||||
|
{
|
||||||
|
base.OnOpen(userData);
|
||||||
|
|
||||||
|
if (userData is LevelUpFormContext context)
|
||||||
|
{
|
||||||
|
RefreshUI(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Warning("LevelUpForm requires LevelUpFormContext as userData.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnClose(bool isShutdown, object userData)
|
||||||
|
{
|
||||||
|
_context = null;
|
||||||
|
base.OnClose(isShutdown, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private void OnSelectProp(int index)
|
||||||
|
{
|
||||||
|
GameEntry.Event.Fire(this, LevelUpPropSelectedEventArgs.Create(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 73f52c8a6d8b8ec42ad8cd3c00e0254d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityGameFramework.Runtime;
|
||||||
|
|
||||||
|
namespace UI
|
||||||
|
{
|
||||||
|
public class LevelUpPropItem : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Image _iconImage;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text _titleText;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text _typeText;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text _descriptionText;
|
||||||
|
|
||||||
|
private LevelUpPropContext _context;
|
||||||
|
|
||||||
|
|
||||||
|
public void Init(LevelUpPropContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
Log.Error("LevelUpPropContext context is invalid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_context = context;
|
||||||
|
|
||||||
|
if (_titleText != null) _titleText.text = context.Title;
|
||||||
|
if (_typeText != null) _typeText.text = context.Type;
|
||||||
|
if (_descriptionText != null) _descriptionText.text = context.Description;
|
||||||
|
if (_iconImage != null) _iconImage.sprite = context.Icon;
|
||||||
|
|
||||||
|
LoadIcon(_context.IconAssetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadIcon(string iconAssetName)
|
||||||
|
{
|
||||||
|
if (_iconImage == null) return;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(iconAssetName)) return;
|
||||||
|
|
||||||
|
GameEntry.SpriteCache.GetSprite(iconAssetName, sprite => _iconImage.sprite = sprite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 237d64392d274c14f9f5c81b54122a93
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using CustomEvent;
|
using CustomEvent;
|
||||||
using GameFramework.Event;
|
using GameFramework.Event;
|
||||||
using Procedure;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -8,6 +7,8 @@ namespace UI
|
||||||
{
|
{
|
||||||
public class ShopForm : UGuiForm
|
public class ShopForm : UGuiForm
|
||||||
{
|
{
|
||||||
|
#region Property
|
||||||
|
|
||||||
[SerializeField] private TMP_Text _titleText;
|
[SerializeField] private TMP_Text _titleText;
|
||||||
|
|
||||||
[SerializeField] private TMP_Text _continueButtonText;
|
[SerializeField] private TMP_Text _continueButtonText;
|
||||||
|
|
@ -15,50 +16,52 @@ namespace UI
|
||||||
[SerializeField] private TMP_Text _refreshPriceText;
|
[SerializeField] private TMP_Text _refreshPriceText;
|
||||||
|
|
||||||
[SerializeField] private TMP_Text _playerCoinText;
|
[SerializeField] private TMP_Text _playerCoinText;
|
||||||
private int _currentCoin = 0;
|
private int _currentCoin;
|
||||||
|
|
||||||
[SerializeField] private GoodsItem[] _goodsItems;
|
[SerializeField] private GoodsItem[] _goodsItems;
|
||||||
|
|
||||||
private GameStateShop _stateShop;
|
private ShopFormContext _context;
|
||||||
|
|
||||||
public void UpdateForm(ShopFormContext context)
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public void RefreshUI(ShopFormContext context)
|
||||||
{
|
{
|
||||||
_stateShop = context.GameStateShop;
|
_context = context;
|
||||||
|
|
||||||
_titleText.text = $"商店(第{context.CurrentLevel}波)";
|
_titleText.text = $"商店 (Lv.{context.CurrentLevel})";
|
||||||
_continueButtonText.text = $"继续(第{context.CurrentLevel + 1}波)";
|
_continueButtonText.text = $"继续 (Lv.{context.CurrentLevel + 1})";
|
||||||
_refreshPriceText.text = $"-{context.RefreshPrice}";
|
_refreshPriceText.text = $"-{context.RefreshPrice}";
|
||||||
_playerCoinText.text = $"{context.PlayerCoin}";
|
_playerCoinText.text = context.PlayerCoin.ToString();
|
||||||
|
|
||||||
for (int i = 0; i < _goodsItems.Length; i++)
|
foreach (var item in _goodsItems)
|
||||||
{
|
{
|
||||||
if (i < context.GoodsItems.Count)
|
item.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_context.GoodsItems == null) return;
|
||||||
|
for (int i = 0; i < _context.GoodsItems.Count; i++)
|
||||||
{
|
{
|
||||||
_goodsItems[i].Init(context.GameStateShop, context.GoodsItems[i]);
|
_goodsItems[i].Init(context.GoodsItems[i]);
|
||||||
_goodsItems[i].gameObject.SetActive(true);
|
_goodsItems[i].gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_goodsItems[i].gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ButtonClick
|
#region ButtonClick
|
||||||
|
|
||||||
public void OnContinueButtonClick()
|
public void OnContinueButtonClick()
|
||||||
{
|
{
|
||||||
_stateShop.ShopOver();
|
GameEntry.Event.Fire(this, ShopContinueEventArgs.Create());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPurchaseButtonClick(int index)
|
public void OnPurchaseButtonClick(int index)
|
||||||
{
|
{
|
||||||
_stateShop.PurchaseGoods(index);
|
GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRefreshButtonClick()
|
public void OnRefreshButtonClick()
|
||||||
{
|
{
|
||||||
_stateShop.RefreshGoods();
|
GameEntry.Event.Fire(this, ShopRefreshEventArgs.Create(_context.RefreshPrice));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -71,13 +74,18 @@ namespace UI
|
||||||
|
|
||||||
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
||||||
|
|
||||||
ShopFormContext context = (ShopFormContext)userData;
|
if (userData is ShopFormContext context)
|
||||||
UpdateForm(context);
|
{
|
||||||
|
RefreshUI(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityGameFramework.Runtime.Log.Warning("ShopForm requires ShopFormContext as userData.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnClose(bool isShutdown, object userData)
|
protected override void OnClose(bool isShutdown, object userData)
|
||||||
{
|
{
|
||||||
_stateShop = null;
|
_context = null;
|
||||||
|
|
||||||
GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
||||||
|
|
||||||
|
|
@ -96,6 +104,7 @@ namespace UI
|
||||||
_currentCoin = args.CoinCount;
|
_currentCoin = args.CoinCount;
|
||||||
_playerCoinText.text = _currentCoin.ToString();
|
_playerCoinText.text = _currentCoin.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3688,7 +3688,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -3698,7 +3698,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -3748,12 +3748,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 725
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -3859,7 +3859,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -3869,7 +3869,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -3919,12 +3919,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 2725
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4414,7 +4414,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4424,7 +4424,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4474,12 +4474,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 1225
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4585,7 +4585,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4595,7 +4595,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -4645,12 +4645,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 1725
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5122,7 +5122,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5132,7 +5132,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5182,12 +5182,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 2225
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5288,7 +5288,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5298,7 +5298,7 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchorMin.y
|
propertyPath: m_AnchorMin.y
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
@ -5348,12 +5348,12 @@ PrefabInstance:
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.x
|
propertyPath: m_AnchoredPosition.x
|
||||||
value: 225
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_AnchoredPosition.y
|
propertyPath: m_AnchoredPosition.y
|
||||||
value: -350
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ EditorBuildSettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/StarForce Launcher.unity
|
path: Assets/Launcher.unity
|
||||||
guid: 9d2d51bf0fc3dfc42908e3a7a64f4feb
|
guid: 9d2d51bf0fc3dfc42908e3a7a64f4feb
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/GameMain/Scenes/Main.unity
|
path: Assets/GameMain/Scenes/Main.unity
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
# VampireLike
|
||||||
|
|
||||||
|
`VampireLike` 是一个基于 **Unity 2022.3 LTS** 的 2D/3D(按当前资源配置)动作生存类项目,使用 `GameMain + GameFramework` 分层组织代码与资源。
|
||||||
|
|
||||||
|
## 开发环境
|
||||||
|
|
||||||
|
- Unity Editor: `2022.3.62f3c1`
|
||||||
|
- .NET/C#: Unity 默认编译链
|
||||||
|
- 推荐 IDE:
|
||||||
|
- Rider
|
||||||
|
- Visual Studio
|
||||||
|
- VS Code
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
1. 使用 Unity Hub 打开项目根目录。
|
||||||
|
2. 确认 Unity 版本为 `2022.3.62f3c1`(或兼容的 2022.3 LTS 版本)。
|
||||||
|
3. 进入后等待包与资源导入完成。
|
||||||
|
4. 在 Editor 中打开场景并运行:
|
||||||
|
- `Assets/GameMain/Scenes/Menu.unity`
|
||||||
|
- `Assets/GameMain/Scenes/Main.unity`
|
||||||
|
- `Assets/GameMain/Scenes/Game.unity`
|
||||||
|
|
||||||
|
可选命令行启动(请替换为本机 Unity 路径):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Unity -projectPath .
|
||||||
|
```
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
主要目录说明:
|
||||||
|
|
||||||
|
- `Assets/GameMain/`: 游戏业务代码、场景和内容资源。
|
||||||
|
- `Assets/GameFramework/`: 通用框架与编辑器扩展。
|
||||||
|
- `Assets/Plugins/`: 第三方插件(如 DOTween)。
|
||||||
|
- `Assets/Resources/`: 运行时通过 Resources 加载的资源。
|
||||||
|
- `Assets/StreamingAssets/`: 原样打包到客户端的数据。
|
||||||
|
- `Json/`、`数据表/`: 配置与数据表。
|
||||||
|
- `Tools/`: 本地工具脚本和处理流程。
|
||||||
|
|
||||||
|
请避免直接修改自动生成目录:
|
||||||
|
|
||||||
|
- `Library/`
|
||||||
|
- `Temp/`
|
||||||
|
- `Logs/`
|
||||||
|
- `obj/`
|
||||||
|
|
||||||
|
## 代码规范
|
||||||
|
|
||||||
|
- C# 使用 4 空格缩进。
|
||||||
|
- 大括号与声明同行(K&R 风格)。
|
||||||
|
- 单文件单主类型,文件名与类型名一致。
|
||||||
|
- 公有类型/成员使用 `PascalCase`。
|
||||||
|
- 局部变量/参数使用 `camelCase`。
|
||||||
|
- 需要在 Inspector 暴露的私有字段使用 `[SerializeField]`。
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
项目已包含 `com.unity.test-framework`。
|
||||||
|
|
||||||
|
建议约定:
|
||||||
|
|
||||||
|
- 测试目录:`Assets/Tests/` 或 `Assets/<Module>/Tests/`
|
||||||
|
- 测试文件命名:`*Tests.cs`
|
||||||
|
- 使用 NUnit `[Test]` 编写用例
|
||||||
|
- 通过 Unity Test Runner 运行:`Window > General > Test Runner`
|
||||||
|
|
||||||
|
## 常用依赖(Packages)
|
||||||
|
|
||||||
|
当前项目使用的关键包包括:
|
||||||
|
|
||||||
|
- `com.unity.inputsystem`
|
||||||
|
- `com.unity.render-pipelines.universal`
|
||||||
|
- `com.unity.textmeshpro`
|
||||||
|
- `com.unity.ugui`
|
||||||
|
- `com.unity.nuget.newtonsoft-json`
|
||||||
|
- `com.unity.test-framework`
|
||||||
|
|
||||||
|
完整依赖见 `Packages/manifest.json`。
|
||||||
|
|
||||||
|
## 协作与提交流程(建议)
|
||||||
|
|
||||||
|
- 提交信息使用简短祈使句,例如:`UI: Fix shop item refresh logic`
|
||||||
|
- PR 建议包含:
|
||||||
|
- 变更摘要
|
||||||
|
- 测试说明
|
||||||
|
- 关联任务/Issue
|
||||||
|
- UI 改动截图或录屏
|
||||||
|
|
||||||
|
## 配置注意事项
|
||||||
|
|
||||||
|
- 修改依赖时,请同时关注:
|
||||||
|
- `Packages/manifest.json`
|
||||||
|
- `ProjectSettings/`
|
||||||
|
- 大体积二进制资源需与对应 `.meta` 一并提交。
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
当前仓库未提供许可证文件。若需开源或外发,请先补充 `LICENSE`。
|
||||||
Loading…
Reference in New Issue