Procházet zdrojové kódy

风车手里剑忍者

1243896040 před 5 dny
rodič
revize
e33ad973d2

+ 23 - 7
ActionTowerDefense/Assets/Resources/Prefab/ESpirits/ESpirits_Pinja.prefab

@@ -170,7 +170,7 @@ Rigidbody:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 2437299196472462361}
   serializedVersion: 2
-  m_Mass: 8
+  m_Mass: 7
   m_Drag: 0.1
   m_AngularDrag: 0.05
   m_UseGravity: 1
@@ -191,7 +191,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   owner: {fileID: 0}
-  attackInterval: 0
+  attackInterval: 0.5
   addAttackEffect: {fileID: 0}
   isAttackTriggerOn: 0
   targetTypes: 0100000003000000
@@ -260,7 +260,7 @@ MonoBehaviour:
     needToChange: 0
     attackDistance: 15
     maxAttackDis: 15
-    minAttackDis: 9
+    minAttackDis: 10
     searchMode: 0
     canHitFly: 1
     bulletPrefab: {fileID: 0}
@@ -348,7 +348,7 @@ MonoBehaviour:
     keys:
     - attackType: 0
       startKeyName: attack_on
-      startKeyTime: 0.20000002
+      startKeyTime: 0
       endType: 1
       endKeyName: attack_off
       endKeyTime: 0.3
@@ -428,7 +428,7 @@ MonoBehaviour:
   cookEffect: {fileID: 0}
   Attack_summonShootCanTransmit: 0
   charactertag: 0
-  hitResistance: 0
+  hitResistance: 10
   bc: {fileID: 0}
   foot: {fileID: 2437299196663985756}
   attributeStatus: {fileID: 0}
@@ -505,6 +505,15 @@ MonoBehaviour:
   totalRevivesNum: 0
   revivesNum: 0
   revivesPos: {x: 0, y: 0}
+  attackHitResistance: 100
+  jumpForce: 30
+  jumpDir: {x: 0.5, y: 1, z: 0}
+  jumpHeight: 6
+  backDuration: {x: 1, y: 1.2}
+  stopDuration: 2
+  maxFlytime: {x: 3.5, y: 3.7}
+  runSpeedRate: 3
+  moveDir: {x: 0, y: 0, z: 0}
 --- !u!1 &2437299196663985757
 GameObject:
   m_ObjectHideFlags: 0
@@ -1606,11 +1615,18 @@ MonoBehaviour:
   owner: {fileID: 9191678810110905539}
   bulletObj: {fileID: 7473170563405908938, guid: a8d7788d84e74054e9bd5fc742e22241, type: 3}
   bulletNum: 3
-  angleRange: 45
+  angleRange: 60
   timeInterval: 0.2
+  backDuration: 0
+  stopDuration: 0
+  maxFlytime: 0
+  hasTarget: 0
+  targetPos: {x: 0, y: 0, z: 0}
   isOut: 0
   isReturning: 0
-  outBullet: {fileID: 0}
+  outBullet:
+  - {fileID: 0}
+  isFallDown: 0
 --- !u!1001 &4975682865987921505
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 2 - 0
ActionTowerDefense/Assets/Resources/Prefab/windmill_shuriken.prefab

@@ -650,8 +650,10 @@ MonoBehaviour:
   stopTime: 5
   backDuration: 1
   stopDuration: 2
+  extraFallGravity: 0
   BoomerangWeaponController: {fileID: 0}
   attackTrigger: {fileID: 4556949082052621437}
+  attackAni: {fileID: 4138066613278734704}
   isGetTarget: 0
   speed: 30
   maxFlyTime: 3.5

+ 40 - 3
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -32,9 +32,13 @@ public class Bullet : MonoBehaviour
     [ShowIf("@bulletType == BulletType.Boomerang")]
     [LabelText("停留时间")] public float stopDuration;
     [ShowIf("@bulletType == BulletType.Boomerang")]
+    [LabelText("坠落速度")] public float extraFallGravity;
+    [ShowIf("@bulletType == BulletType.Boomerang")]
     [DisplayOnly] public BoomerangWeaponController BoomerangWeaponController;
     [ShowIf("@bulletType == BulletType.Boomerang")]
-    public AttackTrigger attackTrigger;
+    public AttackTrigger attackTrigger;    
+    [ShowIf("@bulletType == BulletType.Boomerang")]
+    public Animator attackAni;    
     private Vector3 originalPos;
 
     public bool isGetTarget = false;
@@ -57,7 +61,7 @@ public class Bullet : MonoBehaviour
     [HideInInspector]
     public float transmitTime;          //传送CD
 
