Exemplo n.º 1
0
    /// <summary>
    /// 点对对象范围攻击
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="effectKey">子弹预设key(或path)</param>
    /// <param name="releasePos">子弹飞行起点</param>
    /// <param name="targetObj">子弹目标单位</param>
    /// <param name="scopeRaduis">范围半径</param>
    /// <param name="speed">子弹飞行速度</param>
    /// <param name="durTime">范围特效持续时间</param>
    /// <param name="taType">子弹飞行轨迹</param>
    /// <param name="callback">攻击结束回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPointToObjScopeGeneralAttack(PositionObject attacker,
                                                          string[] effectKey,
                                                          Vector3 releasePos,
                                                          GameObject targetObj,
                                                          float scopeRaduis,
                                                          float speed,
                                                          float durTime,
                                                          TrajectoryAlgorithmType taType,
                                                          Action callback,
                                                          Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        result = new PointToObjScopeGeneralAttack(attacker,
                                                  effectKey,
                                                  releasePos,
                                                  targetObj,
                                                  scopeRaduis,
                                                  speed,
                                                  durTime,
                                                  taType,
                                                  callback,
                                                  callbackForEveryOne);

        return(result);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 范围伤害(矩形)
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="effectKey">范围特效</param>
    /// <param name="targetPos">目标位置</param>
    /// <param name="width">宽度</param>
    /// <param name="height">高度</param>
    /// <param name="rotate">旋转角度(0度为z轴正方向)</param>
    /// <param name="durTime">持续时间</param>
    /// <param name="callback">结束回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPositionRectScopeGeneralAttack(PositionObject attacker,
                                                            string effectKey,
                                                            Vector3 targetPos,
                                                            float width,
                                                            float height,
                                                            float rotate,
                                                            float durTime,
                                                            Action callback,
                                                            Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        // 创建图形 加入偏移 效果为目标前方一条直线
        var graphics = new RectGraphics(new Vector2(targetPos.x, targetPos.z), width, height, rotate);

        result = new PositionScopeGeneralAttack(attacker,
                                                effectKey,
                                                targetPos,
                                                graphics,
                                                durTime,
                                                callback,
                                                callbackForEveryOne);

        return(result);
    }
Exemplo n.º 3
0
    /// <summary>
    /// 范围伤害(矩形带正方向偏移)
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="effectKey">范围特效</param>
    /// <param name="targetPos">目标位置</param>
    /// <param name="width">宽度</param>
    /// <param name="height">高度</param>
    /// <param name="rotate">旋转角度(0度为z轴正方向)</param>
    /// <param name="offset">正方向偏移值</param>
    /// <param name="durTime">持续时间</param>
    /// <param name="callback">结束回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPositionRectScopeGeneralAttack(PositionObject attacker,
                                                            string effectKey,
                                                            Vector3 targetPos,
                                                            float width,
                                                            float height,
                                                            float rotate,
                                                            float offset,
                                                            float durTime,
                                                            Action callback,
                                                            Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        // 创建图形 加入偏移 效果为目标前方一条直线
        // 将图形像攻击者前方推移offset的距离
        var offsetV2    = new Vector2(attacker.X, attacker.Y);
        var targetPosV2 = offsetV2 + new Vector2(attacker.MapCellObj.transform.forward.x, attacker.MapCellObj.transform.forward.z) * offset;
        var graphics    = new RectGraphics(targetPosV2, width, height, rotate);

        result = new PositionScopeGeneralAttack(attacker,
                                                effectKey,
                                                targetPos,
                                                graphics,
                                                durTime,
                                                callback,
                                                callbackForEveryOne);

        return(result);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 范围伤害(扇形)
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="effectKey">范围特效</param>
    /// <param name="targetPos">目标位置</param>
    /// <param name="scopeRaduis">范围半径</param>
    /// <param name="openAngle">扇形角度</param>
    /// <param name="rotate">旋转角度(0度为z轴正方向)</param>
    /// <param name="durTime">持续时间</param>
    /// <param name="callback">结束回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPositionSectorScopeGeneralAttack(PositionObject attacker,
                                                              string effectKey,
                                                              Vector3 targetPos,
                                                              float scopeRaduis,
                                                              float openAngle,
                                                              float rotate,
                                                              float durTime,
                                                              Action callback,
                                                              Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        // 创建图形
        var graphics = new SectorGraphics(new Vector2(targetPos.x, targetPos.z), rotate, scopeRaduis, openAngle);

        result = new PositionScopeGeneralAttack(attacker,
                                                effectKey,
                                                targetPos,
                                                graphics,
                                                durTime,
                                                callback,
                                                callbackForEveryOne);

        return(result);
    }
