You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.8 KiB
75 lines
2.8 KiB
using AOT;
|
|
using CoreGame;
|
|
using ProtoCSClass;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using xFrame;
|
|
using YooAsset;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class Handle_DropExtBox : BaseHandle
|
|
{
|
|
private class BoxDropGroup
|
|
{
|
|
public SyncExtDropRewardData data;
|
|
public Vector2 pos;
|
|
}
|
|
public override void DoHandle(int eid, object msg)
|
|
{
|
|
if (msg is SyncExtDropRewardData data)
|
|
{
|
|
var entity = Contexts.Combat.GetEntity(eid);
|
|
if (entity == null)
|
|
{
|
|
XLog.LogWarning("人死了");
|
|
return;
|
|
}
|
|
|
|
var strVal = CommParamDescMgr.Instance.SpdRwdShowPath.str_val;
|
|
YooAssets.LoadPrefabAsync(strVal, null, (path, go) =>
|
|
{
|
|
if (go is GameObject obj)
|
|
{
|
|
var e = Contexts.Combat.GetEntity(eid);
|
|
if (e == null)
|
|
{
|
|
return ;
|
|
}
|
|
var pos = e.transformProxy.position;
|
|
var random = Vector2.right;//MathHelper.OnsideUnitCircleRandom(CommParamDescMgr.Instance.SpdRwdArea.int_val);
|
|
var instanceSpdRwdShow = CommParamDescMgr.Instance.SpdRwdShow;
|
|
var endPos = new Vector3(pos.x + random.x, pos.y + random.y, 0);
|
|
if (NavMesh.Raycast(pos, endPos, out var hit, NavMesh.AllAreas))
|
|
{
|
|
endPos = hit.position;
|
|
}
|
|
obj.transform.position = endPos;
|
|
BoxDropGroup boxDropGroup = new BoxDropGroup();
|
|
boxDropGroup.data = data;
|
|
boxDropGroup.pos = obj.transform.position;
|
|
Contexts.Combat.renderTimerEntity?.renderTimer?.AddTimer(instanceSpdRwdShow.int_list[0] * 0.001f, boxDropGroup, DropItem);
|
|
Contexts.Combat.renderTimerEntity?.renderTimer?.AddTimer(instanceSpdRwdShow.int_list[1] * 0.001f, obj, DestoryBox);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public static void DestoryBox(object obj)
|
|
{
|
|
if (obj is GameObject go)
|
|
{
|
|
GameObject.Destroy(go);
|
|
}
|
|
}
|
|
public static void DropItem(object obj)
|
|
{
|
|
var boxDropGroup = (BoxDropGroup)obj;
|
|
var typeIDValueStrings = boxDropGroup.data.Rewards;
|
|
for (int i = 0; i < typeIDValueStrings.Count; i++)
|
|
{
|
|
DropItemSrv.DropItem(boxDropGroup.pos, typeIDValueStrings[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|