90 lines
2.9 KiB
C#
90 lines
2.9 KiB
C#
|
|
using Games.LogicObj;
|
|||
|
|
using GCGame.Table;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 客户端NPC 有些NPC需要客户端自己在一定的条件触发
|
|||
|
|
/// Effect.txt 表格扩展参数说明
|
|||
|
|
/// Param1 :EffectParam.txt中id值
|
|||
|
|
/// Param2 :EffectParam.txt中id值
|
|||
|
|
/// Param3 :EffectParam.txt中id值
|
|||
|
|
/// Param4 :EffectParam.txt中id值
|
|||
|
|
/// EffectParams
|
|||
|
|
/// 参数1 ClientNpc.txt表格中的ID
|
|||
|
|
/// 参数2 ClientNpc.txt表格中的ID
|
|||
|
|
/// 参数3 ClientNpc.txt表格中的ID
|
|||
|
|
/// 参数4 ClientNpc.txt表格中的ID
|
|||
|
|
/// </summary>
|
|||
|
|
public class Impact_ClientNpc : ImpactEffectBase
|
|||
|
|
{
|
|||
|
|
public override EffectLogic.EffectType ImpactEffectType
|
|||
|
|
{
|
|||
|
|
get { return EffectLogic.EffectType.TYPE_CLIENTNPC; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
List<Obj_ClientNPC> m_clientNpcs = new List<Obj_ClientNPC>();
|
|||
|
|
|
|||
|
|
public override void StartEffect()
|
|||
|
|
{
|
|||
|
|
base.StartEffect();
|
|||
|
|
for(int i=0;i<Data.getParamValueCount();i++)
|
|||
|
|
{
|
|||
|
|
var paramid = Data.GetParamValuebyIndex(i);
|
|||
|
|
var param = TableManager.GetEffectParamByID(paramid, 0);
|
|||
|
|
if (param != null)
|
|||
|
|
{
|
|||
|
|
for(int j=0;j<param.getParamValueCount();j++)
|
|||
|
|
{
|
|||
|
|
int id = -1;
|
|||
|
|
string indexStr = param.GetParamValuebyIndex(j);
|
|||
|
|
if(int.TryParse(indexStr, out id))
|
|||
|
|
{
|
|||
|
|
Tab_ClientNPC npc = TableManager.GetClientNPCByID(id, 0);
|
|||
|
|
if(npc!=null)
|
|||
|
|
{
|
|||
|
|
CreateNPC(npc);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void CreateNPC(Tab_ClientNPC npc)
|
|||
|
|
{
|
|||
|
|
Obj_ClientNPC_Init_Data initData = new Obj_ClientNPC_Init_Data();
|
|||
|
|
initData.m_ClientNPC = npc;
|
|||
|
|
initData.m_fX = npc.StartPosX;
|
|||
|
|
initData.m_fZ = npc.StartPosZ;
|
|||
|
|
initData.m_fDir = npc.FaceDir;
|
|||
|
|
if(npc.IsFellowOwer==1)
|
|||
|
|
{
|
|||
|
|
Vector3 newPos = objCharacter.Position - objCharacter.ObjTransform.forward;
|
|||
|
|
initData.m_fX = newPos.x;
|
|||
|
|
initData.m_fZ = newPos.z;
|
|||
|
|
initData.m_OwnerObjId = objCharacter.ServerID;
|
|||
|
|
initData.m_OwerName = objCharacter.name;
|
|||
|
|
}
|
|||
|
|
initData.m_RoleBaseID = npc.RoleBaseID;
|
|||
|
|
initData.m_StrName = npc.Name;
|
|||
|
|
ObjParent newNPC = Singleton<ObjManager>.Instance.NewCharacterObj(Games.GlobeDefine.GameDefine_Globe.OBJ_TYPE.OBJ_CLIENTNPC, initData);
|
|||
|
|
if(newNPC!=null)
|
|||
|
|
{
|
|||
|
|
Obj_ClientNPC clientNpc = newNPC as Obj_ClientNPC;
|
|||
|
|
if (clientNpc != null)
|
|||
|
|
m_clientNpcs.Add(clientNpc);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void StopEffect()
|
|||
|
|
{
|
|||
|
|
base.StopEffect();
|
|||
|
|
for(int i=0;i<m_clientNpcs.Count;i++)
|
|||
|
|
{
|
|||
|
|
m_clientNpcs[i].DestroyObj();
|
|||
|
|
}
|
|||
|
|
m_clientNpcs.Clear();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|