/// <summary>
 ///     The method to run when this action is being used.
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void Use(BaseBattleDriver target)
 {
     foreach (Buff buff in Bravery.buffs)
     {
         buff.Apply(target);
     }
 }
        /// <summary>
        ///     Returns a new instance of a battle action class based on an enum
        /// </summary>
        /// <param name="action">The action to get</param>
        /// <param name="user">The user to initialize it with</param>
        /// <returns>A new instance of a battle action</returns>
        public static BattleAction GetBattleAction(ActionClass action, BaseBattleDriver user)
        {
            switch (action)
            {
            case ActionClass.AOEHeal:
                return(new AOEHeal(user));

            case ActionClass.Bravery:
                return(new Bravery(user));

            case ActionClass.FireMagic:
                return(new FireMagic(user));

            case ActionClass.MajorHeal:
                return(new MajorHeal(user));

            case ActionClass.MinorHeal:
                return(new MinorHeal(user));

            case ActionClass.Smash:
                return(new Smash(user));

            case ActionClass.QuickSlash:
                return(new QuickSlash(user));

            case ActionClass.NoAction:
                return(new NoAction(user));

            default:
                // Default to smash
                return(new Smash(user));
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Spawns an entity based on a prefab with a bonus
        /// </summary>
        /// <typeparam name="T">The type of the prefab</typeparam>
        /// <param name="prefab">The prefab to use</param>
        /// <param name="bonus1">The first bonus stat</param>
        /// <param name="bonus2">The second bonus stat</param>
        /// <returns>The new entity</returns>
        public static T SpawnEntityWithBonus <T>(T prefab, Stat?bonus1 = Stat.Random, Stat?bonus2 = Stat.Random) where T : BaseDriver
        {
            T driver = Instantiate(prefab);
            BaseBattleDriver battleDriver = driver.battleDriver;

            if (bonus1 == Stat.Random)
            {
                bonus1 = MainGeneral.GetRandomStat();
            }

            if (bonus2 == Stat.Random)
            {
                bonus2 = MainGeneral.GetRandomStat(bonus1);
            }

            if (bonus1 != null)
            {
                battleDriver.SetBaseStat(
                    (Stat)bonus1,
                    battleDriver.GetBaseStat((Stat)bonus1) * BaseBattleDriver.BonusStatMultiplier);
            }

            if (bonus2 != null)
            {
                battleDriver.SetBaseStat(
                    (Stat)bonus2,
                    battleDriver.GetBaseStat((Stat)bonus2) * BaseBattleDriver.BonusStatMultiplier);
            }

            return(driver);
        }
Beispiel #4
0
 /// <summary>
 ///     The method to run when this action is being used.
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void Use(BaseBattleDriver target)
 {
     if (target.TakingTurn)
     {
         target.TakingTurn = false;
     }
 }
        /// <summary>
        ///     Deal damage respecting the damage formula.
        /// </summary>
        /// <param name="target">The defending BattleDriver</param>
        /// <returns>The amount of damage dealt</returns>
        public int DealDamage(BaseBattleDriver target)
        {
            float damageStat;

            switch (this.Category)
            {
            case ActionCategory.PhysicalAttack:
                damageStat = this.User.PhysicalDamage;
                break;

            case ActionCategory.MagicalAttack:
                damageStat = this.User.MagicalDamage;
                break;

            default:
                Debug.LogWarning("Attempting to deal damage with BattleAction of category " + this.Category.ToString());
                damageStat = 0.0f;
                break;
            }

            int damageValue = (int)Mathf.Max(
                0.0f,
                (BaseBattleDriver.LevelStatOffset + this.User.Level) * this.AttackPower * damageStat / target.Defense);

            target.CurrentHealth -= damageValue;
            return(damageValue);
        }
Beispiel #6
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="QuickSlash"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public QuickSlash(BaseBattleDriver user) : base(user)
        {
            this.name        = "Quick Slash";
            this.description = "A fast attack which deals high damage.";

            this.attackPointCost = 7.0f;
            this.attackPower     = 14.0f;
            this.category        = ActionCategory.PhysicalAttack;
            this.targetOption    = ActionTargetOption.OneOpponent;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="Smash"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public Smash(BaseBattleDriver user) : base(user)
        {
            this.name        = "Smash";
            this.description = "Ram into an enemy to deal some damage.";

            this.attackPointCost = 4.0f;
            this.attackPower     = 10.0f;
            this.category        = ActionCategory.PhysicalAttack;
            this.targetOption    = ActionTargetOption.OneOpponent;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="Bravery"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public Bravery(BaseBattleDriver user) : base(user)
        {
            this.name        = "Bravery";
            this.description = "Increases Damage and Defense of all allies for 1 turn.";

            this.attackPointCost = 12.0f;
            this.attackPower     = 0.0f;
            this.category        = ActionCategory.Support;
            this.targetOption    = ActionTargetOption.AllAllies;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="_NewAction"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public _NewAction(BaseBattleDriver user) : base(user)
        {
            this.name        = "ACTIONNAME";
            this.description = "ACTIONDESCRIPTION";

            this.attackPointCost = 10.0f;
            this.attackPower     = 10.0f;
            this.category        = ActionCategory.Undefined;
            this.targetOption    = ActionTargetOption.OneOpponent;
        }
Beispiel #10
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="NoAction"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public NoAction(BaseBattleDriver user) : base(user)
        {
            this.name        = "End Turn";
            this.description = "Ends the current turn.";

            this.attackPointCost = 1.0f;
            this.attackPower     = 0.0f;
            this.category        = ActionCategory.Undefined;
            this.targetOption    = ActionTargetOption.Self;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="FireMagic"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public FireMagic(BaseBattleDriver user) : base(user)
        {
            this.name        = "Fire Magic";
            this.description = "Magic which deals damage to an opponent and has them take damage for a few turns.";

            this.attackPointCost = 5.0f;
            this.attackPower     = 5.0f;
            this.category        = ActionCategory.MagicalAttack;
            this.targetOption    = ActionTargetOption.OneOpponent;
        }
        /// <summary>
        ///     Finds all fighters with the same tag as <paramref name="leaderBattleDriver"/>
        ///     and adds the ones not participating to <seealso cref="DeactivatableGameObjects"/>
        /// </summary>
        /// <param name="leaderBattleDriver">The leader of the bunch</param>
        /// <returns>A list of <seealso cref="BaseBattleDriver"/>s</returns>
        private List <BaseBattleDriver> FindFighters(BaseBattleDriver leaderBattleDriver)
        {
            // Find all GameObjects with the same tag as the leader
            GameObject[] allFighters = GameObject.FindGameObjectsWithTag(leaderBattleDriver.tag);

            List <BaseBattleDriver> listOfFighters = new List <BaseBattleDriver>();

            BaseDriver leaderDriver = leaderBattleDriver.GetComponent <BaseDriver>();

            // Check each of them
            foreach (GameObject fighter in allFighters)
            {
                BaseDriver driver = fighter.GetComponent <BaseDriver>();

                if (driver != null && (driver.Leader == leaderDriver || driver == leaderDriver))
                {
                    // Required component; should never be missing
                    listOfFighters.Add(fighter.GetComponent <BaseBattleDriver>());
                }
                else
                {
                    fighter.SetActive(false);
                    this.DeactivatableGameObjects.Add(fighter);
                }
            }

            // Sort them
            List <BaseBattleDriver> listOfFightersSorted = new List <BaseBattleDriver>(listOfFighters.Count);

            for (int i = 0; i < listOfFighters.Count; i++)
            {
                foreach (BaseBattleDriver battleDriver in listOfFighters)
                {
                    BaseDriver driver = battleDriver.entityDriver;
                    int        number = 0;
                    while (driver.Following != null)
                    {
                        driver = driver.Following;
                        ++number;

                        if (number > listOfFighters.Count)
                        {
                            throw new RPGException(RPGException.Cause.DriverLoopingFollowing);
                        }
                    }

                    if (number == i)
                    {
                        listOfFightersSorted.Add(battleDriver);
                    }
                }
            }

            return(listOfFightersSorted);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="AOEHeal"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public AOEHeal(BaseBattleDriver user) : base(user)
        {
            this.name        = "Area Heal";
            this.description = "Heals all allies for 25% of their Maximum Health.";

            // Storing heal-potential (fraction) in attack power.
            this.attackPower = 0.25f;

            this.attackPointCost = 10.0f;
            this.category        = ActionCategory.Support;
            this.targetOption    = ActionTargetOption.AllAllies;
        }
        /// <summary>
        ///     Called by Unity to initialize the <seealso cref="BaseDriver"/> whether it is or is not active.
        /// </summary>
        protected virtual void Awake()
        {
            this.spriteManager  = this.GetComponent <SpriteManager>();
            this.spriteAnimator = this.GetComponent <SpriteAnimator>();
            this.battleDriver   = this.GetComponent <BaseBattleDriver>();
            this.highlight      = this.GetComponent <Highlighter>();
            this.rigidbody      = this.GetComponent <Rigidbody>();

            this.lastVelocity = this.transform.forward;

            this.battleDriver.enabled = false;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="MajorHeal"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public MajorHeal(BaseBattleDriver user) : base(user)
        {
            this.name        = "Major Heal";
            this.description = "Fully recovers an allies health.";

            // Storing heal-potential (fraction) in attack power.
            this.attackPower = 1.00f;

            this.attackPointCost = 14.0f;
            this.category        = ActionCategory.Support;
            this.targetOption    = ActionTargetOption.OneAlly;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="_NewHeal"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public _NewHeal(BaseBattleDriver user) : base(user)
        {
            this.name        = "ACTIONNAME";
            this.description = "ACTIONDESCRIPTION";

            // Storing heal-potential (fraction) in attack power.
            this.attackPower = 0.25f;

            this.attackPointCost = 6.0f;
            this.category        = ActionCategory.Support;
            this.targetOption    = ActionTargetOption.OneAlly;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="MinorHeal"/> class
        /// </summary>
        /// <param name="user">The BattleDriver which will use this action</param>
        public MinorHeal(BaseBattleDriver user) : base(user)
        {
            this.name        = "Minor Heal";
            this.description = "Heals an ally for 25% of their Maximum Health.";

            // Storing heal-potential (fraction) in attack power.
            this.attackPower = 0.25f;

            this.attackPointCost = 6.0f;
            this.category        = ActionCategory.Support;
            this.targetOption    = ActionTargetOption.OneAlly;
        }
        /// <summary>
        ///     Applies a buff to a battle driver
        /// </summary>
        /// <param name="target">The target battle driver</param>
        public void Apply(BaseBattleDriver target)
        {
            this.OnApplication(target);

            int turnDuration = this.TurnDuration;

            target.EndTurnActions.Add(delegate
            {
                --turnDuration;

                if (turnDuration <= 0)
                {
                    this.OnRemoval(target);

                    return(true);
                }

                this.OnTurn(target);

                return(false);
            });
        }
        /// <summary>
        ///     Charges through the target.
        /// </summary>
        /// <param name="target">The target</param>
        /// <returns>An enumator</returns>
        protected IEnumerator DoCharge(BaseBattleDriver target)
        {
            this.User.IsWaitingOnAnimation = true;

            Rigidbody rigidbody = this.User.GetComponent <Rigidbody>();

            Vector3 lookAt = target.transform.position - this.User.transform.position;

            lookAt.Normalize();
            lookAt *= this.velocityMultiplier;

            rigidbody.velocity = lookAt + new Vector3(0.0f, this.yVelocity, 0.0f);

            Func <bool> wait = delegate { return(rigidbody.velocity.y > 0.0f); };

            yield return(new WaitUntil(wait));

            yield return(new WaitWhile(wait));

            rigidbody.velocity = Vector3.zero;

            this.User.IsWaitingOnAnimation = false;
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="ChargeAction"/> class.
 /// </summary>
 /// <param name="user">The BattleDriver which will use this action</param>
 public ChargeAction(BaseBattleDriver user) : base(user)
 {
 }
 /// <summary>
 ///     The method to run when this action is being used.
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void Use(BaseBattleDriver target)
 {
     // Code here
 }
Beispiel #22
0
 /// <summary>
 ///     Called when the buff runs out
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void OnRemoval(BaseBattleDriver target)
 {
     target.SetStat(this.Stat, target.GetStat(this.Stat) / this.Multiplier);
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="HealAction"/> class.
 /// </summary>
 /// <param name="user">The BattleDriver which will use this action</param>
 public HealAction(BaseBattleDriver user) : base(user)
 {
 }
 /// <summary>
 ///     Does a small jump.
 /// </summary>
 /// <param name="battleDriver">The entity that needs to jump</param>
 protected static void DoSmallJump(BaseBattleDriver battleDriver)
 {
     battleDriver.GetComponent <Rigidbody>().velocity = new Vector3(0.0f, 0.5f, 0.0f);
 }
        /// <summary>
        ///     The method to run when this action is being used.
        /// </summary>
        /// <param name="target">The target battle driver</param>
        protected override void Use(BaseBattleDriver target)
        {
            this.DealDamage(target);

            this.User.StartCoroutine(this.DoCharge(target));
        }
        /// <summary>
        ///     The method to run when this action is being used.
        /// </summary>
        /// <param name="target">The target battle driver</param>
        protected override void Use(BaseBattleDriver target)
        {
            this.DealDamage(target);

            new FireDebuff().Apply(target);
        }
 /// <summary>
 ///     The method to run when this action is being used.
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void Use(BaseBattleDriver target)
 {
     target.CurrentHealth += (int)(target.MaximumHealth * this.attackPower);
     HealAction.DoSmallJump(target);
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="BattleAction"/> class.
 ///     Since this is an abstract class, it only serves as a base.
 /// </summary>
 /// <param name="user">The BattleDriver which will use this action</param>
 public BattleAction(BaseBattleDriver user)
 {
     this.User = user;
 }
 /// <summary>
 ///     The method to run on the target when this action is being used.
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected abstract void Use(BaseBattleDriver target);
 /// <summary>
 ///     Called every turn while the buff is applied
 /// </summary>
 /// <param name="target">The target battle driver</param>
 protected override void OnTurn(BaseBattleDriver target)
 {
     target.CurrentHealth -= (int)(target.MaximumHealth * FireDebuff.DamagePerTurn);
 }