Exemplo n.º 5
0
    public IGeneralAttack GetGeneralAttack()
    {
        IGeneralAttack result = null;



        return(result);
    }
Exemplo n.º 6
0
    /// <summary>
    /// 范围伤害(任意图形)
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="effectKey">范围特效</param>
    /// <param name="targetPos">目标点位置</param>
    /// <param name="graphics">范围检测图形</param>
    /// <param name="durTime">持续时间</param>
    /// <param name="callback">结束回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPositionScopeGeneralAttack(PositionObject attacker,
                                                        string effectKey,
                                                        Vector3 targetPos,
                                                        ICollisionGraphics graphics,
                                                        float durTime,
                                                        Action callback,
                                                        Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        result = new PositionScopeGeneralAttack(attacker,
                                                effectKey,
                                                targetPos,
                                                graphics,
                                                durTime,
                                                callback,
                                                callbackForEveryOne);

        return(result);
    }
Exemplo n.º 7
0
    /// <summary>
    /// 常规普通攻击
    /// </summary>
    /// <param name="attacker">攻击者数据</param>
    /// <param name="beAttackMember">被攻击者数据</param>
    /// <param name="effectKey">子弹预设key(或path)</param>
    /// <param name="releasePos">子弹飞行起点</param>
    /// <param name="targetObj">子弹目标单位</param>
    /// <param name="speed">子弹飞行速度</param>
    /// <param name="taType">子弹飞行轨迹</param>
    /// <param name="callback">攻击结束回调</param>
    /// <returns></returns>
    public IGeneralAttack GetNormalGeneralAttack(PositionObject attacker,
                                                 PositionObject beAttackMember,
                                                 string effectKey,
                                                 Vector3 releasePos,
                                                 GameObject targetObj,
                                                 float speed,
                                                 TrajectoryAlgorithmType taType,
                                                 Action <GameObject> callback)
    {
        IGeneralAttack result = null;

        result = new NormalGeneralAttack(attacker,
                                         beAttackMember,
                                         effectKey,
                                         releasePos,
                                         targetObj,
                                         speed,
                                         taType,
                                         callback);

        return(result);
    }
Exemplo n.º 8
0
    /// <summary>
    /// 点对点范围伤害
    /// </summary>
    /// <param name="attacker">攻击者</param>
    /// <param name="releasePos">发射点</param>
    /// <param name="targetPos">目标点</param>
    /// <param name="scopeRaduis">范围伤害半径</param>
    /// <param name="speed">飞行速度</param>
    /// <param name="taType">弹道类型</param>
    /// <param name="callback">完成回调</param>
    /// <param name="callbackForEveryOne">每个受击单位的回调</param>
    /// <returns></returns>
    public IGeneralAttack GetPointToPositionScopeGeneralAttack(PositionObject attacker,
                                                               Vector3 releasePos,
                                                               Vector3 targetPos,
                                                               float scopeRaduis,
                                                               float speed,
                                                               TrajectoryAlgorithmType taType,
                                                               Action callback,
                                                               Action <GameObject> callbackForEveryOne = null)
    {
        IGeneralAttack result = null;

        result = new PointToPositionScopeGeneralAttack(attacker,
                                                       releasePos,
                                                       targetPos,
                                                       scopeRaduis,
                                                       speed,
                                                       taType,
                                                       callback,
                                                       callbackForEveryOne);

        return(result);
    }
