123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- using UnityEngine;
- using System.Collections;
- using System;
- public class Tutor : MonoBehaviour
- {
- private bool InfinitelyTraining
- {
- get
- {
- return GameObject.Find("InfinitelyTraining");
- }
- }
- private static Tutor _instance;
- public GameObject ArrowDown;
- public GameObject ArrowLeft;
- public GameObject ArrowRight;
- public GameObject ArrowUp;
- public GameObject ImageInfo;
- public GameObject ObjKillAnOrc;
- public GameObject ObjBreakTheChest;
- public GameObject ObjEnrage;
- public GameObject Colliders;
- private bool _tutorPassed = false;
- public static bool TutorPassed
- {
- get { return _instance._tutorPassed && !_instance.InfinitelyTraining; }
- }
- void Start ()
- {
- _tutorPassed = PlayerPrefs.GetInt("TutorPassed", 0) == 1;
- _instance = this;
- ArrowDown.SetActive(false);
- ArrowLeft.SetActive(false);
- ArrowRight.SetActive(false);
- ArrowUp.SetActive(false);
- // ObjKillAnOrc.SetActive(false);
- // ObjBreakTheChest.SetActive(false);
- //ObjEnrage.SetActive(false);
- }
- public static void ActivateColliders()
- {
- if (_instance && _instance.Colliders)
- {
- _instance.Colliders.SetActive(true);
- }
- }
- public static void Down()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Show(_instance.ArrowDown, new Vector3(0, -1, 0), 10));
- }
- public static void Left()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Show(_instance.ArrowLeft, new Vector3(-1, 0, 0), 10));
- }
- public static void Info()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Show(_instance.ImageInfo, new Vector3(0, 1, 0), 1));
- }
-
- public static void Right()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Show(_instance.ArrowRight, new Vector3(1, 0, 0), 10));
- }
- public static void Up()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Show(_instance.ArrowUp, new Vector3(0, 1, 0), 10));
- }
- public static void BreakChest()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Scale(_instance.ObjBreakTheChest, new Vector3(0.0001f, 0.0001f, 0), 50));
- }
- public static void KillAnOrc()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Scale(_instance.ObjKillAnOrc, new Vector3(0.0001f, 0.0001f, 0), 50));
- }
- public static void Enrage()
- {
- if (_instance._tutorPassed && !_instance.InfinitelyTraining)
- {
- return;
- }
- _instance.StartCoroutine(_instance.Scale(_instance.ObjEnrage, new Vector3(0.0001f, 0.0001f, 0), 50));
- }
- private IEnumerator Show(GameObject obj, Vector3 way, float dist)
- {
-
- if (obj.name == "TutorDone")
- {
- Debug.Log("TutorDone");
- LoginManager.Instance.TutorDone.gameObject.SetActive(true);
- yield return new WaitForSeconds(3.14f);
- LoginManager.Instance.TutorDone.gameObject.SetActive(false);
- yield break;
- }
- obj.transform.localPosition = way * 3 * -dist;
- obj.SetActive(true);
- var move = 0;
- while (move++ < dist)
- {
- yield return new WaitForSeconds(0.02f);
- obj.transform.localPosition += way * 3 * move;
- }
- if (obj.name == "TutorDone")
- {
- LoginManager.Instance.TutorDone.gameObject.SetActive(false);
- //LoginManager.Instance.TutorDone.Hide();
- }
- obj.SetActive(false);
- }
- private IEnumerator Scale(GameObject obj, Vector3 way, float dist)
- {
- Vector3 baseScale = obj.transform.localScale;
- obj.SetActive(true);
- var move = 0;
- while (move++ < dist)
- {
- yield return new WaitForSeconds(0.03f);
- obj.transform.localScale += way;
- }
- obj.SetActive(false);
- obj.transform.localScale = baseScale;
- }
- public static void Passed()
- {
- _instance._tutorPassed = true;
- PlayerPrefs.SetInt("TutorPassed", 1);
- PlayerPrefs.Save();
- }
- }
|