1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TutorialIndicator : MonoBehaviour
- {
- public bool swipe;
- float speed = 0.25f;
- Image image;
- // Use this for initialization
- void Start()
- {
- image = GetComponent<Image>();
- }
- public void Swipe()
- {
- gameObject.SetActive(true);
- swipe = true;
- transform.position = new Vector3(Screen.width * 0.7f, Screen.height * 0.7f, 5);
- }
- // Update is called once per frame
- void Update()
- {
- if (!swipe)
- {
- //print(transform.position);
- transform.localScale = Vector3.one * (1 + Mathf.Sin(Time.time * 2) * 0.15f);
- }
- else
- {
- //float speed = 0.25f;
- if (image.enabled)
- {
- transform.position += Vector3.left * Time.deltaTime * (Screen.width * speed);
- speed += Time.deltaTime * 0.75f;
- if (transform.position.x < Screen.width * 0.3f)
- {
- image.enabled = false;
- StartCoroutine(ResetHand());
- }
- }
- }
- }
- private IEnumerator ResetHand()
- {
- yield return new WaitForSeconds(0.5f);
- image.enabled = true;
- transform.position = new Vector3(Screen.width * 0.7f,
- Screen.height * 0.7f, 5);
- speed = 0.15f;
- }
- public void Stop()
- {
- swipe = false;
- gameObject.SetActive(false);
- }
- }
|