142 lines
5.8 KiB
C#
142 lines
5.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
|
|
public class PCInfo : MonoBehaviourSingletonTemplate<PCInfo>
|
|
{
|
|
public void Make_Actors(bool _IsEnemy, ServerData sdata)
|
|
{
|
|
var curMapData = MyValue.MyChoiceMapData;
|
|
|
|
// PC
|
|
var pcid = sdata.Get_EqiupmentEquip(eItem.PC);
|
|
var pctable = table_classconfig.Ins.Get_Data_orNull(pcid);
|
|
var costumeid = sdata.Get_EqiupmentEquip(eItem.PCCostume);
|
|
var costumetable = table_costumelist.Ins.Get_Data_orNull(costumeid);
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>($"Assets/Res_Addr/PC/{costumetable.s_Prefab}.prefab", handle =>
|
|
{
|
|
if (handle.IsDone && handle.Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
var pc = DSUtil.Get_Clone<Actor>(handle.Result, transform);
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(pc.gameObject);
|
|
pc.Set(_IsEnemy, null, sdata, pcid, true);
|
|
pc.Set_MyPet(null);
|
|
ActorInfo.Ins.Add_Actor(pc, _IsEnemy ? eRole.EnemyPC : eRole.PC, 0, costumetable.s_Prefab);
|
|
|
|
var chapter = curMapData.n_MapID;
|
|
// Pets -> 2024. 9. 21 펫은 한 마리로 변경
|
|
dic_petbattle_deadcount[_IsEnemy][0] = dic_petbattle_deadcount[_IsEnemy][1] = 0;
|
|
Make_Pet(_IsEnemy, sdata, pc);
|
|
}
|
|
});
|
|
|
|
//// Fairy
|
|
//var fairyid = sdata.Get_EqiupmentEquip(eItem.Fairy);
|
|
//if (fairyid > 0)
|
|
//{
|
|
// if (!dic_fairy[_IsEnemy].ContainsKey(fairyid))
|
|
// {
|
|
// var table = table_fairy.Ins.Get_Data(fairyid);
|
|
// var fairy = DSUtil.Get_Clone<Actor>(Get_ModelPrefabPath(eItem.Fairy, table.Prefab), transform, null, table.Scale * Vector3.one);
|
|
// dic_fairy[_IsEnemy].Add(fairyid, fairy);
|
|
// }
|
|
// dic_fairy[_IsEnemy][fairyid].Set(_IsEnemy, sdata, fairyid, true);
|
|
//}
|
|
|
|
//// 전투 NPC
|
|
//for (int i = 0; i < list_BattleNPC[_IsEnemy].Count; i++)
|
|
//{
|
|
// if (list_BattleNPC[_IsEnemy][i].IsActiveNPC())
|
|
// {
|
|
// dic_actor[_IsEnemy].Add(list_BattleNPC[_IsEnemy][i]);
|
|
// list_BattleNPC[_IsEnemy][i].Set(false, sdata, 0, true);
|
|
// }
|
|
//}
|
|
}
|
|
public void Make_Pet(bool _IsEnemy, ServerData sdata, Actor pc)
|
|
{
|
|
var petlist = ActorInfo.Ins.Get_Actors(_IsEnemy ? eRole.EnemyPet : eRole.Pet);
|
|
petlist.ForEach(f => f.Off());
|
|
|
|
var pets = sdata.Get_EqiupmentEquip(eItem.Pet);
|
|
//for (int i = 0; i < pets.Count; i++)
|
|
{
|
|
if (pets > 0)
|
|
{
|
|
++dic_petbattle_deadcount[_IsEnemy][0];
|
|
var pettable = table_petlist.Ins.Get_Data_orNull(pets);
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>(pettable.s_PetPrefab, handle =>
|
|
{
|
|
var pet = DSUtil.Get_Clone<Actor>(handle.Result, transform, null, pettable.f_Scale * Vector3.one);
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(pet.gameObject);
|
|
ActorInfo.Ins.Add_Actor(pet, eRole.Pet, 0, pettable.s_PetPrefab);
|
|
|
|
pet.Set(_IsEnemy, pc, sdata, pets, true);
|
|
pet.Set_Card(0, 0);
|
|
pc.Set_MyPet(pet);
|
|
});
|
|
}
|
|
else
|
|
NewGameUI.Ins.arr_PetCard[0].Set_Empty();
|
|
}
|
|
}
|
|
public void Make_Farmer(int _id)
|
|
{
|
|
if (_id > 0)
|
|
{
|
|
Off_Farmer(_id);
|
|
|
|
//var farmerdata = table_farmer.Ins.Get_Data(_id);
|
|
//if (!dic_farmer.ContainsKey(_id))
|
|
//{
|
|
// var farmer = DSUtil.Get_Clone<FarmerActor>(DSUtil.Format("PC/Farm/{0}", farmerdata.Prefab), transform);
|
|
// dic_farmer.Add(_id, farmer);
|
|
//}
|
|
//dic_farmer[_id].Set(farmerdata, MyValue.MyPC.Get_position() + Random.insideUnitSphere);
|
|
}
|
|
}
|
|
public void Off_Farmer(int _id)
|
|
{
|
|
//if (dic_farmer.ContainsKey(_id))
|
|
// dic_farmer[_id].Off();
|
|
}
|
|
public void ReSet_Farmer()
|
|
{
|
|
//foreach (var item in dic_farmer)
|
|
// item.Value.ReSet();
|
|
}
|
|
|
|
//public void Set_QuestMobTarget(Actor _target)
|
|
//{ // NPC 구하기 퀘스트 시작
|
|
// dic_actor[false].ForEach(f => f.Change_Target(false, _target));
|
|
// dic_actor[false].ForEach(f => f.Add_FindEnemy(eRole.QuestMob));
|
|
// SaveNPCMgr.Ins.Get_QuestMobs().ForEach(f => f.Add_FindEnemy(eRole.PC)); // 타겟 찾기 시작
|
|
//}
|
|
//public void Add_FindTarget_AllPC(bool _IsEnemy, eRole _role, int _group = 0)
|
|
//{
|
|
// foreach (var item in dic_pc[_IsEnemy]) item.Value.Add_FindEnemy(_role, _group);
|
|
// foreach (var item in dic_pet[_IsEnemy]) item.Value.ForEach(f => f.Add_FindEnemy(_role, _group));
|
|
// list_Summon[_IsEnemy].ForEach(f => f.Add_FindEnemy(_role, _group));
|
|
//}
|
|
//public void Set_AllTarget(bool _IsEnemy, bool _find)
|
|
//{
|
|
// foreach (var item in dic_pc[_IsEnemy]) item.Value.Set_AllEnenmy(_find);
|
|
// foreach (var item in dic_pet[_IsEnemy]) item.Value.ForEach(f => f.Set_AllEnenmy(_find));
|
|
// list_Summon[_IsEnemy].ForEach(f => f.Set_AllEnenmy(_find));
|
|
//}
|
|
|
|
#region 투견장 상황
|
|
Dictionary<bool, List<int>> dic_petbattle_deadcount = new Dictionary<bool, List<int>> { { false, new List<int> { 0, 0 } }, { true, new List<int> { 0, 0 } } };
|
|
public void PetBattle_AddDead(bool isenemy)
|
|
{
|
|
dic_petbattle_deadcount[isenemy][1]++;
|
|
if (dic_petbattle_deadcount[isenemy][0] == dic_petbattle_deadcount[isenemy][1])
|
|
{
|
|
ActorInfo.Ins.All_Stop(true);
|
|
InGameInfo.Ins.PetBattleResult(isenemy);
|
|
}
|
|
}
|
|
#endregion
|
|
} |