Пример #1
0
        private void NextActionRound()
        {
            if (actionlist.Count > 0)
            {
                if (actionlist.Count == 1)
                {
                    actionlist.Clear();
                    NextRound();
                    return;
                }
                if (actionlist[0].character is Player)
                {
                    if (localplayer.Operate == Character.OperateType.Attack)
                    {
                        localplayer.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null);
                        localplayer.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveAttackTarget, localplayer.OperateTarget);
                        localplayer.AddActionSet("Landing", CharacterState.Landing, CharacterActionSetChangeFactor.AnimationCompleted, null);
                        localplayer.AddActionSet("Attack", CharacterState.Attack, CharacterActionSetChangeFactor.AnimationCompleted, null);
                        localplayer.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null);
                        localplayer.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveTarget, localplayer.Position);
                        localplayer.AddActionSet("Landing", CharacterState.Landing, CharacterActionSetChangeFactor.AnimationCompleted, null);
                        localplayer.AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    }
                    else if (localplayer.Operate == Character.OperateType.Magic)
                    {
                        if (localplayer.OperateTarget != localplayer)
                        {
            #if WINDOWS_PHONE
                            Spell fireball = Character.CreateCharacter("fireball", this, "fireball") as Spell;
            #else
                            Spell fireball = Character.CreateCharacter("fireball", this) as Spell;
            #endif
                            if (fireball != null)
                            {
                                fireball.Layer = 15;
                                fireball.FaceDirMethod = Character.DirMethod.Fixed;
                                fireball.FixedDir = new Vector2(1, 0);
                                fireball.Picture.Direction = fireball.FixedDir;

                                fireball.Position = localplayer.Position + new Vector2(100, 0);
                                fireball.OnActionCompleted += new EventHandler(Spell_OnActionCompleted);
                                AddSpell(fireball);

                                fireball.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null);
                                fireball.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveAttackTarget, localplayer.OperateTarget);
                                fireball.AddActionSet("Attack", CharacterState.Attack, CharacterActionSetChangeFactor.AnimationCompleted, null);
                                fireball.AddActionSet("Idle", CharacterState.Dead, CharacterActionSetChangeFactor.AnimationCompleted, null);

                                localplayer.AddActionSet("Attack2", CharacterState.Attack2, CharacterActionSetChangeFactor.AnimationCompleted, null);
                                localplayer.AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.Immediate, null);
                            }
                        }
                        else
                        {
                            localplayer.HP += 100;
                            localplayer.HP = (int)MathHelper.Min((float)localplayer.HP, (float)localplayer.MaxHP);
                            //play number animation
                            effects.NumberAnimation na = new effects.NumberAnimation(100);
                            na.Position = new Vector2(localplayer.Position.X, localplayer.Position.Y - localplayer.Picture.FrameSize.Y * 0.5f);
                            na.Color = new Color(0.0f, 1.0f, 0.0f);
                            na.Play(this);
                            GoNextActionRound();
                        }
                    }
                }
                else
                {
                    Monster monster = actionlist[0].character as Monster;
                    monster.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    monster.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveAttackTarget, localplayer);
                    monster.AddActionSet("Landing", CharacterState.Landing, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    monster.AddActionSet("Attack", CharacterState.Attack, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    monster.AddActionSet("Launch", CharacterState.Launch, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    monster.AddActionSet("Moving", CharacterState.Moving, CharacterActionSetChangeFactor.ArriveTarget, monster.Position);
                    monster.AddActionSet("Landing", CharacterState.Landing, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    monster.AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.AnimationCompleted, null);
                }

                actionlist[0].character.Order = null;
                actionlist.RemoveAt(0);

            }
        }
Пример #2
0
        /// <summary>
        /// 角色被攻击后的Callback
        /// </summary>
        /// <param name="offense">进攻者</param>
        public void BeAttack(Character offense)
        {
            try
            {
                float dhp = MathHelper.Max(offense.ATK * 1.5f - def * 1.3f, 0);
                hp -= (int)dhp;
                //play number animation
                effects.NumberAnimation na = new effects.NumberAnimation((int)dhp);
                na.Position = new Vector2(this.Position.X, this.Position.Y - this.Picture.FrameSize.Y * 0.5f);
                na.Color = new Color(1.0f, 0.0f, 0.0f);
                na.Play(Scene);

                ClearActionSet();
                AddActionSet("BeAttack", CharacterState.BeAttack, CharacterActionSetChangeFactor.AnimationCompleted, null);
                if (hp <= 0)
                {
                    //ClearActionSet();
                    //AddActionSet("Dying", CharacterState.Dying, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    AddActionSet("Dead", CharacterState.Dead, CharacterActionSetChangeFactor.AnimationCompleted, null);
                    offense.Notify(GameAction.Kill, this.templateid, 1);
                }
                else
                    AddActionSet("Idle", CharacterState.Idle, CharacterActionSetChangeFactor.Immediate, null);
            }
            catch (NullReferenceException)
            {
                Log.WriteLine(ToString() + ":must had offense");
            }
        }