2024-11-27 17:58:30 +08:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class snailRider : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Image palye;
|
|
|
|
|
public GameObject obj;
|
|
|
|
|
public List<Sprite> LightSprite;
|
|
|
|
|
public GameObject startingPoint;
|
|
|
|
|
public GameObject end;
|
|
|
|
|
public bool is_victory = false;//<2F><>ֻ<EFBFBD><D6BB>ţ<EFBFBD>Ƿ<EFBFBD><C7B7>ڱ<EFBFBD><DAB1>غϱ<D8BA><CFB1><EFBFBD>ʤ<EFBFBD><CAA4>
|
|
|
|
|
public bool is_die = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>û
|
|
|
|
|
float offset = 0;
|
2024-12-02 12:01:20 +08:00
|
|
|
|
public Animator animator;
|
|
|
|
|
|
2024-11-28 07:16:11 +08:00
|
|
|
|
public Sequence mySequence = DOTween.Sequence();
|
2024-11-27 17:58:30 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
async void Start()
|
|
|
|
|
{
|
2024-11-28 01:09:32 +08:00
|
|
|
|
//startMove();
|
2024-11-27 17:58:30 +08:00
|
|
|
|
|
2024-12-02 12:01:20 +08:00
|
|
|
|
//while (true)
|
|
|
|
|
//{
|
|
|
|
|
// if (LightSprite == null) return;
|
|
|
|
|
// foreach (Sprite sprite in LightSprite)
|
|
|
|
|
// {
|
|
|
|
|
// if (palye != null)
|
|
|
|
|
// {
|
|
|
|
|
// palye.sprite = sprite;
|
|
|
|
|
// await Task.Delay(50);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
LightSprite = null;
|
|
|
|
|
}
|
2024-11-28 07:16:11 +08:00
|
|
|
|
|
2024-12-02 12:01:20 +08:00
|
|
|
|
public void MoveOrStand()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-28 07:16:11 +08:00
|
|
|
|
public void killsnail()
|
2024-11-27 17:58:30 +08:00
|
|
|
|
{
|
2024-11-27 18:53:41 +08:00
|
|
|
|
obj.SetActive(!is_die);
|
2024-11-28 07:16:11 +08:00
|
|
|
|
}
|
|
|
|
|
public void startMove()
|
|
|
|
|
{
|
|
|
|
|
|
2024-11-27 18:53:41 +08:00
|
|
|
|
//palye.enabled = !is_die;
|
2024-11-27 17:58:30 +08:00
|
|
|
|
if (!is_die)
|
|
|
|
|
{
|
2024-12-02 12:01:20 +08:00
|
|
|
|
animator.SetInteger("State",1);//<2F>л<EFBFBD>Ϊ<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
|
2024-12-05 15:48:55 +08:00
|
|
|
|
int suiji = 0;
|
2024-11-27 17:58:30 +08:00
|
|
|
|
if (is_victory)
|
|
|
|
|
{
|
2024-12-05 15:48:55 +08:00
|
|
|
|
suiji = UnityEngine.Random.Range(-2, -1);
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-12-05 15:48:55 +08:00
|
|
|
|
suiji = UnityEngine.Random.Range(4, 6);
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
2024-11-29 18:06:13 +08:00
|
|
|
|
|
2024-12-02 12:01:20 +08:00
|
|
|
|
mySequence.Append(transform.DOMoveX(startingPoint.transform.position.x, 0.01f))
|
2024-12-05 15:48:55 +08:00
|
|
|
|
.Append(transform.DOMoveX(end.transform.position.x, 5f + suiji)).SetEase(Ease.Linear).OnComplete(()=> {
|
2024-12-02 12:01:20 +08:00
|
|
|
|
animator.SetInteger("State", 0);
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>л<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}) //<2F>л<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
;
|
2024-11-29 18:06:13 +08:00
|
|
|
|
mySequence.OnKill(()=> { AllManeger.instance.snailMoveNum++; });
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-28 03:35:20 +08:00
|
|
|
|
|
|
|
|
|
public void returnStart()
|
|
|
|
|
{
|
2024-12-02 12:01:20 +08:00
|
|
|
|
//Debug.Log(transform.name);
|
|
|
|
|
//Debug.Log(transform.position);
|
2024-11-28 07:16:11 +08:00
|
|
|
|
mySequence.Kill(); // ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>
|
2024-11-28 03:35:20 +08:00
|
|
|
|
transform.position=startingPoint.transform.position;
|
2024-12-02 12:01:20 +08:00
|
|
|
|
animator.SetInteger("State", 0);
|
|
|
|
|
//Debug.Log(startingPoint.transform.position);
|
|
|
|
|
|
|
|
|
|
//Debug.Log(transform.position);
|
2024-11-28 03:35:20 +08:00
|
|
|
|
}
|
2024-11-27 17:58:30 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
offset = Mathf.Lerp(offset, 0, 1f * Time.deltaTime);
|
|
|
|
|
obj.transform.localPosition = Vector3.Lerp(obj.transform.localPosition, new Vector3(offset, 0, 0), 1f * Time.deltaTime);
|
|
|
|
|
}
|
|
|
|
|
async void OnTriggerEnter2D(Collider2D other)
|
|
|
|
|
{
|
2024-12-02 16:30:36 +08:00
|
|
|
|
|
|
|
|
|
if (other.gameObject.GetComponent<snailRiderItem>()!=null)
|
2024-11-27 17:58:30 +08:00
|
|
|
|
{
|
2024-12-02 16:30:36 +08:00
|
|
|
|
if (other.gameObject.GetComponent<snailRiderItem>().mode == snailRiderItem.Mode.accelerate)
|
|
|
|
|
{
|
|
|
|
|
offset = 500;
|
|
|
|
|
}
|
|
|
|
|
else if (other.gameObject.GetComponent<snailRiderItem>().mode == snailRiderItem.Mode.slowDown)
|
|
|
|
|
{
|
|
|
|
|
offset = -500;
|
|
|
|
|
}
|
|
|
|
|
Destroy(other.gameObject);
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
2024-12-02 16:30:36 +08:00
|
|
|
|
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD>
|
2024-11-27 17:58:30 +08:00
|
|
|
|
{
|
2024-12-02 16:30:36 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD>");
|
|
|
|
|
animator.SetInteger("State", 0);
|
2024-11-27 17:58:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|