-    private bool isInVain;   //击中光球,攻击无效
+    private bool isInVain;   //攻击无效
 
     public UnityAction OnBulletHit;
 
@@ -94,6 +98,27 @@ public class Bullet : MonoBehaviour
         {
             return;
         }
+        if (bulletType == BulletType.Boomerang && BoomerangWeaponController.isFallDown)
+        {
+            Vector3 myPos = transform.position;
+            if(myPos.y < 0)
+            {
+                myPos.y = 0;
+                rb.useGravity = false;
+                rb.velocity = Vector3.zero;
+                transform.position = myPos;
+                attackAni.enabled = false;
+                attackTrigger.gameObject.SetActive(false);
+                isInVain = true;
+            }
+            else
+            {
+                Vector3 velocity = rb.velocity;
+                velocity.y += extraFallGravity * Time.deltaTime;
+                rb.velocity = velocity;
+            }
+            return;
+        }
         flyTime += Time.deltaTime;
         if (flyTime >= maxFlyTime)
         {
@@ -124,7 +149,14 @@ public class Bullet : MonoBehaviour
                 }
                 else
                 {
-                    rb.velocity = dir * speed * ( 1 - flyTime / backDuration);
+                    if(transform.position.y > 0.5f)
+                    {
+                        rb.velocity = dir * speed * (1 - flyTime / backDuration);
+                    }
+                    else
+                    {
+                        rb.velocity = Vector3.zero;
+                    }
                 }
                 
             }
@@ -180,6 +212,11 @@ public class Bullet : MonoBehaviour
             attackTrigger.attackMethod = attackMethod;
             attackTrigger.gameObject.SetActive(false);
         }
+        if (attackAni)
+        {
+            attackAni.enabled = true;
+        }
+        isInVain = false;
     }
 
     private void GetEffectPos(Collider other)

+ 5 - 3
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -395,9 +395,11 @@ public class AttributeStatus : MonoBehaviour
                         //Ñ£ÔÎ״̬
                         if (attributeTime <= 0)
                         {
-                            character.isAdjustHeight = 1;
-                            character.nowCanFly = character.canFly;
-
+                            if (character.canFly)
+                            {
+                                character.isAdjustHeight = 1;
+                                character.nowCanFly = character.canFly;
+                            }
                             OutSpecialState();
                         }
                         else

+ 2 - 5
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -229,12 +229,9 @@ public class Enemy : MoveCharacter
                     ChangeState(CharacterState.Rise);
                     break;
                 }
