/// <summary>
 /// Constructor for a battle animation.
 /// </summary>
 /// <param name="move">The move to use in battle.</param>
 public BattleAnimation(BattleMove move)
 {
     //Initialize a few things.
     Initialize(move);
 }
Exemple #2
0
        /// <summary>
        /// Launch an attack on a creature with a move.
        /// </summary>
        /// <param name="move">The move to attack with.</param>
        /// <param name="target">The target to attack.</param>
        public void LaunchAttack(Move move, Creature target)
        {
            //Stop here if the move or target isn't valid, or if a move already has been set in motion.
            if (move == null || target == null || _BattleState != BattleState.Idle) { return; }

            //Prepare for the attack.
            _BattleState = BattleState.Waiting;
            //Create the activated form of the move.
            BattleMove active = new BattleMove(move, this, target);

            //Attack.
            BattleCoordinator.Instance.QueueMove(active);
        }
        /// <summary>
        /// Use a move.
        /// </summary>
        /// <param name="move">The move to use.</param>
        private void UseMove(BattleMove move)
        {
            //Load the move's content.
            move.LoadContent(_Content);

            //Use the move.
            move.Activate();
        }
 /// <summary>
 /// Initialize the battle animation.
 /// </summary>
 /// <param name="move">The move to use in battle.</param>
 protected void Initialize(BattleMove move)
 {
     //Initialize the class.
     _Timeline = new Timeline(move);
 }
        /// <summary>
        /// When a move has been cancelled or completed.
        /// </summary>
        /// <param name="move">The move that is finished.</param>
        private void OnMoveFinished(BattleMove move)
        {
            //The move is now obsolete, remove it.
            _Moves.Remove(move);

            //Unsubscribe from the move.
            move.Concluded -= OnMoveFinished;
        }
        /// <summary>
        /// Queue a move for use in battle.
        /// </summary>
        /// <param name="move">The move to queue.</param>
        public void QueueMove(BattleMove move)
        {
            //Add the move to the list.
            if (move != null && move.User != null && move.Target != null) { _Moves.Add(move); }

            //Subscribe to the move's events.
            move.Concluded += OnMoveFinished;
        }
Exemple #7
0
        /// <summary>
        /// Create a battle animation, given a certain move.
        /// </summary>
        /// <param name="move">The move to create an animation for.</param>
        /// <returns></returns>
        public Timeline createBattleAnimation(BattleMove move)
        {
            //TODO: Creating and handling a move's animation should be more robust and maintainable. This is a bit of a hack.

            //Create the animation timeline.
            Timeline animation = new Timeline(move);

            //Check the name of the move and create a fitting animation.
            switch (move.Name)
            {
                case "Ember":
                    {
                        //Add events to the timeline.
                        ModifyEnergyEvent energy = new ModifyEnergyEvent(animation, 0, null, move.User, -move.EnergyConsume);
                        ModifyControlEvent state = new ModifyControlEvent(animation, 0, energy, move, move.User, false);
                        ModifyCancelableEvent cancel = new ModifyCancelableEvent(animation, 0, energy, move, false);
                        ProjectileEvent projectile = new ProjectileEvent(animation, 0, null, move.User.Position, new Destination(move.Target));
                        ModifyHealthEvent damage = new ModifyHealthEvent(animation, 0, projectile, move.Target, -move.GetDamage());
                        ImpactEvent impact = new ImpactEvent(animation, 0, projectile, move);

                        //Add the events to the timeline.
                        animation.AddEvent(energy);
                        animation.AddEvent(state);
                        animation.AddEvent(cancel);
                        animation.AddEvent(projectile);
                        animation.AddEvent(damage);
                        animation.AddEvent(impact);
                        break;
                    }
                case "Scratch":
                    {
                        //Add events to the timeline.
                        ModifyControlEvent stateStart = new ModifyControlEvent(animation, 0, null, move, move.User, true);
                        MovementEvent moveTo = new MovementEvent(animation, 0, null, move.User, new Destination(move.Target), MovementType.Run);
                        ModifyCancelableEvent cancel = new ModifyCancelableEvent(animation, 0, moveTo, move, false);
                        ModifyHealthEvent damage = new ModifyHealthEvent(animation, 0, moveTo, move.Target, -move.GetDamage());
                        ModifyEnergyEvent energy = new ModifyEnergyEvent(animation, 0, damage, move.User, -move.EnergyConsume);
                        ModifyControlEvent stateEnd = new ModifyControlEvent(animation, 0, energy, move, move.User, false);
                        ImpactEvent impact = new ImpactEvent(animation, 0, moveTo, move);

                        //Add the events to the timeline.
                        animation.AddEvent(stateStart);
                        animation.AddEvent(moveTo);
                        animation.AddEvent(cancel);
                        animation.AddEvent(damage);
                        animation.AddEvent(energy);
                        animation.AddEvent(stateEnd);
                        animation.AddEvent(impact);
                        break;
                    }
                default: { goto case "Scratch"; }
            }

            //Return the animation.
            return animation;
        }
Exemple #8
0
 /// <summary>
 /// Constructor for a timeline.
 /// </summary>
 /// <param name="move">The battle move to execute.</param>
 public Timeline(BattleMove move)
 {
     Initialize(move);
 }
Exemple #9
0
 /// <summary>
 /// Initialize the timeline.
 /// </summary>
 /// <param name="move">The battle move to execute.</param>
 private void Initialize(BattleMove move)
 {
     //Initialize the fields.
     _Move = move;
     _ElapsedTime = 0;
     _Events = new List<TimelineEvent>();
     _State = TimelineState.Idle;
 }