Exemplo n.º 1
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.º 2
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();
        }
    }