Esempio n. 1
0
 public int bite(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= biteAbility.mana;
     int biteDamageAfterArmor = biteAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(biteDamageAfterArmor - 2, biteDamageAfterArmor + 2);
 }
Esempio n. 2
0
        public int attack(HeroAttributes hero)
        {
            Random damageDealt         = new Random();
            int    minDamageAfterArmor = minDamage * (100 - hero.ArmorWithEquipment()) / 100;
            int    maxDamageAfterArmor = maxDamage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(minDamageAfterArmor, maxDamageAfterArmor));
        }
Esempio n. 3
0
        public int smash(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= smashAbility.mana;
            int smashDamageAfterArmor = smashAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(smashDamageAfterArmor - 1, smashDamageAfterArmor + 1));
        }
Esempio n. 4
0
        public int lightning(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= lightningAbility.mana;
            int lightningDamageAfterArmor = lightningAbility.damage * (100 - hero.LightningResistanceWithEquipment()) / 100;

            return(damageDealt.Next(lightningDamageAfterArmor - 8, lightningDamageAfterArmor + 8));
        }
Esempio n. 5
0
        public int boulderbash(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= boulderBashAbility.mana;
            int boulderBashDamageAfterArmor = boulderBashAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(boulderBashDamageAfterArmor - 5, boulderBashDamageAfterArmor + 5));
        }
Esempio n. 6
0
        public int quake(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= quakeAbility.mana;
            int quakeDamageAfterArmor = quakeAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(quakeDamageAfterArmor - 3, quakeDamageAfterArmor + 3));
        }
Esempio n. 7
0
        public int fireblast(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= fireBlastAbility.mana;
            int fireblastDamageAfterArmor = fireBlastAbility.damage * (100 - hero.FireResistanceWithEquipment()) / 100;

            return(damageDealt.Next(fireblastDamageAfterArmor - 2, fireblastDamageAfterArmor + 2));
        }
Esempio n. 8
0
        public int assault(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= assaultAbility.mana;
            int assaultDamageAfterArmor = assaultAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(assaultDamageAfterArmor - 7, assaultDamageAfterArmor + 7));
        }
Esempio n. 9
0
        public int backstab(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= backstabAbility.mana;
            int backstabDamageAfterArmor = backstabAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(backstabDamageAfterArmor - 8, backstabDamageAfterArmor + 8));
        }
Esempio n. 10
0
        public int flurry(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= flurryAbility.mana;
            int flurryDamageAfterArmor = flurryAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(flurryDamageAfterArmor - 4, flurryDamageAfterArmor + 4));
        }
Esempio n. 11
0
        public int bite(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= biteAbility.mana;
            int biteDamageAfterArmor = biteAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(biteDamageAfterArmor - 2, biteDamageAfterArmor + 2));
        }
Esempio n. 12
0
    void Awake()
    {
        clearTempData();
        GameObject hero = GameObject.Find("Hero").gameObject;

        HA = hero.GetComponent <HeroAttributes>();
        GM = this.GetComponent <GameManager>();
        UM = this.GetComponent <UIManager>();
    }
Esempio n. 13
0
        public int stomp(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= stopmAbility.mana;
            int stompDamageAfterArmor = stopmAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;

            return(damageDealt.Next(stompDamageAfterArmor - 7, stompDamageAfterArmor + 7));
        }
Esempio n. 14
0
        public int charge(HeroAttributes hero)
        {
            Random damageDealt = new Random();

            mana -= chargeAbility.mana;
            int chargeDamageAfterArmor = chargeAbility.damage * (100 - hero.baseArmor) / 100;

            return(damageDealt.Next(chargeDamageAfterArmor - 5, chargeDamageAfterArmor + 5));
        }
Esempio n. 15
0
    void Start()
    {
        GameObject hero = GameObject.Find("Hero").gameObject;

        HA  = hero.GetComponent <HeroAttributes>();
        H   = hero.GetComponent <Hero>();
        AuM = this.GetComponent <AudioManager>();
        GM  = this.GetComponent <GameManager>();
        GDM = this.GetComponent <GameDataManager>();
        DM  = this.GetComponent <DialogManager>();
        UM  = this.GetComponent <UIManager>();
        FM  = this.GetComponent <FightManager>();
    }
