版权声明:欢迎转载,转载请注明原博客链接:http://blog.csdn.net/u013108312 和本文章的链接。谢谢合作。作者:CircleGood https://blog.csdn.net/u013108312/article/details/70313242
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class MonsterPlayerStateAttack : StateBase
{
public MonsterPlayerStateAttack(PlayerBase player)
: base(player)
{
}
public override uint GetStateID()
{
return StateDef.attack;
}
public override void OnEnter(StateMachine machine, IState prevState, object param1, object param2)
{
Debug.Log("attack1");
//mPlayer.Play("attack1");
Vector3 v3 = mPlayer.OtherRole[0].transform.position + new Vector3(1f,0,0);
Tween tw = mPlayer.transform.DOMove(v3, 0.3f);
tw.OnComplete(delegate()
{
mPlayer.Play("attack1");
});
}
public override void OnLeave(IState nextState, object param1, object param2)
{
GameServerMgr.GetInstance().RequsterNotifier(CombatDef.AttackOver, mPlayer, nextState.GetStateID());
}
public override void OnUpate()
{
}
public override void OnFixedUpdate()
{
}
public override void OnLeteUpdate()
{
}
public override void OnAnimationAttackOver(string clipName)
{
Debug.Log("Monster OnAnimationAttackOver");
mPlayer.OtherRole[0].SwitchState(StateDef.hit);
}
public override void OnAnimationEventEnd(string clipName)
{
mPlayer.transform.DOLocalMove(Vector3.zero, 0.3f).OnComplete(delegate()
{
mPlayer.SwitchState(StateDef.idle);
});
}
}
using UnityEngine;
using System.Collections;
public class MonsterPlayerStateHit : StateBase
{
public MonsterPlayerStateHit(PlayerBase player)
: base(player)
{
}
public override uint GetStateID()
{
return StateDef.hit;
}
public override void OnEnter(StateMachine machine, IState prevState, object param1, object param2)
{
mPlayer.Play("hurt");
}
public override void OnLeave(IState nextState, object param1, object param2)
{
GameServerMgr.GetInstance().RequsterNotifier(CombatDef.AttackOver, mPlayer, nextState.GetStateID());
}
public override void OnUpate()
{
}
public override void OnFixedUpdate()
{
}
public override void OnLeteUpdate()
{
}
public override void OnAnimationAttackOver(string clipName)
{
Debug.Log(22);
}
public override void OnAnimationEventEnd(string clipName)
{
Debug.Log(11);
mPlayer.SwitchState(StateDef.idle);
}
}
using UnityEngine;
using System.Collections;
public class MonsterPlayerStateIdle : StateBase
{
public MonsterPlayerStateIdle(PlayerBase player)
: base(player)
{
}
public override uint GetStateID()
{
return StateDef.idle;
}
public override void OnEnter(StateMachine machine, IState prevState, object param1, object param2)
{
mPlayer.Play("idle");
}
public override void OnLeave(IState nextState, object param1, object param2)
{
}
public override void OnUpate()
{
}
public override void OnFixedUpdate()
{
}
public override void OnLeteUpdate()
{
}
}