void Start()
 {
     animationClipTypeStateList = new List <AnimationClipTypeState>();
     iAnimatorState             = GameState.Instance.GetEntity <IAnimatorState>();
     iSpecialState = GameState.Instance.GetEntity <ISpecialState>();
     if (!playerAnimator)
     {
         playerAnimator = GetComponent <Animator>();
     }
     if (playerAnimator)
     {
         PlayerAnimRunningState[] playerAnimRunningStates = playerAnimator.GetBehaviours <PlayerAnimRunningState>();
         foreach (PlayerAnimRunningState playerAnimRunningState in playerAnimRunningStates)
         {
             playerAnimRunningState.AnimRunningStateHandle += PlayerAnimRunningState_AnimRunningStateHandle;
         }
     }
     //注册监听
     GameState.Instance.Registor <IPlayerState>(CallBackIPlayerStateState);
     GameState.Instance.Registor <IAnimatorState>(CallBackIAnimatorState);
     GameState.Instance.Registor <ISpecialState>(CallBackISpecialState);
     GameState.Instance.Registor <IPlayerAttributeState>(CallBackIAttributeState);
     //设置初始武器状态
     CallBackIPlayerStateState(GameState.Instance.GetEntity <IPlayerState>(), GameState.GetFieldNameStatic <IPlayerState, bool>(temp => temp.EquipmentChanged));
     //设置初始速度
     CallBackIAttributeState(GameState.Instance.GetEntity <IPlayerAttributeState>(), GameState.GetFieldNameStatic <IPlayerAttributeState, float>(temp => temp.AttackSpeed));
 }
 /// <summary>
 /// 监听函数-特殊状态变化
 /// </summary>
 /// <param name="iSpecialState"></param>
 /// <param name="fieldName"></param>
 private void CallBackISpecialState(ISpecialState iSpecialState, string fieldName)
 {
     if (!playerAnimator)
     {
         return;
     }
     //眩晕状态发生变化
     if (string.Equals(fieldName, GameState.Instance.GetFieldName <ISpecialState, BuffState>(temp => temp.Xuanyun)))
     {
         playerAnimator.SetBool("Dizzy", iSpecialState.Xuanyun.Time > 0);
     }
 }
예제 #3
0
    /// <summary>
    /// 监听special状态变化回调
    /// </summary>
    /// <param name="iSpecialState"></param>
    /// <param name="specialName"></param>
    private void CallbackSpecialState(ISpecialState iSpecialState, string specialName)
    {
        Action <BuffState, string> CheckGameState = (tempBuffState, buffStateName) =>
        {
            if (tempBuffState.Time > 0)                                 //如果存在异常则添加到集合中
            {
                if (!specialStateList_CantMove.Contains(buffStateName)) //如果不存在再添加,否则会重复添加
                {
                    specialStateList_CantMove.Add(buffStateName);
                }
            }
            else //如果异常时间到了则从集合中移除
            {
                if (specialStateList_CantMove.Contains(buffStateName)) //如果存在再移除
                {
                    specialStateList_CantMove.Remove(buffStateName);
                }
            }
        };

        if (string.Equals(specialName, GameState.Instance.GetFieldName <ISpecialState, BuffState>(temp => temp.Jiangzhi)))//如果是僵直
        {
            CheckGameState(iSpecialState.Jiangzhi, specialName);
        }
        if (string.Equals(specialName, GameState.Instance.GetFieldName <ISpecialState, BuffState>(temp => temp.Xuanyun)))//如果是眩晕
        {
            CheckGameState(iSpecialState.Xuanyun, specialName);
        }
        if (string.Equals(specialName, GameState.Instance.GetFieldName <ISpecialState, BuffState>(temp => temp.Jingu)))//如果是禁锢
        {
            CheckGameState(iSpecialState.Jingu, specialName);
        }
        if (string.Equals(specialName, GameState.Instance.GetFieldName <ISpecialState, BuffState>(temp => temp.Mabi)))//如果是麻痹
        {
            CheckGameState(iSpecialState.Mabi, specialName);
        }
    }