示例#1
0
        public void UseSpecialAttack(GameObject buttonPressed)
        {
            if (this.notificationPopup.activeInHierarchy || this.duelEnded)
            {
                return;
            }

            int            abilityIndex = int.Parse(buttonPressed.name.Substring(0, buttonPressed.name.IndexOf('_')));
            SpecialAbility usedAbility  = (SpecialAbility)this.playerActivePokemon.Abilities[abilityIndex];

            if (usedAbility.CurrentCooldown > 0)
            {
                ShowNotification();
                return;
            }
            else
            {
                if (SpecialAbility.TargetIsHit(usedAbility))
                {
                    this.actionMessage = usedAbility.HitMessage;

                    if (usedAbility.GetType().BaseType == typeof(DamageAbility))
                    {
                        this.actionMessage += string.Format(" The target suffers {0} damage.", usedAbility.AbilityPower);
                        ((DamageAbility)usedAbility).Hit(this.enemyActivePokemon);

                        if (this.enemyActivePokemon.CurrentHealth <= 0)
                        {
                            this.enemyActivePokemon.IsAlive = false;
                            EnemySelectPokemon();
                        }
                    }
                    else if (usedAbility.GetType().BaseType == typeof(HealAbility))
                    {
                        this.actionMessage += string.Format(" The target recieves {0} health.", usedAbility.AbilityPower);
                        ((HealAbility)usedAbility).Heal(this.playerActivePokemon);
                    }
                }
                else
                {
                    this.actionMessage = usedAbility.MissMessage;
                }

                usedAbility.CurrentCooldown = usedAbility.BaseCooldown;
                this.specialActionsButtons.SetActive(false);
                ShowActionResult(this.actionMessage);
                UpdatePlayerStats();
                UpdateEnemyStats();
            }
        }
示例#2
0
        private void EnemyDoSpecialAbility(IList <IAbility> availableAbilities)
        {
            int            abilityIndex = this.randomNumberGenerator.Next(0, availableAbilities.Count);
            SpecialAbility usedAbility  = (SpecialAbility)availableAbilities[abilityIndex];

            if (SpecialAbility.TargetIsHit(usedAbility))
            {
                this.actionMessage = usedAbility.HitMessage;
                this.actionMessage = this.actionMessage.Replace("enemy", "player");

                if (usedAbility.GetType().BaseType == typeof(DamageAbility))
                {
                    this.actionMessage += string.Format(" The target suffers {0} damage.", usedAbility.AbilityPower);
                    ((DamageAbility)usedAbility).Hit(this.playerActivePokemon);

                    if (this.playerActivePokemon.CurrentHealth <= 0)
                    {
                        this.playerActivePokemon.IsAlive = false;
                        PlayerSelectPokemon();
                    }
                }
                else if (usedAbility.GetType().BaseType == typeof(HealAbility))
                {
                    this.actionMessage += string.Format(" The target recieves {0} health.", usedAbility.AbilityPower);
                    ((HealAbility)usedAbility).Heal(this.enemyActivePokemon);
                }
            }
            else
            {
                this.actionMessage = usedAbility.MissMessage;
            }

            usedAbility.CurrentCooldown = usedAbility.BaseCooldown;
            ShowActionResult(this.actionMessage);
            UpdatePlayerStats();
            UpdateEnemyStats();
        }