public override void Use(Bunny user, Fighter[] targets)
        {
            // Select a random damage multiplier and damage all targets
            float multiplier = Random.Range(minMultiplier, maxMultiplier);

            user.DoDamage(targets, multiplier);
        }
Esempio n. 2
0
        /// <summary>
        /// Set the number of active skill buttons and the text on each button.
        /// </summary>
        /// <param name="bunny">The bunny to set skill buttons for.</param>
        private void SetSkillButtons(Bunny bunny)
        {
            string[] availableSkills = bunny.GetAvailableSkillStrings();

            for (int i = 0; i < skillButtons.Length; i++)
            {
                Button button = skillButtons[i];

                if (i < availableSkills.Length)
                {
                    // Activate button
                    button.GetComponentInChildren <TMP_Text>().text = availableSkills[i];
                    if (!button.gameObject.activeSelf)
                    {
                        skillButtons[i].gameObject.SetActive(true);
                    }
                    button.interactable = bunny.CanUseSkill(i);
                }
                else if (button.gameObject.activeSelf)
                {
                    // Hide button
                    skillButtons[i].gameObject.SetActive(false);
                }
            }
        }
 /// <summary>
 /// Subscribe to a bunny's events.
 /// </summary>
 private void SubscribeToBunnyEvents(Bunny bunny)
 {
     bunny.OnDoDamage          += Bunny_OnDoDamage;
     bunny.OnFullRestore       += Bunny_OnFullRestore;
     bunny.OnHealthChange      += Bunny_OnHealthChange;
     bunny.OnSkillPointsChange += Bunny_OnSkillPointsChange;
 }
        public override void Use(Bunny user, Fighter[] targets)
        {
            // Select a random enemy to damage
            int targetIndex = Random.Range(0, targets.Length);

            user.DoDamage(targets[targetIndex], multiplier);
        }
 /// <summary>
 /// Unsubscribe from a bunny's events.
 /// </summary>
 private void UnsubscribeFromBunnyEvents(Bunny bunny)
 {
     bunny.OnDoDamage          -= Bunny_OnDoDamage;
     bunny.OnFullRestore       -= Bunny_OnFullRestore;
     bunny.OnHealthChange      -= Bunny_OnHealthChange;
     bunny.OnSkillPointsChange -= Bunny_OnSkillPointsChange;
 }
Esempio n. 6
0
        /// <summary>
        /// Insert a skill turn during which a bunny uses a special skill.
        /// </summary>
        /// <param name="skillIndex">The index of the skill to use.</param>
        public void InsertBunnySkillTurn(int skillIndex)
        {
            Bunny user = SelectedBunny;

            // Make sure bunny can use the selected skill
            if (!user.CanUseSkill(skillIndex))
            {
                return;
            }

            // Create turn
            Turn turn;

            if (user.Skills[skillIndex].Target == Globals.FighterType.Bunny)
            {
                turn = new Turn(user, currentBunnies, string.Format(skillMessage, user.name, user.Skills[skillIndex].Name), () => user.UseSkill(skillIndex, currentBunnies));
            }
            else
            {
                turn = new Turn(user, GetAliveEnemies(), string.Format(skillMessage, user.name, user.Skills[skillIndex].Name), () => user.UseSkill(skillIndex, GetAliveEnemies()));
            }

            // Insert turn
            turnCollection.Insert(turn);

            // Move to next input
            NextInput();
        }
Esempio n. 7
0
 public BattleEventArgs(Bunny[] bunnies, Enemy[] enemies, Bunny selectedBunny, Turn currentTurn, bool isFinalWave)
 {
     this.bunnies       = bunnies;
     this.enemies       = enemies;
     this.selectedBunny = selectedBunny;
     this.currentTurn   = currentTurn;
     this.isFinalWave   = isFinalWave;
 }
Esempio n. 8
0
        /// <summary>
        /// Insert a standard attack turn during which a bunny attacks a single enemy.
        /// </summary>
        /// <param name="enemyIndex">The index of the enemy to target.</param>
        public void InsertBunnyAttackTurn(int enemyIndex)
        {
            // Create and insert turn
            Bunny user   = SelectedBunny;
            Enemy target = currentEnemies[enemyIndex];
            Turn  turn   = new Turn(user, target, string.Format(attackMessage, user.name, target.name), () => user.DoDamage(target));

            turnCollection.Insert(turn);

            // Move to next input
            NextInput();
        }
