137 lines
6.3 KiB
C#
137 lines
6.3 KiB
C#
using System.Threading.Tasks;
|
|
using CSNetwork.GPDataType;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster.Scripts.Managers
|
|
{
|
|
public class NPCManager : MonoBehaviour
|
|
{
|
|
private static NPCManager instance;
|
|
|
|
[SerializeField] private GameObject modelPlayerCharacter;
|
|
|
|
|
|
private string[] _playerModelPaths = new string[] {
|
|
// "Models\\Matters\\物品\\原石\\原石.ecm",
|
|
// "Models\\Matters\\物品\\元素\\元素.ecm",
|
|
// Human
|
|
"models/players/形象/武侠男/躯干/武侠男.ecm",
|
|
"models/players/形象/武侠女/躯干/武侠女.ecm",
|
|
"models/players/形象/法师男/躯干/法师男.ecm",
|
|
"models/players/形象/法师女/躯干/法师女.ecm",
|
|
// 汐族 巫师
|
|
"models/players/形象/巫师男/躯干/巫师男.ecm",
|
|
"models/players/形象/巫师女/躯干/巫师女.ecm",
|
|
// 妖族
|
|
"",
|
|
"models/players/形象/妖精/躯干/妖精.ecm",
|
|
"models/players/形象/妖兽男/躯干/妖兽男.ecm",
|
|
"",
|
|
// 汐族 刺客
|
|
"models/players/形象/刺客男/躯干/刺客男.ecm",
|
|
"models/players/形象/刺客女/躯干/刺客女.ecm",
|
|
// 羽族
|
|
"models/players/形象/羽芒男/躯干/羽芒男.ecm",
|
|
"models/players/形象/羽芒女/躯干/羽芒女.ecm",
|
|
"models/players/形象/羽灵男/躯干/羽灵男.ecm",
|
|
"models/players/形象/羽灵女/躯干/羽灵女.ecm",
|
|
// 灵族
|
|
"models/players/形象/剑灵男/躯干/剑灵男.ecm",
|
|
"models/players/形象/剑灵女/躯干/剑灵女.ecm",
|
|
"models/players/形象/魅灵男/躯干/魅灵男.ecm",
|
|
"models/players/形象/魅灵女/躯干/魅灵女.ecm",
|
|
// 职业变身模型
|
|
"models/players/形象/白虎/白虎.ecm",
|
|
"models/players/形象/火狐狸/火狐狸.ecm",
|
|
"models/players/形象/影族变身男/影族变身男.ecm",
|
|
"models/players/形象/影族变身女/影族变身女.ecm",
|
|
|
|
// 技能变身模型(此ID不可变,新模型请往后添加)
|
|
"models/players/形象/金钱蛙/金钱蛙.ecm",
|
|
"models/players/形象/婚礼童男/婚礼童男.ecm",
|
|
"models/players/形象/婚礼童女/婚礼童女.ecm",
|
|
"models/players/形象/2011变身/园艺区哨兵/园艺区哨兵.ecm",
|
|
"models/players/形象/树鸡/树鸡.ecm",
|
|
"models/players/形象/小魔虎/小魔虎.ecm",
|
|
"models/players/形象/红色松鼠/红色松鼠.ecm",
|
|
"models/players/形象/陆化的海龟/陆化的海龟.ecm",
|
|
"models/players/形象/新娘的表哥/新娘的表哥.ecm",
|
|
"models/players/形象/哨兵傀儡/哨兵傀儡.ecm",
|
|
"models/players/形象/2013变身/企鹅帝王/企鹅帝王.ecm",
|
|
"models/players/形象/2013变身/企鹅帝王/企鹅皇后.ecm",
|
|
"models/players/形象/2013变身/雪兔/雪兔.ecm",
|
|
"models/players/形象/2013变身/泰迪熊/泰迪熊.ecm",
|
|
"models/players/形象/红色松鼠/红色松鼠大.ecm",
|
|
"models/players/形象/树鸡/树鸡大.ecm",
|
|
"models/players/形象/2011变身/园艺区哨兵/园艺区哨兵愤怒.ecm",
|
|
"models/players/形象/2011变身/园艺区哨兵/园艺区哨兵沮丧.ecm",
|
|
"models/players/形象/2011变身/园艺区哨兵/园艺区哨兵失落.ecm",
|
|
"models/players/形象/2013变身/雪兔/雪兔电光.ecm",
|
|
"models/players/形象/2013变身/龙/龙.ecm",
|
|
// 职业变身新模型
|
|
"models/players/形象/熊猫/熊猫.ecm",
|
|
"models/players/形象/蝶羽狐/蝶羽狐.ecm",
|
|
|
|
// 默认摆摊模型
|
|
"models/players/形象/摆摊/男/男.ecm",
|
|
"models/players/形象/摆摊/女/女.ecm",
|
|
|
|
// 胧族
|
|
"models/players/形象/夜影男/躯干/夜影男.ecm",
|
|
"models/players/形象/夜影女/躯干/夜影女.ecm",
|
|
"models/players/形象/月仙男/躯干/月仙男.ecm",
|
|
"models/players/形象/月仙女/躯干/月仙女.ecm",
|
|
|
|
// 胧族职业变身
|
|
"models/players/形象/胧族变身夜影男/胧族变身夜影男.ecm",
|
|
"models/players/形象/胧族变身夜影女/胧族变身夜影女.ecm",
|
|
"models/players/形象/胧族变身月仙男/胧族变身月仙男.ecm",
|
|
"models/players/形象/胧族变身月仙女/胧族变身月仙女.ecm",
|
|
};
|
|
|
|
public static NPCManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = FindAnyObjectByType<NPCManager>();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
public async Task<GameObject> GetModelPlayer(byte profession, byte gender)
|
|
{
|
|
var prefab = await AddressableManager.Instance.LoadPrefabAsync(_playerModelPaths[profession * GENDER.NUM_GENDER + gender]);
|
|
BMLogger.LogError("_playerModelPaths[profession * GENDER.NUM_GENDER + gender] = " + _playerModelPaths[profession * GENDER.NUM_GENDER + gender]);
|
|
if (prefab == null)
|
|
{
|
|
BMLogger.LogError( $" [NPC Manager] Not found Prefab from Addressable with profession : {profession} gender : {gender}");
|
|
return null;
|
|
}
|
|
|
|
var player = Instantiate(prefab);
|
|
player.SetActive(true);
|
|
return player;
|
|
}
|
|
public async Task<GameObject> GetDummyModel(int iShape)
|
|
{
|
|
// The first 2 shapes are the matters, so we need to subtract 2 from the shape id
|
|
// not sure it will cause any problem
|
|
|
|
int tempShape = iShape-2;
|
|
var prefab = await AddressableManager.Instance.LoadPrefabAsync(_playerModelPaths[tempShape]);
|
|
if (prefab == null)
|
|
{
|
|
BMLogger.LogError( $" [NPC Manager] Not found Prefab from Addressable with shape : {tempShape}");
|
|
return null;
|
|
}
|
|
var dummyModel = Instantiate(prefab);
|
|
dummyModel.SetActive(true);
|
|
return dummyModel;
|
|
}
|
|
}
|
|
}
|
|
//models/players/形象/白虎/白虎
|