1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class TriggerRollerDeactive : MonoBehaviour
- {
- public List<RollerController> ListRollers;
- private int _curIndex = 0;
- public List<Transform> SpawnPointPlayer;
- private LevelTargets _levelTargets;
- private LevelTargets GetTargets()
- {
- return LevelManager.Instance.CurLevel.LevelTargets;
- }
- private void Start()
- {
-
- }
- public void ResetRolley()
- {
- _curIndex = 0;
- //for (var i = 0; i < ListRollers.Count; i++)
- //{
- // ListRollers[i].Roller.gameObject.SetActive(true);
- //}
- }
- private void OnTriggerEnter(Collider other)
- {
-
- if (other.tag == "Player")
- {
- var rController = ListRollers[_curIndex];
- other.gameObject.SetActive(false);
- rController.StopRoller();
- var r = UnityEngine.Random.Range(0, SpawnPointPlayer.Count - 1);
- Debug.Log(r);
- var agent = rController.Player.GetComponent<RunnersController>().Agent;
- rController.Player.transform.SetParent(SpawnPointPlayer[r]);
- rController.Player.transform.localPosition = Vector3.zero;
- rController.Player.transform.localScale = Vector3.one;
- _levelTargets = LevelManager.Instance.CurLevel.LevelTargets;
- rController.Player.GetComponent<RunnersController>().SetTarget(_levelTargets.ListLevelTargets[1]);
- DeactiveController();
- switch(Core.Instance.CurGender)
- {
- case Core.Gender.Male:
- rController.Player.transform.SetParent(Core.Instance.ParentMale);
- break;
- case Core.Gender.Female:
- rController.Player.transform.SetParent(Core.Instance.ParentFemale);
- break;
- }
- rController.Player.SetActive(true);
- //rController.Player.GetComponent<RunnersController>().Start();
- //Debug.Log(_levelTargets.CurTarget);
- //_levelTargets.CurTarget++;
- if (rController.Player.GetComponent<RunnersController>().IsPlayer)
- {
- rController.Player.SetActive(true);
- UIManager.Instance.Camera.transform.SetParent(null);
- UIManager.Instance.Camera.GetComponent<CompleteCameraController>().enabled = true;
- }
- rController.Player.GetComponent<RunnersController>().Move();
- NotificationCenter.Post(NotificationType.RollerDeactive, other.gameObject);
- }
- }
- public void DeactiveController()
- {
- _curIndex++;
- if(_curIndex< ListRollers.Count)
- {
- ListRollers[_curIndex].gameObject.SetActive(true);
- }
- }
- }
|