-                else if (isAttack)
+                else if (isAttack && pastAttackTime >= attackController.attackInterval)
                 {
-                    if (pastAttackTime >= attackController.attackInterval)
-                    {
-                        Attack_march();
-                    }
+                    Attack_march();
                 }
                 else
                 {

+ 62 - 12
ActionTowerDefense/Assets/Scripts/Skills/BoomerangWeaponController.cs

@@ -9,12 +9,19 @@ public class BoomerangWeaponController : SpecialSkills
     [LabelText("×Óµ¯ÊýÁ¿")] public int bulletNum;
     [LabelText("½Ç¶È")] public float angleRange;
     [LabelText("ʱ¼ä¼ä¸ô")] public float timeInterval;
-    
+    public float backDuration;
+    public float stopDuration;
+    public float maxFlytime;
+    public bool hasTarget;
+    public Vector3 targetPos;
+
     [DisplayOnly] public bool isOut;
     [DisplayOnly] public bool isReturning;
-    [DisplayOnly] public Bullet outBullet;
+    [DisplayOnly] public List<Bullet> outBullet;
     private float timer;
     private int outNum;
+    public bool isFallDown;
+    
     public void Awake()
     {
         Init();
@@ -23,6 +30,11 @@ public class BoomerangWeaponController : SpecialSkills
     {
         isReturning = false;
         isOut = false;
+        outBullet = new List<Bullet>();
+        for(int i = 0; i < bulletNum; i++)
+        {
+            outBullet.Add(null);
+        }
     }
     public override void Attack()
     {
@@ -35,9 +47,9 @@ public class BoomerangWeaponController : SpecialSkills
 
     private void Update()
     {
-        if(isOut)
+        if(isOut && !isFallDown)
         {
-            if (outNum >= bulletNum && !isReturning && !outBullet.gameObject.activeSelf)
+            if (outNum >= bulletNum && !isReturning && !outBullet[bulletNum - 1].gameObject.activeSelf)
             {
                 isReturning = true;
             }
@@ -46,7 +58,11 @@ public class BoomerangWeaponController : SpecialSkills
     }
     public void Shoot()
     {
-        if (outNum >= bulletNum) return;
+        if (outNum >= bulletNum)
+        {
+            return;
+        }
+        
         timer += Time.deltaTime;
         if(timer >= timeInterval)
         {
@@ -55,24 +71,58 @@ public class BoomerangWeaponController : SpecialSkills
             float angle;
             Bullet bullet = PoolManager.Instantiate(bulletObj).GetComponent<Bullet>();
             bullet.BoomerangWeaponController = this;
-
-            Vector3 dir;
-            if (owner.targetCharacter.beSearchTrigger.transform.position.x - transform.position.x > 0)
+            bullet.backDuration = backDuration;
+            bullet.stopDuration = stopDuration;
+            bullet.maxFlyTime = maxFlytime;
+            Vector3 dir = targetPos - transform.position;
+            float arrivalAngle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
+            if (dir.x > 0)
             {
-                angle = outNum * angleInterval;
+                if (hasTarget)
+                {
+                    angle = arrivalAngle - angleRange/2 + outNum * angleInterval;
+                }
+                else
+                {
+                    angle = outNum * angleInterval;
+                }
             }
             else
             {
-                angle = 180 - outNum * angleInterval;
+                if (hasTarget)
+                {
+                    angle = arrivalAngle - angleRange/2 + outNum * angleInterval;
+                }
+                else
+                {
+                    angle = 180 - outNum * angleInterval;
+                }
             }
             angle = angle / 180 * Mathf.PI;
             dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
             bullet.BeShoot(owner, transform.position, dir, true, target: owner.targetCharacter, attackMethod: owner.attackController.attackMethod_march[0]);
+            outBullet[outNum] = bullet;
             outNum++;
-            if (outNum >= bulletNum)
+        }
+    }
+
+    public int FindMinBullet()
+    {
+        int target = -1;
+        float minDis = 0;
+        for(int i = 0; i < bulletNum; i++)
+        {
+            Bullet bullet = outBullet[i];
+            if (bullet)
             {
-                outBullet = bullet;
+                float dis = Vector3.Distance(transform.position, bullet.transform.position);
+                if(target == -1 || dis< minDis)
+                {
+                    minDis = dis;
+                    target = i;
+                }
             }
         }
+        return target; 
     }
 }

+ 149 - 9
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Pinja.cs

@@ -11,9 +11,20 @@ public class ESpirits_Pinja : Enemy
     [ShowIf("canRevives")] [LabelText("复活次数")] public int totalRevivesNum;
     [ShowIf("canRevives")] public int revivesNum;
     [ShowIf("canRevives")] [LabelText("复活范围")] public Vector2 revivesPos;
+    [LabelText("攻击时抗击打值")] public int attackHitResistance;
+    [LabelText("跳跃的力")] public float jumpForce;
+    [LabelText("跳跃方向")] public Vector3 jumpDir;
+    [LabelText("跳跃高度")] public float jumpHeight;
+    [LabelText("回旋镖移动时间")] public Vector2 backDuration;
+    [LabelText("回旋镖停留时间")] public float stopDuration;
+    [LabelText("回旋镖最大飞行时间")] public Vector2 maxFlytime;
+    [LabelText("奔跑速度倍率")] public float runSpeedRate;
 
     private PlayerController player;
     private BoomerangWeaponController boomerangWeaponController;
+    private int originalHitResistance;
+    public Vector3 moveDir;
+    private int targetBullet;
     public override void Init()
     {
         base.Init();
@@ -29,12 +40,68 @@ public class ESpirits_Pinja : Enemy
         player = PlayersInput.instance[0];
         ChooseLockingTarget();
         boomerangWeaponController = attackController.attackMethod_march[0].skill as BoomerangWeaponController;
+        originalHitResistance = hitResistance;
     }
 
     public override void OnState()
     {
         switch (state)
         {
+            case CharacterState.Idle:
+                if (boomerangWeaponController.isFallDown)
+                {
+                    targetBullet = boomerangWeaponController.FindMinBullet();
+                    if(targetBullet == -1)
+                    {
+                        boomerangWeaponController.isOut = false;
+                        boomerangWeaponController.isReturning = true;
+                        boomerangWeaponController.isFallDown = false;
+                    }
+                    else
+                    {
+                        ChangeState(CharacterState.Run);
+                    }
+                    return;
+                }
+                if (boomerangWeaponController.isOut && !boomerangWeaponController.isReturning)
+                {
+                    if (rb.velocity.y < 0)
+                    {
+                        ChangeState(CharacterState.Fall);
+                    }
+                    return;
+                }
+                break;
+            case CharacterState.Run:
+                if (boomerangWeaponController.isFallDown)
+                {
+                    Bullet bullet = boomerangWeaponController.outBullet[targetBullet];
+                    float dirX = bullet.transform.position.x - transform.position.x;
+                    CheckTurn(dirX);
+                   
+                    if (dirX > 1)
+                    {
+                        rb.velocity = Vector3.right * moveSpeed * moveSpeedScale * runSpeedRate;
+                    }
+                    else if(dirX < -1)
+                    {
+                        rb.velocity = Vector3.left * moveSpeed * moveSpeedScale * runSpeedRate;
+                    }
+                    else
+                    {
+                        boomerangWeaponController.outBullet[targetBullet] = null;
+                        bullet.gameObject.SetActive(false);
+                        targetBullet = boomerangWeaponController.FindMinBullet();
+                        if (targetBullet == -1)
+                        {
+                            boomerangWeaponController.isOut = false;
+                            boomerangWeaponController.isReturning = true;
+                            boomerangWeaponController.isFallDown = false;
+                        }
+                    }
+                    return;
+                }
+                break;
             case CharacterState.Die:
                 if (GameManager.instance.gameType == GameType.GameEnd)
                 {
@@ -61,18 +128,25 @@ public class ESpirits_Pinja : Enemy
                 }
                 return;
             case CharacterState.Attack:
-                attackController.attackTime = 1;
                 ChooseLockingTarget();
-                if (boomerangWeaponController.isReturning && boomerangWeaponController.isOut)
+                break;
+            case CharacterState.Rise:
+                Vector3 velocity = jumpDir * jumpForce * moveSpeedScale;
+                if (bodyTrans.localScale.x < 0)
                 {
-                    boomerangWeaponController.Init();
-                    if (GetAttack())
-                    {
-                        isConAttack = true;
-                    }
-                    ChangeState(CharacterState.Idle);
-                    return;
+                    velocity.x = -velocity.x;
+                }
+                rb.velocity = velocity;
+                if (transform.position.y >= jumpHeight)
+                {
+                    boomerangWeaponController.targetPos = player.transform.position + Vector3.one;
+                    boomerangWeaponController.hasTarget = true;
+                    moveDir.x = -moveDir.x;
+                    base.Attack_march();
                 }
+                return;
+            case CharacterState.Fall:
+                moveDir = Vector3.zero;
                 break;
         }
         base.OnState();
@@ -83,14 +157,48 @@ public class ESpirits_Pinja : Enemy
         switch (state)
         {
             case CharacterState.Attack:
+                hitResistance = originalHitResistance;
+                rb.useGravity = true;
+                canNotShotDown = true;
                 ChooseLockingTarget();
                 break;
         }
         switch (newState)
         {
             case CharacterState.Attack:
+                hitResistance = attackHitResistance;
+                rb.useGravity = false;
+                rb.velocity = Vector3.zero;
                 ChooseLockingTarget();
                 break;
+            case CharacterState.Rise:
+                float dir = player.transform.position.x - transform.position.x;
+                if (dir < 0)
+                {
+                    if (bodyTrans.localScale.x < 0)
+                    {
+                        Turn();
+                    }
+                }
+                else
+                {
+                    if (bodyTrans.localScale.x > 0)
+                    {
+                        Turn();
+                    }
+                }
+                break;
+            case CharacterState.SpecialStatus_BlowUp:
+            case CharacterState.SpecialStatus_ShotDown:
+                boomerangWeaponController.isFallDown = true;
+                for(int i = 0; i < boomerangWeaponController.bulletNum; i++)
+                {
+                    if (boomerangWeaponController.outBullet[i])
+                    {
+                        boomerangWeaponController.outBullet[i].rb.useGravity = true;
+                    }
+                }
+                break;
         }
         base.ChangeState(newState);
     }
@@ -106,4 +214,36 @@ public class ESpirits_Pinja : Enemy
         targetCharacter = player;
     }
 
+    public override void Attack_march()
+    {
+        int randId = Random.Range(0, 2);
+        boomerangWeaponController.backDuration = backDuration[randId];
+        boomerangWeaponController.stopDuration = stopDuration;
+        boomerangWeaponController.maxFlytime = maxFlytime[randId];
+        switch (randId)
+        {
+            case 0:
+                boomerangWeaponController.hasTarget = false;
+                boomerangWeaponController.targetPos = player.transform.position + Vector3.one;
+                base.Attack_march();
+                break;
+            case 1:
+                moveDir.x = -moveDir.x;
+                canNotShotDown = false;
+                ChangeState(CharacterState.Rise);
+                Vector3 velocity = rb.velocity;
+                velocity.y = jumpForce;
+                rb.velocity = velocity;
+                break;
+        }
+    }
+
+    public override Vector3 GetMoveDir()
+    {
+        if(state == CharacterState.Fall)
+        {
+            return Vector3.zero;
+        }
+        return base.GetMoveDir();
+    }
 }