77 lines
2.1 KiB
C#
77 lines
2.1 KiB
C#
using Axibug;
|
|
using Axibug.Event;
|
|
using Axibug.Runtime;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
public class MonsterRole : RoleBase
|
|
{
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
public void Init(S_ROLE_MONSTER data)
|
|
{
|
|
base.Init(data);
|
|
}
|
|
|
|
protected override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
AppEntry.Event.Subscribe(RoleDeadEventArgs.EventId, OnRoleDeadEventArgs);
|
|
|
|
AppEntry.Event.Subscribe(RoleDeadAnimeEndEventArgs.EventId, OnRoleDeadAnimeEndEventArgs);
|
|
}
|
|
|
|
protected override void OnDisable()
|
|
{
|
|
base.OnDisable();
|
|
AppEntry.Event.Unsubscribe(RoleDeadEventArgs.EventId, OnRoleDeadEventArgs);
|
|
AppEntry.Event.Unsubscribe(RoleDeadAnimeEndEventArgs.EventId, OnRoleDeadAnimeEndEventArgs);
|
|
}
|
|
|
|
public override void MeshChangeMoveState(bool ToMoveState)
|
|
{
|
|
if (ToMoveState)
|
|
{
|
|
Anime.StartRun();
|
|
}
|
|
else
|
|
{
|
|
Anime.BackToIdle();
|
|
}
|
|
}
|
|
|
|
public override void Release()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void OnRoleDeadEventArgs(object sender, LogicEventArgs e)
|
|
{
|
|
RoleDeadEventArgs msg = (RoleDeadEventArgs)e;
|
|
if (msg == null) throw new GameException("RoleDeadEventArgs is null");
|
|
if (msg.RoleID == RoleID)
|
|
{
|
|
//关闭碰撞盒
|
|
mselfCollider.enabled = false;
|
|
//关闭受重力
|
|
mRigidbody.useGravity = false;
|
|
}
|
|
}
|
|
|
|
private void OnRoleDeadAnimeEndEventArgs(object sender, LogicEventArgs e)
|
|
{
|
|
RoleDeadAnimeEndEventArgs msg = (RoleDeadAnimeEndEventArgs)e;
|
|
if (msg == null) throw new GameException("RoleDeadAnimeEndEventArgs");
|
|
if (msg.RoleID == RoleID)
|
|
{
|
|
GamePlayEntry.RoleMgr.DestroyRole(this);
|
|
}
|
|
}
|
|
}
|
|
}
|