Exemplo n.º 1
0
 /// <summary>
 /// 攻击状态构造函数
 /// </summary>
 /// <param name="host"></param>
 public GeneralWalkState(GeneralSoldier host)
     : base(host)
 {
     //取得士兵和动画
     _host = host;
     _navmeshAgent = _host.GetComponent<NavMeshAgent>();
 }
Exemplo n.º 2
0
 /// <summary>
 /// 攻击状态构造函数
 /// </summary>
 /// <param name="host"></param>
 public GeneralAttackState(GeneralSoldier host)
     : base(host)
 {
     //取得士兵和动画
     soldier  = host;
     animator = soldier.GetComponent <Animator>();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 攻击状态构造函数
 /// </summary>
 /// <param name="host"></param>
 public GeneralWalkState(GeneralSoldier host)
     : base(host)
 {
     //取得士兵和动画
     _host         = host;
     _navmeshAgent = _host.GetComponent <NavMeshAgent>();
 }
Exemplo n.º 4
0
 /// <summary>
 /// 攻击状态构造函数
 /// </summary>
 /// <param name="host"></param>
 public GeneralHurtState(GeneralSoldier host)
     : base(host)
 {
     //取得士兵和动画
     soldier = host;
     animator = soldier.GetComponent<Animator>();
 }
Exemplo n.º 5
0
    /// <summary>
    /// 初始化
    /// </summary>
    public override void init()
    {
        _target = null;

        //播放移动动作
        _host.GetComponent <Animator>().Play("run01");

        _host.walkStop();

        _host.walkEnable();
    }
Exemplo n.º 6
0
    /// <summary>
    /// 每帧的更新
    /// </summary>
    public override void update()
    {
        //如果死亡
        if (_deadDelay <= 0)
        {
            _host.notifyEvent(this, DEAD_COMPLETE_EVENT, null);
            return;
        }

        //计时
        _deadDelay--;

        //播放死亡动画
        _host.GetComponent <Animator>().Play("die01");
    }
Exemplo n.º 7
0
    /// <summary>
    /// 每帧的更新
    /// </summary>
    public override void update()
    {
        if (_host == null)
        {
            return;
        }

        //播放移动动作
        _host.GetComponent <Animator>().Play("run01");

        //面向敌人
        _host.gameObject.transform.LookAt(_host._data.AttackTarget.gameObject.transform);

        //向目标靠近,靠近速度是自身的移动速度
        _host.gameObject.transform.Translate(Vector3.forward * Time.deltaTime * _host._data.MoveSpeed);

        //如果进入攻击范围,靠近行为结束
        if (Vector3.Distance(_host.transform.position, _host._data.AttackTarget.transform.position) <= _host._data.AttckDistance)
        {
            //发靠近行为结束消息
            notifyEvent(MOVE_COMPLETE_EVENT);
        }
    }
Exemplo n.º 8
0
 /// <summary>
 /// 每帧的更新
 /// </summary>
 public override void update()
 {
     _host.GetComponent <Animator>().Play("win01");
 }
Exemplo n.º 9
0
 /// <summary>
 /// 初始化
 /// </summary>
 public override void init()
 {
     //运行待机动画
     _host.GetComponent <Animator>().Play("idle01");
 }