Exemplo n.º 1
0
    /// <summary>
    /// user使用的技能对targetPosition产生skillRes指定的技能效果.
    /// </summary>
    public static ErrorCode SkillTakeEffect(BattleUnit user, SkillCommonTableItem skillRes, Vector3 targetPosition)
    {
        AttackerAttr attackerAttr = new AttackerAttr(user, (uint)skillRes.resID);

        if (skillRes.projectileResID != uint.MaxValue)
        {
            createProjectiles(user, (uint)skillRes.resID, skillRes.projectileResID, targetPosition);
        }

        // 给技能使用者添加的效果.
        ErrorHandler.Parse(
            AddSkillEffectByResource(attackerAttr, user, skillRes.skillEffect2UserInUseState)
            );

        // 向前延伸一定距离, 作为目标选择的中心点.
        Vector3 centerPosition = Utility.MoveVector3Towards(attackerAttr.AttackerPosition,
                                                            user.GetDirection(), skillRes.distForward);

        // 在中心点进行目标选择, 并添加技能效果.
        SelectTargetAndAddSkillEffect(attackerAttr, centerPosition, user.GetDirection(),
                                      skillRes.targetSelection, skillRes.skillEffect2Others);

        // 创建召唤物.
        ErrorHandler.Parse(
            CreateCreationAround(attackerAttr, skillRes.creationID, user.GetPosition(), user.GetDirection())
            );

        return(ErrorCode.Succeeded);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 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);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 初始化该结构.
    /// </summary>
    /// <param name="attacker">技能效果等的发起者.</param>
    /// <param name="skillCommonID">发起者使用的技能ID(非技能发起填入uint.MaxValue).</param>
    /// <param name="structMadeByRandEvent">该结构是否由randevent创造(检测并避免randevent循环产生效果).</param>
    public AttackerAttrImpl(BattleUnit attacker, uint skillCommonID, bool structMadeByRandEvent)
    {
        mStructMadeByRandEvent = structMadeByRandEvent;
        mSkillCommonID         = skillCommonID;
        if (attacker != null)
        {
            mAttackerID           = attacker.InstanceID;
            mAttackerName         = attacker.GetName();
            mAttackerRadius       = attacker.GetRadius();
            mAttackerLeague       = attacker.GetLeague();
            mEffectStartPosition  = mAttackerPosition = attacker.GetPosition();
            mEffectStartDirection = mAttackerDirection = attacker.GetDirection();
            mLevel         = attacker.GetLevel();
            mDamage        = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeDamage);
            mCriticalLevel = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeCrticalLV);

            mSummonerID    = attacker.SummonerID;
            mSummonerName  = attacker.SummonerName;
            mSummonerLevel = attacker.SummonerLevel;
        }
    }