Esempio n. 16
0
    void Start()
    {
        GM           = this.GetComponent <GameManager>();
        GDM          = this.GetComponent <GameDataManager>();
        AM           = this.GetComponent <ActionManager>();
        AuM          = this.GetComponent <AudioManager>();
        hero         = GameObject.Find("Hero").gameObject.GetComponent <Hero>();
        HA           = hero.gameObject.GetComponent <HeroAttributes>();
        displayScale = Screen.width / 400f;
        //摇杆位置的自适应
        buttonController = GameObject.Find("Button_Controller").gameObject.GetComponent <Button>();
        canvasTrans      = GameObject.Find("Canvas").GetComponent <Transform>();
        RectTransform PanelInfoRT = GameObject.Find("Panel_Info").gameObject.GetComponent <RectTransform>();

        panelinfoCenterX = Screen.width / 2;
        beishu           = canvasTrans.localScale.x / 0.023075f;
        panelinfoCenterY = PanelInfoRT.rect.height * beishu / 2;
    }
        internal HeroAttributes FetchAttributes(string heroReference)
        {
            HtmlNode root = mainController.HtmlDocumentController.GetDotabuffHeroRoot(heroReference);

            string strength     = root.SelectSingleNode(HeroPath.Attributes.Main.Strength.Value).InnerText;
            string agility      = root.SelectSingleNode(HeroPath.Attributes.Main.Agility.Value).InnerText;
            string intelligence = root.SelectSingleNode(HeroPath.Attributes.Main.Intelligence.Value).InnerText;

            string[] strengthSplit     = strength.Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);
            string[] agilitySplit      = agility.Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);
            string[] intelligenceSplit = intelligence.Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);

            HeroAttributes attributes = new HeroAttributes();

            attributes.Strength     = float.Parse(strengthSplit[0].Replace(".", ","));
            attributes.Agility      = float.Parse(agilitySplit[0].Replace(".", ","));
            attributes.Intelligence = float.Parse(intelligenceSplit[0].Replace(".", ","));

            attributes.StrengthGain     = float.Parse(strengthSplit[1].Replace(".", ","));
            attributes.AgilityGain      = float.Parse(agilitySplit[1].Replace(".", ","));
            attributes.IntelligenceGain = float.Parse(intelligenceSplit[1].Replace(".", ","));


            string movementSpeed  = root.SelectSingleNode(HeroPath.Attributes.Other.MovementSpeed.Value).InnerText;
            string sightRange     = HtmlEntity.DeEntitize(root.SelectSingleNode(HeroPath.Attributes.Other.SightRange.Value).InnerText);
            string armor          = root.SelectSingleNode(HeroPath.Attributes.Other.Armor.Value).InnerText;
            string baseAttackTime = root.SelectSingleNode(HeroPath.Attributes.Other.BaseAttackTime.Value).InnerText;
            string damage         = root.SelectSingleNode(HeroPath.Attributes.Other.Damage.Value).InnerText;
            string attackPoint    = root.SelectSingleNode(HeroPath.Attributes.Other.AttackPoint.Value).InnerText;

            string[] sightRangeSplit = sightRange.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
            string[] damageSplit     = damage.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries);

            attributes.MovementSpeed   = int.Parse(movementSpeed);
            attributes.SightRangeDay   = int.Parse(sightRangeSplit[0]);
            attributes.SightRangeNight = int.Parse(sightRangeSplit[1]);
            attributes.Armor           = float.Parse(armor);
            attributes.BaseAttackTime  = float.Parse(baseAttackTime);
            attributes.Damage          = new Damage(int.Parse(damageSplit[0]), int.Parse(damageSplit[1]));
            attributes.AttackPoint     = float.Parse(attackPoint);

            return(attributes);
        }
Esempio n. 18
0
 public static void PrintInfo(HeroAttributes[] heroes, string character)
 {
     int currentHeroIndex = -1;
     for (int i = 0; i < heroes.Length; i++)
     {
         if(character.ToLower().Equals(heroes[i].name.ToLower()))
         {
             currentHeroIndex = i;
             break;
         }
     }
     Type type = heroes[currentHeroIndex].GetType(); // Get the class of the current hero
     FieldInfo[] properties = type.GetFields(BindingFlags.Public | BindingFlags.Instance); // Get all of the fields of the current hero
     GameConsole.currentLog.Append("\n");
     foreach (FieldInfo property in properties)
     {
         Type propertyType = property.GetValue(heroes[currentHeroIndex]).GetType();
         if (propertyType == typeof(ItemPool.Item)) // If the current field is an item we need to print it diffrently
         {
             ItemPool.Item item = FindItem(property.GetValue(heroes[currentHeroIndex]), propertyType);
             GameConsole.currentLog.Append("\t" + property.Name + ": ");
             PrintItem(item);
         }
         else
         {
             GameConsole.currentLog.Append("\t" + property.Name + ": " + property.GetValue(heroes[currentHeroIndex]).ToString() + "\n");
         }
     }
     var abilities = type.GetFields(BindingFlags.Public | BindingFlags.Static);
     GameConsole.currentLog.Append("\tAbilities: \n");
     foreach (var ability in abilities)
     {
         Type abilityType = ability.GetValue(abilities).GetType();
         var abilityInfos = abilityType.GetFields();
         GameConsole.currentLog.Append("\t\t|" + ability.Name + " | ");
         foreach (var abilityInfo in abilityInfos)
         {
             GameConsole.currentLog.Append(abilityInfo.Name + ": " + abilityInfo.GetValue(ability.GetValue(abilities)).ToString() + " | ");
         }
         GameConsole.currentLog.Append("\n");
     }
     GameConsole.currentLog.Append("\n");
 }