Esempio n. 9
0
        /// <summary>
        /// Get the actor associated with a specific bunny.
        /// </summary>
        /// <param name="bunny">The bunny to get the actor for.</param>
        /// <returns>The actor associated with this bunny. Null if none is found.</returns>
        private BunnyActor GetActor(Bunny bunny)
        {
            foreach (BunnyActor bunnyActor in bunnyActors)
            {
                if (bunnyActor.Fighter.Equals(bunny))
                {
                    return(bunnyActor);
                }
            }

            return(null);
        }
Esempio n. 10
0
        /// <summary>
        /// Insert a defend turn during which a bunny takes reduced damage.
        /// </summary>
        public void InsertBunnyDefendTurn()
        {
            // Create and insert turn
            Bunny user = SelectedBunny;

            user.IsDefending = true;
            Turn turn = new Turn(user, user, string.Format(defendMessage, user.name), null);

            turnCollection.Insert(turn);

            // Move to next input
            NextInput();
        }
Esempio n. 11
0
        /// <summary>
        /// Set and display the options for a specific bunny.
        /// </summary>
        /// <param name="bunny">The bunny to set options for.</param>
        public void SetOptions(Bunny bunny)
        {
            bunnyName = bunny.name;
            DisplayOptionPrompt();

            // Set skills
            if (bunny.GetAvailableSkillStrings().Length == 0)
            {
                skillOptionButton.SetActive(false);
            }
            else
            {
                skillOptionButton.SetActive(true);
                SetSkillButtons(bunny);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Set and display the stats of multiple bunnies.
        /// </summary>
        /// <param name="bunnies">The bunnies to display stats for.</param>
        public void SetPlayerStatText(Bunny[] bunnies)
        {
            string stats = string.Empty;

            for (int i = 0; i < bunnies.Length; i++)
            {
                // Add a new line of stat text
                Bunny bunny = bunnies[i];
                stats += string.Format("{0, -16} HP:{1, 3} SP:{2, 3}", bunny.name, bunny.CurrentHealth, bunny.CurrentSkillPoints);
                if (i < bunnies.Length - 1)
                {
                    stats += "\n\n";
                }
            }

            playerStatText.text = stats;
        }
        /// <summary>
        /// Create bunny objects from save data.
        /// </summary>
        private void CreateBunnies()
        {
            SaveData save = SaveData.current;

            Party = new Bunny[4];

            // Create bunny objects
            Bunnight       = new Bunny(Globals.BunnyType.Bunnight, save.bunnightName, save.bunnightExp);
            Bunnecromancer = new Bunny(Globals.BunnyType.Bunnecromancer, save.bunnecromancerName, save.bunnecromancerExp);
            Bunnurse       = new Bunny(Globals.BunnyType.Bunnurse, save.bunnurseName, save.bunnurseExp);
            Bunneerdowell  = new Bunny(Globals.BunnyType.Bunneerdowell, save.bunneerdowellName, save.bunneerdowellExp);

            // Store bunnies in array
            Party[(int)Globals.BunnyType.Bunnight]       = Bunnight;
            Party[(int)Globals.BunnyType.Bunnecromancer] = Bunnecromancer;
            Party[(int)Globals.BunnyType.Bunnurse]       = Bunnurse;
            Party[(int)Globals.BunnyType.Bunneerdowell]  = Bunneerdowell;
        }
Esempio n. 14
0
        /// <summary>
        /// Insert a defeat turn for a bunny and lose the battle if all bunnies are defeated.
        /// </summary>
        /// <param name="bunny">The defeated bunny.</param>
        private void PushBunnyDefeatTurn(Bunny bunny)
        {
            // Remove turns
            turnCollection.RemoveUserTurns(bunny);
            turnCollection.RemoveTargetTurns(bunny);

            // Create and push defeat turn
            BunnyActor bunnyActor = GetActor(bunny);
            Turn       turn       = new Turn(bunny, string.Format(defeatMessage, bunny.name), () => bunnyActor.Defeat());

            turnCollection.Push(turn);

            if (GetAliveBunnies().Length == 0)
            {
                // Bunnies have lost
                turnCollection.RemoveEnemyTurns();
                turn = new Turn(bunny, loseMessage, null);
                turnCollection.Append(turn);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Display the stats for a selected bunny.
        /// </summary>
        /// <param name="typeIndex">The integer value of the bunny type to display stats for.</param>
        public void DisplayBunnyStats(int typeIndex)
        {
            Globals.BunnyType type       = (Globals.BunnyType)typeIndex;
            Bunny             bunny      = null;
            string            typeString = "";

            // Set bunny and type string
            switch (type)
            {
            case Globals.BunnyType.Bunnight:
                bunny      = gameManager.Bunnight;
                typeString = "BUNNIGHT";
                break;

            case Globals.BunnyType.Bunnecromancer:
                bunny      = gameManager.Bunnecromancer;
                typeString = "BUNNECROMANCER";
                break;

            case Globals.BunnyType.Bunnurse:
                bunny      = gameManager.Bunnurse;
                typeString = "BUNNURSE";
                break;

            case Globals.BunnyType.Bunneerdowell:
                bunny      = gameManager.Bunneerdowell;
                typeString = "BUNNE'ER-DO-WELL";
                break;
            }

            // Set stat text
            string stats = $"{bunny.name} the {typeString}" + "\n\n"
                           + $"LEVEL: {bunny.Level}" + SPACER + $"EXPERIENCE: {bunny.Experience}" + "\n\n"
                           + $"HEALTH: {bunny.MaxHealth}" + SPACER + $"SKILL: {bunny.MaxSkillPoints}" + "\n\n"
                           + $"ATTACK: {new string('*', bunny.Attack)}" + SPACER
                           + $"DEFENSE: {new string('*', bunny.Defense)}" + SPACER
                           + $"SPEED: {new string('*', bunny.Speed)}";

            statText.text = stats;
        }
Esempio n. 16
0
        /// <summary>
        /// Generate a randomly-selected turn for this enemy actor.
        /// </summary>
        /// <param name="bunnies">All bunnies that this enemy can attack.</param>
        /// <param name="enemies">All enemies that this enemy can heal, including itself.</param>
        public Turn GetTurn(Bunny[] bunnies, Enemy[] enemies)
        {
            EnemyTurnType[] availableTurnTypes = GetAvailableTurnTypes(bunnies, enemies);

            if (availableTurnTypes.Length == 0)
            {
                Debug.LogError("Enemy has no available turns!");
                return(null);
            }

            EnemyTurnType selectedTurn = availableTurnTypes[UnityEngine.Random.Range(0, availableTurnTypes.Length)];

            switch (selectedTurn)
            {
            case EnemyTurnType.SingleAttack:
                Bunny bunny = bunnies[UnityEngine.Random.Range(0, bunnies.Length)];
                return(new Turn(this, bunny, $"{name} attacks {bunny.name}!", () => DoDamage(bunny)));

            case EnemyTurnType.MultiAttack:
                return(new Turn(this, bunnies, $"{name} attacks the whole party!", () => DoDamage(bunnies)));

            case EnemyTurnType.SingleHeal:
                return(new Turn(this, this, $"{name} healed itself!", () => Heal(HEAL_AMOUNT)
                                ));

            case EnemyTurnType.MultiHeal:
                return(new Turn(this, enemies, $"{name} healed all enemies!", () =>
                {
                    foreach (Enemy enemy in enemies)
                    {
                        enemy.Heal(HEAL_AMOUNT / 2);
                    }
                }
                                ));

            default:
                return(null);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Insert a level up turn for a bunny.
        /// </summary>
        /// <param name="bunny">The bunny that has leveled up.</param>
        private void PushLevelUpTurn(Bunny bunny)
        {
            Turn turn = new Turn(bunny, string.Format(levelUpMessage, bunny.name), () => bunny.FullRestore());

            turnCollection.Push(turn);
        }