Exemplo n.º 9
0
    /// <summary>
    /// 攻击
    /// </summary>
    private void Attack()
    {
        if (workingObj != null && targetObj != null)
        {
            IGeneralAttack normalGeneralAttack = null;
            if (workingObj.AllData.MemberData.AttackType == Utils.BulletTypeNormal)
            {
                normalGeneralAttack = GeneralAttackManager.Instance()
                                      .GetNormalGeneralAttack(workingObj, targetObj, "jiguang1.prefab",
                                                              workingObj.transform.position + new Vector3(0, 10, 0),
                                                              targetObj.gameObject,
                                                              200,
                                                              TrajectoryAlgorithmType.Line,
                                                              (obj) =>
                {
                    //Debug.Log("普通攻击");
                });
            }
            else if (workingObj.AllData.MemberData.AttackType == Utils.BulletTypeScope)
            {
                //// 获取
                ////Debug.Log("AOE");
                //var armyAOE = workingObj.AllData.AOEData;
                //// 根据不同攻击类型获取不同数据
                //switch (armyAOE.AOEAim)
                //{
                //    case Utils.AOEObjScope:
                //        normalGeneralAttack = GeneralAttackManager.Instance().GetPointToObjScopeGeneralAttack(workingObj,
                //            new[] { armyAOE.BulletModel, armyAOE.DamageEffect },
                //            workingObj.transform.position,
                //            targetObj.gameObject,
                //            armyAOE.AOERadius,
                //            200,
                //            armyAOE.EffectTime,
                //            (TrajectoryAlgorithmType)armyAOE.BulletPath,
                //            () =>
                //            {
                //                //Debug.Log("AOE Attack1");
                //            });
                //        break;
                //    case Utils.AOEPointScope:
                //        normalGeneralAttack =
                //            GeneralAttackManager.Instance().GetPointToPositionScopeGeneralAttack(workingObj,
                //                new[] { armyAOE.BulletModel, armyAOE.DamageEffect },
                //                workingObj.transform.position,
                //                targetObj.transform.position,
                //                armyAOE.AOERadius,
                //                200,
                //                armyAOE.EffectTime,
                //                (TrajectoryAlgorithmType)armyAOE.BulletPath,
                //                () =>
                //                {
                //                    //Debug.Log("AOE Attack2");
                //                });
                //        break;
                //    case Utils.AOEScope:
                //        normalGeneralAttack = GeneralAttackManager.Instance().GetPositionScopeGeneralAttack(workingObj,
                //            armyAOE.DamageEffect,
                //            workingObj.transform.position,
                //            new CircleGraphics(new Vector2(workingObj.X, workingObj.Y), armyAOE.AOERadius),
                //            armyAOE.EffectTime,
                //            () =>
                //            {
                //                //Debug.Log("AOE Attack3");
                //            });
                //        break;
                //    case Utils.AOEForwardScope:
                //        normalGeneralAttack =
                //            GeneralAttackManager.Instance().GetPositionRectScopeGeneralAttack(workingObj,
                //                armyAOE.DamageEffect,
                //                workingObj.transform.position,
                //                armyAOE.AOEWidth,
                //                armyAOE.AOEHeight,
                //                Vector2.Angle(Vector2.up, new Vector2(workingObj.transform.forward.x, workingObj.transform.forward.z)),
                //                armyAOE.EffectTime,
                //                () =>
                //                {
                //                    //Debug.Log("AOE Attack4");
                //                });
                //        break;
                //}
            }

            if (normalGeneralAttack != null)
            {
                normalGeneralAttack.Begin();
            }
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// 发射子弹
    /// </summary>
    /// <param name="fsm"></param>
    private void ShootBullet(SoldierFSMSystem fsm)
    {
        var enemyDisplayOwner = fsm.EnemyTarget;
        var myDisplayOwner    = fsm.Display;
        var enemyClusterData  = enemyDisplayOwner.ClusterData;
        var myClusterData     = myDisplayOwner.ClusterData;
        var myMemberData      = myClusterData.AllData.MemberData;
        var effect            = myClusterData.AllData.EffectData;

        // 如果攻击方的攻击方式不为普通攻击的读取攻击表, 获取对应攻击方式
        IGeneralAttack normalGeneralAttack = null;

        switch (myMemberData.AttackType)
        {
        case Utils.BulletTypeNormal:
            normalGeneralAttack = GeneralAttackManager.Instance()
                                  .GetNormalGeneralAttack(myClusterData, enemyClusterData, effect.Bullet,
                                                          myClusterData.transform.position + new Vector3(0, 10, 0),
                                                          enemyClusterData.gameObject,
                                                          myMemberData.BulletSpeed,
                                                          TrajectoryAlgorithmType.Line,
                                                          (obj) =>
            {
                //Debug.Log("普通攻击");
                // 播受击特效
            });
            break;

        case Utils.BulletTypeScope:
            // 获取
            //Debug.Log("AOE");
            var armyAOE = myClusterData.AllData.AOEData;
            // 根据不同攻击类型获取不同数据
            switch (armyAOE.AOEAim)
            {
            case Utils.AOEObjScope:
                normalGeneralAttack = GeneralAttackManager.Instance().GetPointToObjScopeGeneralAttack(myClusterData,
                                                                                                      new[] { effect.Bullet, effect.RangeEffect },
                                                                                                      myClusterData.transform.position,
                                                                                                      enemyClusterData.gameObject,
                                                                                                      armyAOE.AOERadius,
                                                                                                      myMemberData.BulletSpeed,
                                                                                                      1, //effect.EffectTime,
                                                                                                      (TrajectoryAlgorithmType)Enum.Parse(typeof(TrajectoryAlgorithmType), effect.TrajectoryEffect),
                                                                                                      () =>
                {
                    //Debug.Log("AOE Attack1");
                });
                break;

            case Utils.AOEPointScope:
                normalGeneralAttack =
                    GeneralAttackManager.Instance().GetPointToPositionScopeGeneralAttack(myClusterData,
                                                                                         myClusterData.transform.position,
                                                                                         enemyClusterData.transform.position,
                                                                                         armyAOE.AOERadius,
                                                                                         myMemberData.BulletSpeed,
                                                                                         (TrajectoryAlgorithmType)Enum.Parse(typeof(TrajectoryAlgorithmType), effect.TrajectoryEffect),
                                                                                         () =>
                {
                    //Debug.Log("AOE Attack2");
                });
                break;

            case Utils.AOEScope:
                normalGeneralAttack = GeneralAttackManager.Instance().GetPositionScopeGeneralAttack(myClusterData,
                                                                                                    effect.RangeEffect,
                                                                                                    myClusterData.transform.position,
                                                                                                    new CircleGraphics(new Vector2(myClusterData.X, myClusterData.Y), armyAOE.AOERadius),
                                                                                                    1, //effect.EffectTime,
                                                                                                    () =>
                {
                    //Debug.Log("AOE Attack3");
                });
                break;

            case Utils.AOEForwardScope:
                normalGeneralAttack =
                    GeneralAttackManager.Instance().GetPositionRectScopeGeneralAttack(myClusterData,
                                                                                      effect.RangeEffect,
                                                                                      myClusterData.transform.position,
                                                                                      armyAOE.AOEWidth,
                                                                                      armyAOE.AOEHeight,
                                                                                      Vector2.Angle(Vector2.up, new Vector2(myClusterData.transform.forward.x, myClusterData.transform.forward.z)),
                                                                                      1, //effect.EffectTime,
                                                                                      () =>
                {
                    //Debug.Log("AOE Attack4");
                    // 播放目标的受击特效
                });
                break;
            }
            break;
        }

        if (normalGeneralAttack != null)
        {
            normalGeneralAttack.Begin();
        }
    }