Exemplo n.º 1
0
    public ErrorCode Restart(ActionInitParam param)    // 不停止动画
    {
        if (param == null)
        {
            return(ErrorCode.InvalidParam);
        }

        if (param.GetType() != typeof(ActionMoveInitParam))
        {
            return(ErrorCode.InvalidParam);
        }

        ActionMoveInitParam thisParam = (ActionMoveInitParam)param;

        if (thisParam.wayOrDir)
        {
            mPathNodes = thisParam.wayPoint;

            mCurrentIndex = 0;

            mMoveMode = MOVE_MODE.MOVE_MODE_WAY;
        }
        else
        {
            mMoveMode      = MOVE_MODE.MOVE_MODE_DIRECTION;
            mMoveDirection = thisParam.dir;

            mOwner.SetMoveDirection(mMoveDirection);
        }

        return(ErrorCode.Succeeded);
    }
Exemplo n.º 2
0
    protected override ErrorCode doStart(ActionInitParam param)
    {
        if (param == null)
        {
            return(ErrorCode.InvalidParam);
        }

        if (param.GetType() != typeof(ActionMoveInitParam))
        {
            return(ErrorCode.InvalidParam);
        }

        return(Restart(param));
    }
    /// <summary>
    /// 开启一个Action, 并且将它加入到Update队列中.
    /// </summary>
    /// ?
    public ErrorCode StartAction(ActionInitParam param)
    {
        if (param == null)
        {
            return(ErrorCode.InvalidParam);
        }

        if (param.GetType() == typeof(ActionMoveInitParam))
        {
            ActionMove actionMove = GetActionByType(ActionTypeDef.ActionTypeMove) as ActionMove;
            if (actionMove != null)
            {
                return(actionMove.Restart(param));
            }
        }

        if (GetActionByType(param.ActionType) != null)
        {
            ErrorHandler.Parse(ErrorCode.ConfigError, "only one " + param.ActionType + " can run");
            return(ErrorCode.ConfigError);
        }

        Action action = BattleUnitActionFactory.Instance.Allocate(param.ActionType);

        if (action == null)
        {
            return(ErrorCode.LogicError);
        }

        action.Owner = mActionOwner;

        ErrorCode err = action.Start(param);

        if (err == ErrorCode.Succeeded)
        {
            mActionContainer[(int)param.ActionType] = action;
            IdleAction.SetActive(false);
        }

        return(err);
    }