SZAND\msx_2 1 год назад
Родитель
Сommit
dec8211793

+ 50 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Cook.cs

@@ -0,0 +1,50 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Trans_Cook : MonoBehaviour
+{
+    public PlayerController controller;
+    public float changeTime;
+
+    public float intervalTime;              //攻击硬直
+    private float pastAttackTime;
+    private bool canAttack = true;
+
+    public GameObject bird;                 //扔出去的鸟儿
+    public float birdSpeed;                 //鸟儿攻击速度
+
+    private void Start()
+    {
+        controller = GetComponentInParent<PlayerController>();
+        controller.changeTime = changeTime;
+    }
+
+    private void Update()
+    {
+        if (!canAttack)
+        {
+            pastAttackTime += Time.deltaTime;
+            if (pastAttackTime >= intervalTime)
+            {
+                canAttack = true;
+                pastAttackTime = 0;
+            }
+        }
+        if (controller.isinputJ && canAttack)
+        {
+            canAttack = false;
+            controller.isinputJ = false;
+            float dir = controller.bodyTrans.localScale.x;
+            bird.transform.position -= new Vector3(dir * birdSpeed, 0, 0);
+        }
+        if (controller.isinputK)
+        {
+            controller.isinputK = false;
+        }
+        if (controller.isinputL)
+        {
+            controller.isinputL = false;
+        }
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Cook.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5adf6402dec23ec4e971c72cea57ab65
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: