SceneEventAreaLockLogic.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SceneEventAreaLockLogic : MonoBehaviour
  5. {
  6. public int areaIndex = 0;
  7. private bool isUnlockDoor = false;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. AIManager.Instance.AddAreaLockCmpt(this);
  12. SceneEventAreaLock info = this.gameObject.GetComponent<SceneEventAreaLock>();
  13. this.areaIndex = info.areaIndex;
  14. int curMapId = UserProxy.Instance.player.newMap.curMapId;
  15. List<string> unlockInfo = MapProxy.Instance.getMapUnlockInfoList(curMapId);
  16. foreach(var item in unlockInfo)
  17. {
  18. string[] unlock = item.Split('_');
  19. if(curMapId == int.Parse(unlock[0]) &&
  20. int.Parse(unlock[1]) == (int)(SceneEventExplore.ExploreType.Border) &&
  21. areaIndex == int.Parse(unlock[2]))
  22. {
  23. AreaClose();
  24. }
  25. }
  26. }
  27. public bool IsUnlockDoor { get { return this.isUnlockDoor; } }
  28. public void AreaUnlock()
  29. {
  30. SceneEventGateLogic door;
  31. if (this.TryGetComponent<SceneEventGateLogic>(out door))
  32. {
  33. isUnlockDoor = true;
  34. door.OpenDoor();
  35. }
  36. else
  37. {
  38. Animator anim = this.gameObject.GetComponent<Animator>();
  39. if (anim)
  40. {
  41. anim.Play("zhandou_jiejie_end",0,0);
  42. }
  43. SceneEventExploreLogic expLogix = this.GetComponent<SceneEventExploreLogic>();
  44. expLogix.ExploreTrigger();
  45. }
  46. }
  47. public void AreaClose()
  48. {
  49. Animator anim = this.gameObject.GetComponent<Animator>();
  50. if (anim)
  51. {
  52. anim.Play("zhandou_jiejie_end", 0, 0);
  53. }
  54. }
  55. }