コード例 #1
0
    /// <summary>
    /// 发送攻击请求
    /// </summary>
    /// <param name="target"></param>
    /// <returns></returns>
    public behaviac.EBTStatus Attack(FightAgent target)
    {
        if (target == null)
        {
            return(behaviac.EBTStatus.BT_FAILURE);
        }
        if (target.IsDead())
        {
            return(behaviac.EBTStatus.BT_SUCCESS);
        }

        if (curActionStatus != ActionStatus.StopAndDoingSomething)
        {
            curActionStatus = ActionStatus.StopAndDoingSomething;

            //开启一个协程计算时间处理攻击? 还是用动画事件处理攻击?
            MgrCenter.Instance.SendMsg(Msgs.GetMsgAtkRequest((ushort)SoilderFightEvent.SoilderAtkClientRequest, Id, target.Id));
        }

        return(behaviac.EBTStatus.BT_RUNNING);
    }
コード例 #2
0
    /// <summary>
    /// 攻击当前的目标,每次攻击由这个AI发出攻击请求,确保攻击在各个终端的一致性
    /// </summary>
    /// <returns></returns>
    public behaviac.EBTStatus AttackCurEnemy()
    {
        if (curTarget == null)
        {
            isAttacking = false;
            MgrCenter.Instance.SendMsg(Msgs.GetMsgInt((ushort)BuildingFightEvent.DefenseTowerIdle, Id));
            return(behaviac.EBTStatus.BT_FAILURE);
        }
        if (curTarget.IsDead())
        {
            isAttacking = false;
            curTarget   = null;
            MgrCenter.Instance.SendMsg(Msgs.GetMsgInt((ushort)BuildingFightEvent.DefenseTowerIdle, Id));
            return(behaviac.EBTStatus.BT_SUCCESS);
        }

        if (!isAttacking)
        {
            isAttacking = true;
            Attack(curTarget);
        }

        return(behaviac.EBTStatus.BT_RUNNING);
    }