Пример #1
0
        /// <summary>
        /// Construct a new CombatantPlayer object containing the given player.
        /// </summary>
        public CombatantMonster(Player player)
            : base()
        {
            // check the parameter
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            // assign the parameters
            this.player = player;

            // if the player starts dead, make sure the sprite is already "dead"
            if (IsDeadOrDying)
            {
                if (Statistics.HealthPoints > 0)
                {
                    State = RolePlayingGameData.Character.CharacterState.Idle;
                }
                else
                {
                    CombatSprite.PlayAnimation("Die");
                    CombatSprite.AdvanceToEnd();
                }
            }
            else
            {
                State = RolePlayingGameData.Character.CharacterState.Idle;
                CombatSprite.PlayAnimation("Idle");
            }
        }
Пример #2
0
 public Character(Character other)
 {
     characterName    = other.Name;
     health           = other.Health;
     poise            = other.Poise;
     speed            = other.Speed;
     defenses         = other.Defenses;
     combatSprite     = other.combatSprite;
     combatController = other.combatController;
     actions          = new List <ActionData>(other.actions);
 }
Пример #3
0
        /// <summary>
        /// Draw the combatant for this frame.
        /// </summary>
        public virtual void Draw(GameTime gameTime)
        {
            CombatSprite.Draw(Session.ScreenManager.SpriteBatch,
                              Position, 1f - Position.Y / 720f);

            Session.ScreenManager.SpriteBatch.Draw(Character.ShadowTexture, Position,
                                                   null, Color.White, 0f, new Vector2(Character.ShadowTexture.Width / 2,
                                                                                      Character.ShadowTexture.Height / 2), 1f, SpriteEffects.None, 1f);

            // draw the combat action
            if (combatAction != null)
            {
                // update the combat action
                combatAction.Draw(gameTime, Session.ScreenManager.SpriteBatch);
            }
        }
