HeavenStudioPlus/Assets/Scripts/CircleCursor.cs

65 lines
2.2 KiB
C#
Raw Normal View History

2021-12-19 04:10:43 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
2021-12-19 04:10:43 +00:00
namespace RhythmHeavenMania
{
public class CircleCursor : MonoBehaviour
2021-12-19 04:10:43 +00:00
{
[SerializeField] private bool follow = false;
[SerializeField] private float mouseMoveSpeed;
2021-12-19 04:10:43 +00:00
[Header("DSGuy")]
[SerializeField] private GameObject Eyes;
[SerializeField] private GameObject OuterCircle;
[SerializeField] private GameObject InnerCircle;
[SerializeField] private GameObject Circle;
private Tween outerCircleTween, eyesTween;
2021-12-19 04:10:43 +00:00
private void Start()
2021-12-19 04:10:43 +00:00
{
Cursor.visible = false;
2021-12-19 04:10:43 +00:00
}
private void Update()
2021-12-19 04:10:43 +00:00
{
Vector3 pos = GameManager.instance.CursorCam.ScreenToWorldPoint(Input.mousePosition);
if (follow)
{
Vector2 direction = (pos - transform.position).normalized;
this.GetComponent<Rigidbody2D>().velocity = new Vector2(direction.x * mouseMoveSpeed, direction.y * mouseMoveSpeed);
}
else
{
this.gameObject.transform.position = new Vector3(pos.x, pos.y, 0);
if (PlayerInput.Pressed())
{
2021-12-25 06:22:09 +00:00
Cursor.visible = false;
Circle.transform.DOScale(0, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(true);
outerCircleTween.Kill();
outerCircleTween = OuterCircle.transform.DOScale(1, 0.15f).SetEase(Ease.OutExpo);
Eyes.SetActive(true);
eyesTween.Kill();
eyesTween = Eyes.transform.DOLocalMoveY(0.15f, 0.15f).SetEase(Ease.OutExpo);
}
else if (PlayerInput.PressedUp())
{
Circle.transform.DOScale(0.2f, 0.5f).SetEase(Ease.OutExpo);
InnerCircle.SetActive(false);
outerCircleTween.Kill();
outerCircleTween = OuterCircle.transform.DOScale(0, 0.15f);
eyesTween.Kill();
eyesTween = Eyes.transform.DOLocalMoveY(-0.66f, 0.15f).OnComplete(delegate { Eyes.SetActive(false); });
}
}
2021-12-19 04:10:43 +00:00
}
}
}