147 lines
6.6 KiB
C#
147 lines
6.6 KiB
C#
using System.Collections.Generic;
|
|
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);
|
|
LoadMapMgr.Ins.Get_PortalPos(MyValue.MyChoiceMapData, portalpos =>
|
|
{
|
|
// Pets -> 2024. 9. 21 펫은 한 마리로 변경
|
|
dic_petbattle_deadcount[_IsEnemy][0] = dic_petbattle_deadcount[_IsEnemy][1] = 0;
|
|
Make_Pet(_IsEnemy, sdata, pc); // 펫 생성
|
|
Make_Worker(sdata, pc); // 일꾼 생성
|
|
});
|
|
ActorInfo.Ins.Add_Actor(pc, _IsEnemy ? eRole.EnemyPC : eRole.PC, 0, costumetable.s_Prefab);
|
|
}
|
|
});
|
|
}
|
|
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());
|
|
|
|
// PD 지시 #763 (2026-09-06) "내가 지시할때까지 플레이어의 펫은 등장시키지 마."
|
|
// · 값은 코드 상수가 아니라 WLGameplaySettings 에셋에서 읽는다(C45). 다시 등장시킬 때는 에셋 체크박스만 켠다.
|
|
// · 적 펫(_IsEnemy = PvP·투견장 상대)은 건드리지 않는다.
|
|
// · 진입 경로는 여기 한 곳뿐이다 — Make_Actors(맵 진입) 와 PetUI.OnClick_Back(펫 교체) 모두 이 함수를 탄다.
|
|
// · 펫 미보유 계정과 완전히 같은 상태(펫 카드 Empty · Get_MyPet() null)를 만든다.
|
|
if (!_IsEnemy && !WL.Settings.WLGameplaySettings.SpawnPlayerPet)
|
|
{
|
|
if (!DSUtil.CheckNull(pc)) pc.Set_MyPet(null);
|
|
if (NewGameUI.isIns && NewGameUI.Ins.arr_PetCard != null && NewGameUI.Ins.arr_PetCard.Length > 0)
|
|
NewGameUI.Ins.arr_PetCard[0].Set_Empty();
|
|
return;
|
|
}
|
|
|
|
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_Worker(ServerData sdata, Actor pc)
|
|
{
|
|
var workerid = sdata.Get_EqiupmentEquip(eItem.Worker);
|
|
if (workerid > 0)
|
|
{
|
|
var workerData = table_worker.Ins.Get_Data_orNull(workerid);
|
|
AddrResourceMgr.Ins.LoadObject<GameObject>($"Assets/Res_Addr/Worker/{workerData.s_Prefab}.prefab", handle =>
|
|
{
|
|
var worker = DSUtil.Get_Clone<Actor>(handle.Result, transform, null, workerData.f_Scale * Vector3.one);
|
|
ActorInfo.Ins.Add_Actor(worker, eRole.Worker, 0, "");
|
|
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(worker.gameObject);
|
|
worker.Set(false, pc, sdata, workerid, false);
|
|
});
|
|
}
|
|
}
|
|
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
|
|
} |