Пример #4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);



            if (CombatSprite.GetcurrentAnimation() != null && CombatSprite.GetcurrentAnimation().IsLoop == false)
            {
                if (CombatSprite.IsPlaybackComplete == false)
                {
                    return;
                }

                State = RolePlayingGameData.Character.CharacterState.Idle;
            }


            switch (State)
            {
            case RolePlayingGameData.Character.CharacterState.Walking:
            case RolePlayingGameData.Character.CharacterState.Idle:


                WindowsGame2.AI.InputData input = GetInputData();

                _CurAIState = MyLearning.I.GetNextAction(input);

                break;
            }


            switch (_CurAIState)
            {
            case OUTPUT.STAND:
                State = RolePlayingGameData.Character.CharacterState.Idle;

                break;

            case OUTPUT.ATTACK:
                State = RolePlayingGameData.Character.CharacterState.Attack;
                break;

            case OUTPUT.FAR:
                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Update the combatant for this frame.
        /// </summary>
        public virtual void Update(GameTime gameTime)
        {
            float elapsedSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // update the combat action
            if (combatAction != null)
            {
                // update the combat action
                combatAction.Update(gameTime);
                // remove the combat action if it is done and set the turn-taken flag
                if (combatAction.Stage == CombatAction.CombatActionStage.Complete)
                {
                    combatAction = null;
                    isTurnTaken  = true;
                }
            }


            // update the combat sprite animation
            CombatSprite.UpdateAnimation(elapsedSeconds);

            // check for death
            if (!IsDeadOrDying && (Statistics.HealthPoints <= 0))
            {
                AudioManager.PlayCue("Death");
                State = RolePlayingGameData.Character.CharacterState.Dying;
            }
            // check for waking up
            else if (IsDeadOrDying && (Statistics.HealthPoints > 0))
            {
                State = RolePlayingGameData.Character.CharacterState.Idle;
            }
            else if (CombatSprite.IsPlaybackComplete)
            {
                if (State == RolePlayingGameData.Character.CharacterState.Hit)
                {
                    State = RolePlayingGameData.Character.CharacterState.Idle;
                }
                else if (State == RolePlayingGameData.Character.CharacterState.Dying)
                {
                    State = RolePlayingGameData.Character.CharacterState.Dead;
                }
            }
        }
Пример #6
0
        public object Clone()
        {
            Player player = new Player();

            player.activePortraitTexture     = activePortraitTexture;
            player.activePortraitTextureName = activePortraitTextureName;
            player.AssetName                 = AssetName;
            player.CharacterClass            = CharacterClass;
            player.CharacterClassContentName = CharacterClassContentName;
            player.CharacterLevel            = CharacterLevel;
            player.CombatAnimationInterval   = CombatAnimationInterval;
            player.CombatSprite              = CombatSprite.Clone() as AnimatingSprite;
            player.Direction                 = Direction;
            player.EquippedEquipment.AddRange(EquippedEquipment);
            player.Experience = Experience;
            player.gold       = gold;
            player.inactivePortraitTexture     = inactivePortraitTexture;
            player.inactivePortraitTextureName = inactivePortraitTextureName;
            player.InitialEquipmentContentNames.AddRange(InitialEquipmentContentNames);
            player.introductionDialogue = introductionDialogue;
            player.Inventory.AddRange(Inventory);
            player.joinAcceptedDialogue     = joinAcceptedDialogue;
            player.joinRejectedDialogue     = joinRejectedDialogue;
            player.MapIdleAnimationInterval = MapIdleAnimationInterval;
            player.MapPosition = MapPosition;
            player.MapSprite   = MapSprite.Clone() as AnimatingSprite;
            player.MapWalkingAnimationInterval = MapWalkingAnimationInterval;
            player.Name          = Name;
            player.ShadowTexture = ShadowTexture;
            player.State         = State;
            player.unselectablePortraitTexture     = unselectablePortraitTexture;
            player.unselectablePortraitTextureName = unselectablePortraitTextureName;
            player.WalkingSprite = WalkingSprite.Clone() as AnimatingSprite;

            player.RecalculateEquipmentStatistics();
            player.RecalculateTotalDefenseRanges();
            player.RecalculateTotalTargetDamageRange();
            player.ResetAnimation(false);
            player.ResetBaseStatistics();

            return(player);
        }
Пример #7
0
 private static CombatSpriteAttribute GetAttribute(CombatSprite s)
 {
     return (CombatSpriteAttribute)Attribute.GetCustomAttribute(ForValue(s), typeof(CombatSpriteAttribute));
 }
Пример #8
0
 private static MemberInfo ForValue(CombatSprite s)
 {
     return typeof(CombatSpriteAttribute).GetField(Enum.GetName(typeof(CombatSpriteAttribute), s));
 }
Пример #9
0
        /// <summary>
        /// Update the player for this frame.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (CombatSprite.GetcurrentAnimation() != null && CombatSprite.GetcurrentAnimation().IsLoop == false)
            {
                if (CombatSprite.IsPlaybackComplete == false)
                {
                    return;
                }
            }

            Vector2 movePos = new Vector2(0, 0);

            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Left))
            {
                _LastDir = -1;

                movePos += new Vector2(-1, 0);
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Right))
            {
                _LastDir = 1;
                movePos += new Vector2(1, 0);
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Up))
            {
                movePos += new Vector2(0, -1);
            }
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Down))
            {
                movePos += new Vector2(0, 1);
            }


            if (movePos.Length() != 0)
            {
                State = RolePlayingGameData.Character.CharacterState.Walking;



                Position += movePos;
            }
            else
            {
                //if( this.CombatSprite.currentAnimation == null
                //    || this.CombatSprite.currentAnimation.IsLoop == false)

                State = RolePlayingGameData.Character.CharacterState.Idle;
            }



            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Space))
            {
                State = RolePlayingGameData.Character.CharacterState.Hit;

                //_Player.CombatSprite.PlayAnimation("Hit");
            }


            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.LeftControl))
            {
                State = RolePlayingGameData.Character.CharacterState.Attack;
                //_Player.CombatSprite.PlayAnimation("Hit");
            }
        }