Exemplo n.º 1
0
 /// <summary>
 /// 移除管理的子状态机
 /// </summary>
 /// <param name="hfsmSystem">子状态机的名称</param>
 public void RemoveSubSystem(HFSMBaseSystem hfsmSystem)
 {
     if (!systems.ContainsValue(hfsmSystem))
     {
         Debug.LogError("HFSMManagerSystem ERROR: " + hfsmSystem.Name + "子状态机未被管理状态机管理,删除失败!");
         return;
     }
     systems.Remove(hfsmSystem.Name);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 退出当前子状态机,继续执行上一状态。
 /// </summary>
 /// <param name="transition"></param>
 public void QuitCurrentState(string currentState = "")
 {
     if (activeSystems.Count > 1)
     {
         activeSystems.Pop();
         currentSystem = activeSystems.Peek();
         if (currentState != "")
         {
             currentSystem.SetStateAsCurrent(currentState);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 添加管理的子状态机
        /// </summary>
        /// <param name="hfsmSystem">子状态机对象</param>
        public void AddSubSystem(HFSMBaseSystem hfsmSystem)
        {
            if (systems.ContainsKey(hfsmSystem.Name))
            {
                Debug.LogError("HFSMManagerSystem ERROR: " + hfsmSystem.Name + "子状态机已经添加,请勿重复添加!");
                return;
            }

            if (systems.Count == 0)
            {
                currentSystem = hfsmSystem;
                activeSystems.Push(currentSystem);
            }
            systems.Add(hfsmSystem.Name, hfsmSystem);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 切换当前正在执行的子状态机
 /// </summary>
 /// <param name="hfsmSystemName">子状态机名称</param>
 /// <param name="transition">切换后子状态机要转换的条件</param>
 public void ChangeSystem(string hfsmSystemName, string currentState = "")
 {
     if (systems.ContainsKey(hfsmSystemName))
     {
         //proviceSystem = currentSystem;
         currentSystem = systems[hfsmSystemName];
         activeSystems.Push(currentSystem);
         if (currentState != "")
         {
             currentSystem.SetStateAsCurrent(currentState);
         }
     }
     else
     {
         Debug.LogError("HFSMManagerSystem ERROR: " + hfsmSystemName + "子状态机未被管理状态机管理,删除失败!");
     }
 }