Esempio n. 19
0
 private static void AIAction()
 {
     for (int i = 0; i < enemies.Count; i++)
     {
         Random random = new Random();
         int randomHeroIndex;
         do
         {
             randomHeroIndex = random.Next(0, heroes.Length);
         }
         while (heroes[randomHeroIndex].health <= 0); //Keep choosing a new random hero if the random hero we are attacking is dead
         var methodNames = enemies[i].GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance |
             BindingFlags.DeclaredOnly).Select(x => x.Name).Distinct().OrderBy(x => x); // We take all of the methods the current enemy has that have not been inherited remove duplicates and order them
         List<MethodInfo> abilities = new List<MethodInfo>(); //The abilities the enemy has
         abilities.Add(enemies[i].GetType().GetMethod("attack")); //All enemies have attack by default
         foreach (var methodName in methodNames)
         {
             abilities.Add(enemies[i].GetType().GetMethod(methodName.ToLower())); //Add the method to the ability list
             int currentMana = enemies[i].mana;
             abilities[abilities.Count - 1].Invoke(enemies[i], new object[] { heroes[randomHeroIndex] }); //Try to use the ability by also draining mana
             if (enemies[i].mana < 0) //If after the enemy has used the ability the current enemy has less than 0 mana then he doesn't have mana for that ability
             {
                 abilities.RemoveAt(abilities.Count - 1); //We remove the ability from the list
             }
             enemies[i].mana = currentMana;
         }
         int randomAbilityIndex = random.Next(0, abilities.Count); //Use a random ability from the list
         float startingHealth = heroes[randomHeroIndex].health;
         HeroAttributes test = new HeroAttributes();
         heroes[randomHeroIndex].health = heroes[randomHeroIndex].health - //Reduce the hero's health with the damage from the ability
             (int)abilities[randomAbilityIndex].Invoke(enemies[i], new object[] { heroes[randomHeroIndex] }); //Invoke the ability which will return an int value of the damage it deals
         if(heroes[randomHeroIndex].health < 0)
         {
             heroes[randomHeroIndex].health = 0;
         }
         currentLog.Append(enemies[i].name + " hits " + heroes[randomHeroIndex].name + " for " + (startingHealth - heroes[randomHeroIndex].health) + " damage\n");
     }
 }
Esempio n. 20
0
 public int charge(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= chargeAbility.mana;
     int chargeDamageAfterArmor = chargeAbility.damage * (100 - hero.baseArmor) / 100;
     return damageDealt.Next(chargeDamageAfterArmor - 5, chargeDamageAfterArmor + 5);
 }
Esempio n. 21
0
 public int stomp(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= stopmAbility.mana;
     int stompDamageAfterArmor = stopmAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(stompDamageAfterArmor - 7, stompDamageAfterArmor + 7);
 }
Esempio n. 22
0
 public int boulderbash(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= boulderBashAbility.mana;
     int boulderBashDamageAfterArmor = boulderBashAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(boulderBashDamageAfterArmor - 5, boulderBashDamageAfterArmor + 5);
 }
Esempio n. 23
0
 public int quake(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= quakeAbility.mana;
     int quakeDamageAfterArmor = quakeAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(quakeDamageAfterArmor - 3, quakeDamageAfterArmor + 3);
 }
Esempio n. 24
0
 public int assault(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= assaultAbility.mana;
     int assaultDamageAfterArmor = assaultAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(assaultDamageAfterArmor - 7, assaultDamageAfterArmor + 7);
 }
Esempio n. 25
0
 public int attack(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     int minDamageAfterArmor = minDamage * (100 - hero.ArmorWithEquipment()) / 100;
     int maxDamageAfterArmor = maxDamage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(minDamageAfterArmor, maxDamageAfterArmor);
 }
Esempio n. 26
0
 public int smash(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= smashAbility.mana;
     int smashDamageAfterArmor = smashAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(smashDamageAfterArmor - 1, smashDamageAfterArmor + 1);
 }
Esempio n. 27
0
 public int lightning(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= lightningAbility.mana;
     int lightningDamageAfterArmor = lightningAbility.damage * (100 - hero.LightningResistanceWithEquipment()) / 100;
     return damageDealt.Next(lightningDamageAfterArmor - 8, lightningDamageAfterArmor + 8);
 }
Esempio n. 28
0
 public int fireblast(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= fireBlastAbility.mana;
     int fireblastDamageAfterArmor = fireBlastAbility.damage * (100 - hero.FireResistanceWithEquipment()) / 100;
     return damageDealt.Next(fireblastDamageAfterArmor - 2, fireblastDamageAfterArmor + 2);
 }
Esempio n. 29
0
 public int backstab(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= backstabAbility.mana;
     int backstabDamageAfterArmor = backstabAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(backstabDamageAfterArmor - 5, backstabDamageAfterArmor + 5);
 }
Esempio n. 30
0
 //Called before Start
 void Awake()
 {
     heroAttributes = GetComponent <HeroAttributes>();            //Grab this instance's hero attributes script to mess with
 }
Esempio n. 31
0
 public int flurry(HeroAttributes hero)
 {
     Random damageDealt = new Random();
     mana -= flurryAbility.mana;
     int flurryDamageAfterArmor = flurryAbility.damage * (100 - hero.ArmorWithEquipment()) / 100;
     return damageDealt.Next(flurryDamageAfterArmor - 4, flurryDamageAfterArmor + 4);
 }