示例#1
0
    public override bool Init(ObjectInitParam param)
    {
        if (!base.Init(param))
        {
            return(false);
        }

        mBulletParam = (BulletInitParam)param;

        if ((mBulletResource = DataManager.BulletTable[mBulletParam.resID] as BulletTableItem) == null)
        {
            SkillUtilities.ResourceNotFound("bullet", mBulletParam.resID);
            return(false);
        }

        mCreateDelay = mBulletParam.createDelay;

        mFirerAttr = mBulletParam.firerAttr;

        FlySpeed = mBulletResource.flySpeed;

        StartPosition  = mBulletParam.startPosition;
        TargetPosition = mBulletParam.targetPosition;

        Vector3 dir3d = TargetPosition - StartPosition;

        dir3d.y = 0;

        if (dir3d == Vector3.zero)
        {
            // 起始点与终点位置重叠, 取开火者当前朝向.
            BattleUnit firer       = mFirerAttr.CheckedAttackerObject();
            float      alternative = (firer != null) ? firer.GetDirection() : mFirerAttr.AttackerDirection;
            dir3d = Utility.RadianToVector3(alternative);
        }

        FlyDirection = Quaternion.LookRotation(dir3d);
        SetRotation(FlyDirection);

        AccelerateDelay = mBulletResource.accelerateDelay;

        mFlyTargetSelection = new TargetSelectionTableItem()
        {
            resID     = -1,
            desc      = "bullet hit",
            leagueSel = mBulletResource.leagueSelection,
            //maxTargetCount = mBulletResource.flyThroughCount - (uint)mHitted.Count,
            shape      = ShapeType.ShapeType_Rect,
            RectLength = mBulletResource.radiusOnCollide * 2
        };

        SetPosition(StartPosition);

        return(true);
    }
示例#2
0
    /// <summary>
    /// 根据子弹的类型, 调整子弹的目标点.
    /// </summary>
    public static Vector3 AdjustBulletTargetPosition(
        BulletTableItem bulletRes,
        Vector3 startPosition,
        Vector3 targetPosition
        )
    {
        float dir = Utility.Vector3ToRadian(targetPosition - startPosition);

        // 几种类型的子弹, 目标点延伸到最大射程处.
        return(NeedAdjustTargetPosition(bulletRes.type)
                        ? Utility.MoveVector3Towards(startPosition, dir, bulletRes.flyRange)
                        : targetPosition);
    }
示例#3
0
    /// <summary>
    /// 根据子弹的类型, 处理子弹的飞行方向.
    /// 返回子弹新的飞行目标点.
    /// </summary>
    public static Vector3 AdjustBulletDirection(BulletTableItem bulletRes, BattleUnit firer, Vector3 startPosition, Vector3 targetPosition)
    {
        // 几种类型的子弹, 沿着开火者的朝向飞行(这几种子弹按方向飞行)
        if (NeedAdjustTargetDirection(bulletRes.type))
        {
            // 处理起点与终点重合的特殊情况.
            float dist = Mathf.Max(0.1f, Utility.Distance2D(firer.GetPosition(), targetPosition));
            float dir  = firer.GetDirection();
            return(Utility.MoveVector3Towards(startPosition, dir, dist));
        }

        // 其他类型飞到目标点.
        return(targetPosition);
    }
示例#4
0
    /// <summary>
    /// 创建投掷物.
    /// </summary>
    public static ErrorCode createProjectiles(BattleUnit user, uint skillResID, uint projResID, Vector3 targetPosition)
    {
        ProjectileSettingsTableItem projSettings = DataManager.ProjectileSettingsTable[projResID] as ProjectileSettingsTableItem;

        for (uint i = 0; i < ProjectileSettingsTableItem.ProjectileCount; ++i)
        {
            ProjectileItem item = projSettings.items[i];

            if (item.bulletResID == uint.MaxValue)
            {
                break;
            }

            BulletTableItem bulletRes = DataManager.BulletTable[item.bulletResID] as BulletTableItem;

            // 枪口特效.
            if (item.bindpointEffect != uint.MaxValue)
            {
                SkillClientBehaviour.AddEffect2Object(user, item.bindpointEffect, item.initBindpoint);
            }

            ProjectileCreateParam param = new ProjectileCreateParam()
            {
                User                 = user,
                StartPosition        = user.GetBonePositionByName(item.initBindpoint),
                TargetPosition       = targetPosition,
                DistributionType     = item.distributionType,
                DistributionArgument = item.distributionArgument,
                BulletRes            = bulletRes,
                SkillResID           = skillResID
            };

            createProjectiles(param);
        }

        return(ErrorCode.Succeeded);
    }
