Project_WL/Assets/Script/Ingame/SaveNPCMgr.cs

87 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SaveNPCMgr : MonoBehaviourSingletonTemplate<SaveNPCMgr>
{
List<NPCActor> list_npc = new List<NPCActor>();
List<MobActor> list_mob = new List<MobActor>();
List<Actor> rtn_actors = new List<Actor>();
bool isSet;
protected override void Awake()
{
base.Awake();
for (int i = 0; i < transform.childCount; i++)
{
var temp = transform.GetChild(i);
var npc = temp.GetComponent<NPCActor>();
if (npc != null) list_npc.Add(npc);
else
{
var mob = temp.GetComponent<MobActor>();
//mob.m_Role = eRole.QuestMob;
list_mob.Add(mob);
}
}
}
private void Update()
{
for (int i = 0; i < list_mob.Count; i++)
{
if (list_mob[i].Get_Target() != null)
{
for (int j = 0; j < list_npc.Count; j++)
list_npc[j].BubbleOff();
}
}
}
public void Set()
{
if (list_mob != null)
{
if (!isSet)
{
isSet = true;
list_mob.ForEach(f => f.Set(true, null, null, 0, false));
}
}
}
public void Set_Clear()
{
if (list_npc != null) list_npc.ForEach(f => f.Set_Off());
StartCoroutine(Off_Mob());
}
IEnumerator Off_Mob()
{
yield return new WaitForSeconds(1f);
if (list_mob != null) list_mob.ForEach(f => f.Off());
}
public List<Actor> Get_QuestMobs()
{
rtn_actors.Clear();
for (int i = 0; i < list_mob.Count; i++)
{
var temp = list_mob[i] as Actor;
if (!temp.IsDead())
rtn_actors.Add(temp);
}
return rtn_actors;
}
public bool IsClearQuestMobs()
{
for (int i = 0; i < list_mob.Count; i++)
{
if (!list_mob[i].IsDead())
return false;
}
return true;
}
}