| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using UnityCommon;
- namespace DTYJ
- {
- public class PlatformDoorController : SerializedMonoBehaviour
- {
- public static PlatformDoorController Instance;
- private void Awake()
- {
- Instance = this;
- }
- public Dictionary<string, Animation> dicDoors = new Dictionary<string, Animation>();
- public void SetDoor(string id, int state)
- {
- if (state == 1 || state == 0)
- {
- if (dicDoors.ContainsKey(id))
- {
- var anim = dicDoors[id];
- var animationName = anim.clip.name;
- anim[animationName].time = state == 1 ? 0 : anim[animationName].length;
- anim[animationName].speed = state == 1 ? 1 : -1;
- anim[animationName].wrapMode = WrapMode.Once;
- anim.CrossFade(animationName);
- }
- }
- }
- //[ContextMenu("´¦Àí")]
- public void Handle()
- {
- var rootSx = GameObject.Find("SceneCommon/Animation/PSDAll_ÏÂÐÐ/psd_animation/psd_total");
- var anims = rootSx.GetComponentsInChildren<Animation>();
- foreach (var anim in anims)
- {
- if (anim.gameObject.activeSelf)
- dicDoors[anim.name] = anim;
- }
- var rootXx = GameObject.Find("SceneCommon/Animation/PSDAll_ÉÏÐÐ/psd_animation/psd_total");
- anims = rootXx.GetComponentsInChildren<Animation>();
- foreach (var anim in anims)
- {
- if (anim.gameObject.activeSelf)
- dicDoors[anim.name] = anim;
- }
- }
- [ContextMenu("´¦Àí")]
- public void HandleTemp()
- {
- Dictionary<string, Animation> dicNew = new Dictionary<string, Animation>();
- foreach (var kvp in dicDoors)
- {
- var animPath = Utility.GetPathInHierichy(kvp.Value.transform, null);
- dicNew["1_" + kvp.Key] = GameObject.Find("StationOthers/1/" + animPath).GetComponent<Animation>();
- dicNew["2_" + kvp.Key] = GameObject.Find("StationOthers/2/" + animPath).GetComponent<Animation>();
- }
- foreach (var kvp in dicNew)
- {
- dicDoors[kvp.Key] = kvp.Value;
- }
- }
- }
- }
|