コード例 #1
0
        /// <summary>
        /// Initialize the active move.
        /// </summary>
        /// <param name="move">The move to use in battle.</param>
        /// <param name="user">The user of the move.</param>
        /// <param name="target">The target for the move.</param>
        protected void Initialize(Move move, Creature user, Creature target)
        {
            //Initialize the class.
            _Move = move;
            _User = user;
            _Target = target;
            _IsCancelable = true;
            _HasUserControl = true;
            _HasTargetControl = false;
            _Timeline = Factory.Instance.createBattleAnimation(this);

            //Subscribe to the timeline.
            _Timeline.OnConcluded += ConcludedInvoke;
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
ファイル: Factory.cs プロジェクト: LaudableBauble/Insipidus
        /// <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;
        }