Exemple #1
0
 /// <summary>
 /// Callback when Actionset finish
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnUpdateActionSets(object sender, EventArgs e)
 {
     if (actionsets.Count > 0)
     {
         if (this.GetType() == typeof(demo.Player) && ClientID != 0 && scene.State == demo.Scene.SceneState.Map)
         {
             if (actionsets[0].factor == CharacterActionSetChangeFactor.ArriveTarget ||
                 actionsets[0].factor == CharacterActionSetChangeFactor.ArriveInteractiveTarget)
             {
                 MainGame.SendMoveFinishMsg(this);
             }
         }
         actionsets.RemoveAt(0);
         if (actionsets.Count == 0 && currentactionset != null)
         {
             if (OnActionCompleted != null && currentactionset.factor != CharacterActionSetChangeFactor.Immediate)
             {
                 OnActionCompleted(this, new EventArgs());
                 //OnActionCompleted = null;
             }
         }
     }
     currentactionset = null;
 }
Exemple #2
0
 /// <summary>
 /// 从actionset的队列前部插入一个actionset
 /// </summary>
 /// <param name="animname">需要切换的动作名</param>
 /// <param name="state">actionset对应的状态</param>
 /// <param name="factor">转换因子</param>
 /// <param name="o">上下文参数</param>
 public void AddActionSetPre(string animname, CharacterState state, CharacterActionSetChangeFactor factor, object o)
 {
     CharacterActionSet cas = new CharacterActionSet(animname, state, factor, o);
     actionsets.Insert(0, cas);
 }
Exemple #3
0
        /// <summary>
        /// 每帧从actionset list取得新的action set加入到执行,并根据
        /// actionset的属性设置不同的完成事件
        /// </summary>
        /// <param name="gametime"></param>
        private void UpdateActionSet(GameTime gametime)
        {
            while (actionsets.Count > 0 && currentactionset == null)
            {
                currentactionset = actionsets[0];
                if (pic.SetCurrentAnimationByName(currentactionset.animname))
                {
                    Log.WriteLine(string.Format("Now action is {0}", currentactionset.animname));
                    State = currentactionset.state;
                    switch (currentactionset.factor)
                    {
                        case CharacterActionSetChangeFactor.AnimationCompleted:
                            {
                                pic.CurrentAnimation.OnAnimationFini += new EventHandler(OnUpdateActionSets);
                                pic.CurrentAnimation.OnAnimationEvent += new EventHandler(OnPicAnimationEvent);
                                break;
                            }
                        case CharacterActionSetChangeFactor.ArriveTarget:
                            {
                                //Target = currentactionset.target;
                                OnArrived += new EventHandler(OnUpdateActionSets);
                                break;
                            }
                        case CharacterActionSetChangeFactor.ArriveAttackTarget:
                            {
                                AttackTarget = currentactionset.interactive;
                                OnArrived += new EventHandler(OnUpdateActionSets);
                                break;
                            }
                        case CharacterActionSetChangeFactor.ArriveInteractiveTarget:
                            {
                                InteractiveTarget = currentactionset.interactive;
                                OnArrived += new EventHandler(OnUpdateActionSets);
                                break;
                            }
                        case CharacterActionSetChangeFactor.EffectCompleted:
                            {
                                if (effects.ContainsKey(currentactionset.effectname))
                                {
                                    effects[currentactionset.effectname].Play();
                                    pic.Child = effects[currentactionset.effectname];
                                    effects[currentactionset.effectname].OnAnimationFini += new EventHandler(OnUpdateActionSets);
                                }
                                else
                                {
                                    OnUpdateActionSets(this, new EventArgs());
                                }
                                break;
                            }
                        case CharacterActionSetChangeFactor.Time:
                            {
                                break;
                            }
                        case CharacterActionSetChangeFactor.Immediate:
                            {
                                OnUpdateActionSets(this, new EventArgs());
                                break;
                            }
                    }
                }
                else
                {
                    actionsets.RemoveAt(0);
                    currentactionset = null;
                }
            }

            if (currentactionset != null)
            {
                if (currentactionset.factor == CharacterActionSetChangeFactor.Time)
                {
                    currentactionset.duration -= gametime.ElapsedGameTime.TotalSeconds;
                    if (currentactionset.duration <= 0.0)
                    {
                        OnUpdateActionSets(this, new EventArgs());
                    }
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// 清除actionset list
 /// </summary>
 public void ClearActionSet()
 {
     actionsets.Clear();
     currentactionset = null;
 }