示例#5
0
    private bool checkBullet()
    {
        DataType myName           = DataType.DATA_SKILL_BULLET;
        IDictionaryEnumerator itr = DataManager.BulletTable.GetEnumerator();

        while (itr.MoveNext())
        {
            BulletTableItem item = itr.Value as BulletTableItem;
            if (!checkParam(item.type < BulletType.BulletTypeCount, myName, item.resID, "bullet type"))
            {
                return(false);
            }

            if (item.bulletFigureID != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_EFFECT, item.bulletFigureID))
            {
                return(false);
            }

            if (item.targetSelectionOnArrive != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_TARGET_SELECTION, item.targetSelectionOnArrive))
            {
                return(false);
            }

            if (!checkParam(item.flySpeed >= 0f, myName, item.resID, "speed"))
            {
                return(false);
            }

            if (!checkParam(item.accelerateSpeed >= 0f, myName, item.resID, "加速度"))
            {
                return(false);
            }

            if (!checkParam(item.accelerateDelay != uint.MaxValue, myName, item.resID, "加速度延迟", "不需要加速度延迟时, 需填入0"))
            {
                return(false);
            }

            if (!checkParam(item.flyRange != 0, myName, item.resID, "子弹射程", "射程不能为0"))
            {
                return(false);
            }

            bool   flyHorizontally = (item.type != BulletType.BulletTypeCannonball && item.type != BulletType.BulletTypeGrenade && item.type != BulletType.BulletTypeBomb);
            string dumpMessage     = "类型为" + (uint)item.type + "的子弹" + (flyHorizontally ? "射程不可为-1" : "不支持射程(填入-1)");

            if (!checkParam(flyHorizontally == (item.flyRange != uint.MaxValue), myName, item.resID, "子弹射程", dumpMessage))
            {
                return(false);
            }

            if (!checkParam(item.type != BulletType.BulletTypeMissile || item.bulletFlyParam_0 >= 0f,
                            myName, item.resID, "追踪延迟", "追踪延迟必须不小于0"))
            {
                return(false);
            }

            if (!checkParam(item.type != BulletType.BulletTypeMissile || item.bulletFlyParam_1 != 0, myName, item.resID,
                            "追踪持续时间", "追踪持续时间不能为0"))
            {
                return(false);
            }

            if (!checkParam(item.flyHitCount > 0, myName, item.resID, "穿透人数", "穿透人数必须大于0"))
            {
                return(false);
            }

            if (!checkParam(item.leagueSelection < LeagueSelection.Count, myName, item.resID, "阵营选择"))
            {
                return(false);
            }

            if (!checkParam(item.radiusOnCollide > 0, myName, item.resID, "碰撞半径"))
            {
                return(false);
            }

            if (item.skilleffectOnFlyCollide != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skilleffectOnFlyCollide))
            {
                return(false);
            }

            if (item.threeDEffectOnArrive != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_EFFECT, item.threeDEffectOnArrive))
            {
                return(false);
            }

            if (item.targetSelectionOnArrive != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_TARGET_SELECTION, item.targetSelectionOnArrive))
            {
                return(false);
            }

            if (item.skilleffectOnArrive != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_EFFECT, item.skilleffectOnArrive))
            {
                return(false);
            }

            if (item.creationOnArrive != uint.MaxValue &&
                !checkLink(myName, item.resID, DataType.DATA_SKILL_CREATION, item.creationOnArrive))
            {
                return(false);
            }

            if (!checkParam(item.flyRange > 0, myName, item.resID, "子弹射程"))
            {
                return(false);
            }

            if (!checkParam(item.type != BulletType.BulletTypeCircleArc || item.bulletFlyParam_0 > 0,
                            myName, item.resID, "轨迹控制的参数 I", "该值必须大于0"))
            {
                return(false);
            }

            if (!checkParam(item.type != BulletType.BulletTypeSineWave || (item.bulletFlyParam_0 != 0 && item.bulletFlyParam_1 != 0),
                            myName, item.resID, "轨迹控制参数I或II", "二者均不可为0"))
            {
                return(false);
            }
        }
//      foreach (int key in DataManager.BulletTable.Keys)
//      {
//
//      }

        return(true);
    }