|
@@ -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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|