|
|
@@ -5,30 +5,33 @@ using UnityEngine;
|
|
|
public class Trans_Cook : MonoBehaviour
|
|
|
{
|
|
|
public PlayerController controller;
|
|
|
+ private GameObject player;
|
|
|
public float changeTime;
|
|
|
public Vector3 UIoffset; //UI调整值
|
|
|
|
|
|
private Demonic dem;
|
|
|
- private Rigidbody demRB;
|
|
|
+ private int dir;
|
|
|
|
|
|
[Header("J技能:撒辣椒粉")]
|
|
|
public GameObject bottle;
|
|
|
public float intervalTime; //攻击硬直
|
|
|
private float pastAttackTime;
|
|
|
private bool canAttack = true;
|
|
|
- private Rigidbody rb;
|
|
|
- public Vector3 throwForce; //抛出辣椒粉调料瓶的力
|
|
|
+ public Vector3 throwForceUp; //抛出辣椒粉调料瓶的向上的力
|
|
|
public GameObject throwPos;
|
|
|
private GameObject curBottle;
|
|
|
+ private bool isThrow = false;
|
|
|
+ public float speed;
|
|
|
+ public float maxDis; //调料瓶最远距离
|
|
|
|
|
|
private void Start()
|
|
|
{
|
|
|
controller = GetComponentInParent<PlayerController>();
|
|
|
+ player = controller.gameObject;
|
|
|
controller.changeTime = changeTime;
|
|
|
controller.uiHp.transform.position += UIoffset;
|
|
|
controller.uiMp.transform.position += UIoffset;
|
|
|
dem = GetComponent<Demonic>();
|
|
|
- demRB = dem.GetComponentInParent<Rigidbody>();
|
|
|
}
|
|
|
|
|
|
private void OnDisable()
|
|
|
@@ -37,12 +40,29 @@ public class Trans_Cook : MonoBehaviour
|
|
|
controller.uiMp.transform.position -= UIoffset;
|
|
|
}
|
|
|
|
|
|
- private void SprinklePaprika() //J技能:撒辣椒粉
|
|
|
+ private void ThrowBottle() //J技能:撒辣椒粉
|
|
|
{
|
|
|
curBottle = Instantiate(bottle, throwPos.transform.position, new Quaternion(0, 0, 0, 0), null);
|
|
|
- rb = curBottle.GetComponent<Rigidbody>();
|
|
|
- rb.velocity = throwForce;
|
|
|
- rb.AddForce(Vector3.up);
|
|
|
+ curBottle.GetComponent<Rigidbody>().velocity = throwForceUp;
|
|
|
+ if (player.transform.localScale.x > 0)
|
|
|
+ {
|
|
|
+ dir = -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dir = 1;
|
|
|
+ }
|
|
|
+ isThrow = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BottleMove()
|
|
|
+ {
|
|
|
+ curBottle.transform.position += new Vector3(dir * speed * Time.deltaTime, 0, 0);
|
|
|
+ if (dir == 1 && curBottle.transform.position.x >= maxDis || dir == -1 && curBottle.transform.position.x <= -maxDis)
|
|
|
+ {
|
|
|
+ curBottle.SetActive(false);
|
|
|
+ isThrow = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void Update()
|
|
|
@@ -60,7 +80,7 @@ public class Trans_Cook : MonoBehaviour
|
|
|
{
|
|
|
canAttack = false;
|
|
|
controller.isinputJ = false;
|
|
|
- SprinklePaprika();
|
|
|
+ ThrowBottle();
|
|
|
|
|
|
}
|
|
|
if (controller.isinputK)
|
|
|
@@ -71,5 +91,9 @@ public class Trans_Cook : MonoBehaviour
|
|
|
{
|
|
|
controller.isinputL = false;
|
|
|
}
|
|
|
+ if (isThrow)
|
|
|
+ {
|
|
|
+ BottleMove();
|
|
|
+ }
|
|
|
}
|
|
|
}
|