123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- [Serializable]
- public class TriggerRollerActive : MonoBehaviour
- {
- [SerializeField]
- public List<RollerController> Rollers;
- public Camera MainCamera;
- private void Start()
- {
- MainCamera = Camera.main;
- Rollers[_curIndex].gameObject.SetActive(true);
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.tag == "Player")
- {
- var rController = Rollers[_curIndex];
- other.GetComponent<RunnersController>().SetRollerAnim();
- StartCoroutine(SitTrolleyAnim(rController, other));
-
- //Invoke("ActiveController", 1);
- }
- }
- private IEnumerator SitTrolleyAnim(RollerController rController, Collider other)
- {
- yield return new WaitForSeconds(1);
- other.gameObject.SetActive(false);
- NotificationCenter.Post(NotificationType.RollerActive, other.gameObject);
- if (other.gameObject == Core.Instance._player.name.Contains(other.name))
- {
- MainCamera.transform.SetParent(Rollers[_curIndex].TrCamera);
- MainCamera.GetComponent<CompleteCameraController>().enabled = false;
- MainCamera.transform.DOLookAt(Rollers[_curIndex].Roller.transform.position, 0.3f);
- Rollers[_curIndex].Initializaion(other.gameObject);
- ActiveController();
- }
- else
- {
- Rollers[_curIndex].Initializaion(other.gameObject);
- ActiveController();
- }
- }
- private void OnRollerActive(Notification note)
- {
-
- }
- public void ResetRolley()
- {
- _curIndex = 0;
- for (var i= 0; i< Rollers.Count;i++)
- {
- Rollers[i].Roller.gameObject.SetActive(true);
- }
- }
- public int _curIndex = 0;
-
-
- public void ActiveController()
- {
- _curIndex++;
- if (_curIndex < Rollers.Count)
- {
- Rollers[_curIndex].gameObject.SetActive(true);
- }
-
- }
- }
|