|
|
@@ -14,6 +14,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
stay, //停在目标点
|
|
|
back, //收回
|
|
|
disappear, //消失前原地动画
|
|
|
+ flyAway,
|
|
|
}
|
|
|
|
|
|
[DisplayOnly]
|
|
|
@@ -28,6 +29,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
WaterSprite ws;
|
|
|
|
|
|
public Animator ani;
|
|
|
+ public RuntimeAnimatorController rac;
|
|
|
private WaterSpriteAttackController attackCon;
|
|
|
|
|
|
//玩家
|
|
|
@@ -52,9 +54,9 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
public float stayTime;
|
|
|
[LabelText("黑伞冲刺前提示时长")]
|
|
|
public float attentionyTime;
|
|
|
- //[LabelText("黑伞收回时长")]
|
|
|
- //public float backTime;
|
|
|
- //private bool hasBackAni;
|
|
|
+ [LabelText("黑伞收回时长")]
|
|
|
+ public float backTime;
|
|
|
+ private bool hasBackAni;
|
|
|
[LabelText("黑伞消失时长")]
|
|
|
public float disappearTime;
|
|
|
[LabelText("黑伞位置提示特效")]
|
|
|
@@ -70,7 +72,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
public UnityAction OnBack;
|
|
|
|
|
|
public float leftBoundary, rightBoundary;
|
|
|
- public float minimumHeight = 4f;
|
|
|
+ public float maxHeight;
|
|
|
|
|
|
private void Start()
|
|
|
{
|
|
|
@@ -78,6 +80,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
GetComponentInChildren<AttackTrigger>().owner = ws;
|
|
|
attackCon = owner.GetComponent<WaterSpriteAttackController>();
|
|
|
pc = PlayersInput.instance[0];
|
|
|
+ ani.runtimeAnimatorController = rac;
|
|
|
}
|
|
|
|
|
|
//放出这个攻击!
|
|
|
@@ -94,6 +97,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ if(umbrellaState == UmbrellaState.stay) ani.Play("idle");
|
|
|
umbrellaState = us;
|
|
|
switch (us)
|
|
|
{
|
|
|
@@ -104,52 +108,46 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
case UmbrellaState.sprint:
|
|
|
origPos = transform.position;
|
|
|
aimPos = pc.transform.position;
|
|
|
- if (isFirst && aimPos.x < transform.position.x)
|
|
|
+ if (isFirst)
|
|
|
{
|
|
|
- aimPos = transform.position + new Vector3(1, 0, 0) * farFromPlayerDis;
|
|
|
- attackDis = farFromPlayerDis;
|
|
|
+ aimPos = new Vector3(rightBoundary,transform.position.y,transform.position.z);
|
|
|
+ attackDis = rightBoundary - transform.position.y;
|
|
|
isFirst = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
aimPos.y = origPos.y;
|
|
|
- int fx = 1;
|
|
|
- if (aimPos.x < origPos.x)
|
|
|
+ if (transform.position.x > leftBoundary)
|
|
|
{
|
|
|
- fx = -1;
|
|
|
+ aimPos.x = leftBoundary;
|
|
|
}
|
|
|
- string dir = fx > 0 ? "右边" : "左边";
|
|
|
- Debug.Log("攻击方向为" + dir);
|
|
|
- aimPos.x += farFromPlayerDis * fx;
|
|
|
+ else aimPos.x = rightBoundary;
|
|
|
attackDis = Mathf.Abs(aimPos.x - transform.position.x);
|
|
|
}
|
|
|
- if (aimPos.x > rightBoundary)
|
|
|
- {
|
|
|
- aimPos.x = rightBoundary;
|
|
|
- }
|
|
|
- else if (aimPos.x < leftBoundary)
|
|
|
- {
|
|
|
- aimPos.x = leftBoundary;
|
|
|
- }
|
|
|
break;
|
|
|
case UmbrellaState.stay:
|
|
|
aimPos.y = pc.bodyTrans.position.y;
|
|
|
allTime--;
|
|
|
- if (allTime < 0)
|
|
|
- {
|
|
|
- ChangeUmbrellaState(UmbrellaState.back);
|
|
|
- }
|
|
|
+ if (transform.position.x < rightBoundary) transform.localScale = new Vector3(1, 1, 1);
|
|
|
+ else transform.localScale = new Vector3(-1, 1, 1);
|
|
|
+ if (allTime >= 0) ani.Play("attack_start");
|
|
|
break;
|
|
|
case UmbrellaState.back:
|
|
|
OnBack?.Invoke();
|
|
|
- if(transform.position.y < 4)
|
|
|
- {
|
|
|
- origPos = transform.position;
|
|
|
- aimPos = new Vector3(transform.position.x, 4, transform.position.z);
|
|
|
- }
|
|
|
+ //if(transform.position.y < 4)
|
|
|
+ //{
|
|
|
+ // origPos = transform.position;
|
|
|
+ // aimPos = new Vector3(transform.position.x, 4, transform.position.z);
|
|
|
+ //}
|
|
|
+ umbrePastTime = 0f;
|
|
|
break;
|
|
|
case UmbrellaState.disappear:
|
|
|
break;
|
|
|
+ case UmbrellaState.flyAway:
|
|
|
+ umbrePastTime = 0;
|
|
|
+ origPos = transform.position;
|
|
|
+ aimPos = new Vector3(transform.position.x, maxHeight, transform.position.z);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -178,7 +176,11 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
}
|
|
|
break;
|
|
|
case UmbrellaState.stay:
|
|
|
- if (umbrePastTime > stayTime + attentionyTime)
|
|
|
+ if (allTime < 0)
|
|
|
+ {
|
|
|
+ if(ws.state == CharacterState.Idle) ChangeUmbrellaState(UmbrellaState.back);
|
|
|
+ }
|
|
|
+ else if (umbrePastTime > stayTime + attentionyTime)
|
|
|
{
|
|
|
umbrePastTime = 0;
|
|
|
ChangeUmbrellaState(UmbrellaState.sprint);
|
|
|
@@ -190,30 +192,30 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
}
|
|
|
break;
|
|
|
case UmbrellaState.back:
|
|
|
- //float t2 = Mathf.Clamp01(umbrePastTime / backTime);
|
|
|
- //float smoothT2 = Mathf.SmoothStep(0, 1, t2);
|
|
|
- //transform.position = Vector3.Lerp(aimPos, umbrellaBackPos.position, smoothT2);
|
|
|
- //if (umbrePastTime >= backTime)
|
|
|
- //{
|
|
|
- // umbrePastTime = 0;
|
|
|
- // hasBackAni = false;
|
|
|
- // ws.isHoldingUmbre = true;
|
|
|
- // ChangeUmbrellaState(UmbrellaState.disappear);
|
|
|
- //}
|
|
|
- //else if (!hasBackAni && umbrePastTime >= backTime - 0.6f)
|
|
|
- //{
|
|
|
- // hasBackAni = true;
|
|
|
- // attackCon.isUmbrellaBack = true;
|
|
|
- // ws.isHoldingUmbre = true;
|
|
|
- //}
|
|
|
- if(transform.position.y < 4)
|
|
|
+ float t2 = Mathf.Clamp01(umbrePastTime / backTime);
|
|
|
+ float smoothT2 = Mathf.SmoothStep(0, 1, t2);
|
|
|
+ transform.position = Vector3.Lerp(transform.position, umbrellaBackPos.position, smoothT2);
|
|
|
+ if (umbrePastTime >= backTime)
|
|
|
{
|
|
|
- //Debug.Log(umbrePastTime);
|
|
|
- float distanceCovered1 = umbrePastTime * initialSpeed;
|
|
|
- float fraction1 = distanceCovered1 / (4-transform.position.y);
|
|
|
- float dec1 = 1 - (1 - fraction1) * (1 - fraction1);
|
|
|
- transform.position = Vector3.Lerp(origPos, aimPos, umbrePastTime);
|
|
|
+ umbrePastTime = 0;
|
|
|
+ hasBackAni = false;
|
|
|
+ ws.isHoldingUmbre = true;
|
|
|
+ ChangeUmbrellaState(UmbrellaState.disappear);
|
|
|
}
|
|
|
+ else if (!hasBackAni && umbrePastTime >= backTime - 0.6f)
|
|
|
+ {
|
|
|
+ hasBackAni = true;
|
|
|
+ attackCon.isUmbrellaBack = true;
|
|
|
+ ws.isHoldingUmbre = true;
|
|
|
+ }
|
|
|
+ //if(transform.position.y < 4)
|
|
|
+ //{
|
|
|
+ // //Debug.Log(umbrePastTime);
|
|
|
+ // float distanceCovered1 = umbrePastTime * initialSpeed;
|
|
|
+ // float fraction1 = distanceCovered1 / (4-transform.position.y);
|
|
|
+ // float dec1 = 1 - (1 - fraction1) * (1 - fraction1);
|
|
|
+ // transform.position = Vector3.Lerp(origPos, aimPos, umbrePastTime);
|
|
|
+ //}
|
|
|
break;
|
|
|
case UmbrellaState.disappear:
|
|
|
if (umbrePastTime >= disappearTime)
|
|
|
@@ -223,22 +225,17 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
gameObject.SetActive(false);
|
|
|
}
|
|
|
break;
|
|
|
+ case UmbrellaState.flyAway:
|
|
|
+ transform.position = Vector3.Lerp(origPos, aimPos, umbrePastTime);
|
|
|
+ if(Vector3.Distance(transform.position,aimPos) < 1)
|
|
|
+ {
|
|
|
+ gameObject.SetActive(false);
|
|
|
+ ws.isHoldingUmbre = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void BeTaken()
|
|
|
- {
|
|
|
- StartCoroutine(Disappear());
|
|
|
- }
|
|
|
-
|
|
|
- IEnumerator Disappear()
|
|
|
- {
|
|
|
- yield return new WaitForSeconds(0.6f);
|
|
|
- umbrePastTime = 0;
|
|
|
- attackCon.isUmbrellaBack = true;
|
|
|
- ws.isHoldingUmbre = true;
|
|
|
- ChangeUmbrellaState(UmbrellaState.disappear);
|
|
|
- }
|
|
|
private bool IsTargetVisible(GameObject target)
|
|
|
{
|
|
|
Camera camera = Camera.main;
|
|
|
@@ -272,10 +269,9 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
// && (stayTime - umbrePastTime) <= 1f;
|
|
|
|
|
|
bool isAboutToAttack = umbrellaState == UmbrellaState.stay
|
|
|
- && allTime > -1
|
|
|
&& (umbrePastTime - stayTime)> 0;
|
|
|
|
|
|
- if (!IsTargetVisible(gameObject) && umbrellaState == UmbrellaState.stay)
|
|
|
+ if (!IsTargetVisible(gameObject) && umbrellaState == UmbrellaState.stay && allTime > -1)
|
|
|
{
|
|
|
if (isAboutToAttack)
|
|
|
{
|
|
|
@@ -332,14 +328,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
|
|
|
public void BeCleared()
|
|
|
{
|
|
|
- ani.Play("disapear", 0, 0);
|
|
|
- StartCoroutine(ClearDelay());
|
|
|
- }
|
|
|
-
|
|
|
- IEnumerator ClearDelay()
|
|
|
- {
|
|
|
- yield return new WaitForSeconds(2f);
|
|
|
- gameObject.SetActive(false);
|
|
|
+ ChangeUmbrellaState(UmbrellaState.flyAway);
|
|
|
}
|
|
|
|
|
|
private void Update()
|