ソースを参照

吃完烤串变大

SZAND\msx_2 1 年間 前
コミット
4475dc1195

+ 2 - 1
ActionTowerDefense/Assets/Resources/Prefab/Spirits_Cook.prefab

@@ -217,10 +217,11 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   text: {fileID: 979388067414062712}
+  chuan: 10
   value: 20
   effect: {fileID: 417478504669294145, guid: 07c7a53ff610e0b45898f0f09276d995, type: 3}
   activeAniTime: 3.3
-  chuan: 10
+  larger: 1.2
 --- !u!1 &3483054690158852324
 GameObject:
   m_ObjectHideFlags: 0

+ 19 - 2
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -87,6 +87,9 @@ public class Character : MonoBehaviour
 
     public bool hasHpUp = false;
 
+    private float toLargeSize = 0;
+    private Vector3 speed = new Vector3(1, 1, 0);
+    public bool beLarger = false;
 
     public virtual void Init()
     {
@@ -188,7 +191,7 @@ public class Character : MonoBehaviour
         {
             attackDir.x = -attackDir.x;
         }
-        bullet.BeShoot(this, shootPos[shootId].position, attackDir, attackInfo.damage, attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, shootTrack, attackTarget?attackTarget:null);
+        bullet.BeShoot(this, shootPos[shootId].position, attackDir, attackInfo.damage, attackInfo.force, attackInfo.changeHurt, attackInfo.repelValue, shootTrack, attackTarget ? attackTarget : null);
     }
 
     public virtual Vector3 GetMoveDir()
@@ -298,7 +301,7 @@ public class Character : MonoBehaviour
         meshRenderer.sortingOrder = order;
     }
 
-    public void HpUp(float value)
+    public void HpUp(float value, float larger)
     {
         int add = 0;
         switch (hptp)
@@ -317,5 +320,19 @@ public class Character : MonoBehaviour
         totalHp += add;
         hp += add;
         uiHp.Show(hp, totalHp);
+        float cur = transform.localScale.x;
+        toLargeSize = cur * larger;
+        beLarger = true;
+    }
+
+    public void Enlarge()
+    {
+        transform.localScale = Vector3.SmoothDamp(transform.localScale, new Vector3(1, 1, 1) * toLargeSize, ref speed, 0.3f);
+        if (transform.localScale.x >= toLargeSize + 0.1f)
+        {
+            beLarger = false;
+            transform.localScale = new Vector3(toLargeSize, toLargeSize, 1);
+            toLargeSize = 0;
+        }
     }
 }

+ 4 - 0
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -101,6 +101,10 @@ public class MoveCharacter : Character
 
     private void Update()
     {
+        if (!beLarger)
+        {
+            Enlarge();
+        }
         //print(maxTime);
         if (floatState == 1)
         {

+ 25 - 17
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs

@@ -6,22 +6,30 @@ using System;
 
 public class Spirits_Cook : MonoBehaviour
 {
-    public TextMeshProUGUI text;
-    private GameObject dia;
-    private Transform cook;
-    public float value;
-    public GameObject effect;
-    private Animator ani;
-    private Demonic dem;
-    private bool once = false;
-    private Collider col;
-    private float activeTime;
-    public float activeAniTime;
-    private bool isAct = false;
-    public int chuan;
-    private bool goAway = false;
-    private GameObject[] customers;
-    private int count;
+    public TextMeshProUGUI text;    //剩余串的数量文本
+    private GameObject dia;         //文本框
+
+    private Transform cook;         //厨子
+    private Animator ani;           //厨子动画
+    private Collider col;           //厨子的碰撞体
+    public int chuan;               //厨子拥有多少串
+
+    public float value;             //加血程度百分比
+    public GameObject effect;       //加血效果
+
+    private Demonic dem;            //厨子的demonic脚本
+
+    private bool once = false;      //死一次
+    private bool goAway = false;    //厨子命尽
+
+    private float activeTime;       //厨子已出现的时长
+    public float activeAniTime;     //厨子出现动画的时长
+    private bool isAct = false;     //厨子已经完整出现
+
+    private GameObject[] customers; //厨子的所有顾客
+    private int count;              //顾客数量
+
+    public float larger;            //顾客变大的程度
 
     private void OnEnable()
     {
@@ -46,7 +54,7 @@ public class Spirits_Cook : MonoBehaviour
                 chuan -= 1;
                 text.text = chuan.ToString();
                 ani.Play("attack_march", 0, 0);
-                ca.HpUp(value);
+                ca.HpUp(value, larger);
                 customers[count] = ga;
                 count += 1;
                 Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform);