public PassiveAbility ConvertTo() { var obj = new PassiveAbility { name = name, description = description, icon = icon }; if (points == 0) { points = 70; } obj.points = points; obj.level = level; obj.xp = xp; obj.skillTree = skillTree.ConvertTo(); foreach (var list in obj.skillTree.nodesByLayer) { foreach (var item in list) { item.ability = obj; } } foreach (var attribute in attributes) { obj.attributes.Add(attribute.ConvertTo()); } return(obj); }
// Start is called before the first frame update void Start() { switch (Type) { case PassiveAbilityType.Harmony: Ability = new Harmony(); break; case PassiveAbilityType.SpiritMaster: Ability = new SpiritMaster(); break; case PassiveAbilityType.UltimateAwakening: Ability = new UltimateAwakening(); break; case PassiveAbilityType.CriticalEye: Ability = new CriticalEye(); break; case PassiveAbilityType.BattleArtMaster: Ability = new BattleArtMaster(); break; case PassiveAbilityType.Dancer: Ability = new Dancer(); break; case PassiveAbilityType.OneMind: Ability = new OneMind(); break; } }
public void CheckLevelPassiveStatBoost() { var passive = new PassiveAbility { level = 1, xp = 0, points = 70f, attributes = new List <AbilityAttribute> { new AbilityAttribute { priority = 100f, type = "boostStat", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "stat", value = "strength" }, new AbilityAttributeParameter { name = "degree", value = 3f } } } } }; passive.GainExperience(ExperienceGainer.xpTable[0]); Assert.AreEqual(passive.level, 2); Assert.Less((float)passive.FindAttribute("boostStat").FindParameter("degree").value, 4f); }
public static string Describe(PassiveAbility ability) { string description = "L" + ability.level.ToString() + " <b>Passive</b>\n"; int count = 0; foreach (var attribute in ability.attributes) { if (attribute.priority < 50 || count > 3) { description += "LATENT - "; } if (simpleDescriptionTable.ContainsKey(attribute.type)) { description += simpleDescriptionTable[attribute.type]; } else if (descriptionTable.ContainsKey(attribute.type)) { description += descriptionTable[attribute.type](ability, attribute); } else { description += attribute.type + " - DESCRIPTION NOT FOUND.\n"; } count++; } return(description); }
private void AddPassiveInfo(PassiveAbility ability) { if (ability == null) { abilityNames[12] = ""; abilityIcons[12] = 65; abilityCDs[12] = 0; abilityDescriptions[12] = ""; abilityIsRanged[12] = false; abilityIsAttack[12] = false; abilityRadii[12] = 0; abilityCurrentCDs[12] = 0; } else { abilityNames[12] = ability.name; abilityIcons[12] = ability.icon; abilityCDs[12] = 0; abilityDescriptions[12] = ability.description; abilityIsRanged[12] = false; abilityIsAttack[12] = false; abilityRadii[12] = 0; abilityCurrentCDs[12] = 0; } }
public static AbilityAttribute Generate(PassiveAbility ability, string attributeType) { for (int i = 0; i < 10000; i++) { AbilityAttribute attribute; if (simpleAttributes.Contains(attributeType)) { attribute = new AbilityAttribute { type = attributeType }; attribute.priority = RNG.Float(12.5f, 100f); attribute.points = AbilityAttributeAppraiser.Appraise(ability, attribute); return(attribute); } attribute = attributes[attributeType](ability); if (attribute != null) { attribute.priority = RNG.Float(12.5f, 100f); attribute.points = AbilityAttributeAppraiser.Appraise(ability, attribute); return(attribute); } } Debug.Log("FAILED TO FIND VALID ATTRIBUTE FOR ABILITY!"); return(null); }
private void CreateNewData() { AssetDatabase.CreateAsset(_passiveAbility, "Assets/Scriptable Objects/Passive Abilities/" + _name + ".asset"); AssetDatabase.SaveAssets(); _passiveAbility = CreateInstance <PassiveAbility>(); }
private void GeneratePassiveAbility() { PassiveAbility ability = null; while (ability == null) { ability = PassiveAbilityGenerator.Generate(); } passiveAbilities.Add(ability); }
private void SetPanel() { GameObject Player = CharacterOpenInfo.Self; var Info = Player.GetComponent <CharacterAbilitiesInfo>(); HPInfo.GetComponent <Text>().text = "HP: " + Player.GetComponent <StatusManager_Character>().CurrentHP.ToString() + "/" + Player.GetComponent <StatusManager_Character>().CurrentMaxHP.ToString(); PowerInfo.GetComponent <Text>().text = "Power: " + Player.GetComponent <StatusManager_Character>().CurrentPower.ToString(); GameObject BattleArtSlot = BattleArtInfo.transform.GetChild(0).gameObject; BattleArt battleArt = Player.GetComponent <CharacterAction>().EquipedBattleArt; if (battleArt != null) { BattleArtSlot.GetComponent <Text>().text = battleArt.name + "(Lv" + battleArt.Level + ")"; BattleArtSlot.transform.Find("Icon").GetComponent <Image>().sprite = battleArt.Icon; for (int i = 1; i <= battleArt.Level; i++) { BattleArtSlot.transform.Find("Description").GetComponent <Text>().text += "-" + battleArt.Description[i - 1]; if (i < battleArt.Level - 1) { BattleArtSlot.transform.Find("Description").GetComponent <Text>().text += "\n"; } } } else { BattleArtSlot.GetComponent <Text>().text = "Empty"; BattleArtSlot.transform.Find("Icon").GetComponent <Image>().sprite = null; BattleArtSlot.transform.Find("Description").GetComponent <Text>().text = ""; } for (int i = 0; i < PassiveAbilityInfo.transform.childCount; i++) { GameObject PassiveAbilitySlot = PassiveAbilityInfo.transform.GetChild(i).gameObject; PassiveAbility passiveAbility = Player.GetComponent <CharacterAction>().EquipedPassiveAbility[i]; if (passiveAbility != null) { PassiveAbilitySlot.GetComponent <Text>().text = passiveAbility.name; PassiveAbilitySlot.transform.Find("Icon").GetComponent <Image>().sprite = passiveAbility.Icon; PassiveAbilitySlot.transform.Find("Description").GetComponent <Text>().text = passiveAbility.Description; } else { PassiveAbilitySlot.GetComponent <Text>().text = "Empty"; PassiveAbilitySlot.transform.Find("Icon").GetComponent <Image>().sprite = null; PassiveAbilitySlot.transform.Find("Description").GetComponent <Text>().text = ""; } } }
public void AttachPassives() { foreach (AbilityModule ab in abilitySlots) { if (ab.passive) { PassiveAbility passiveAbility = ab.GetComponent <PassiveAbility>(); passiveAbility.Attach(); } } }
public void AddPassive(PassiveAbility ability) { var character = GetComponent <Character>(); foreach (var attribute in ability.attributes) { if (attribute.type == "boostStat") { CharacterAttribute.attributes[(string)attribute.FindParameter("stat").value].instances[GetComponent <Character>()].AbilityValue += (float)attribute.FindParameter("degree").value; } } character.CalculateAll(); }
public override Ability Copy() { var newAbility = new PassiveAbility { name = name, description = description, icon = icon }; foreach (var attribute in attributes) { newAbility.attributes.Add(attribute.Copy()); } return(newAbility); }
private static AbilityAttribute GetDamageEnemiesOnScreen(PassiveAbility ability) { int degree = RNG.Int(1, 23); return(new AbilityAttribute { type = "damageEnemiesOnScreen", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "degree", value = (float)degree } } }); }
private static AbilityAttribute GetReduceDamage(PassiveAbility ability) { int degree = RNG.Int(15, 31); return(new AbilityAttribute { type = "reduceDamage", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "degree", value = degree / 100f } } }); }
private static AbilityAttribute GetGoldBoost(PassiveAbility ability) { int degree = RNG.Int(5, 31); return(new AbilityAttribute { type = "goldBoost", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "degree", value = (float)degree } } }); }
public static float Appraise(PassiveAbility ability, AbilityAttribute attribute) { if (simplePassiveValues.ContainsKey(attribute.type)) { return(simplePassiveValues[attribute.type]); } else if (simplePassiveMultipliers.ContainsKey(attribute.type)) { return(simplePassiveMultipliers[attribute.type] * ability.points); } else if (complexPassiveMethods.ContainsKey(attribute.type)) { return(complexPassiveMethods[attribute.type](ability, attribute)); } return(1000000000); }
/// <summary> /// Selects and configures the ability to the player according to the inputted key /// </summary> /// <param name="key">Chosen Ability/ies</param> /// <param name="controller">Player Control</param> public static void Fetch(PlayerAbilities key, PlayerMovement controller) { //don't configure anything if player does not have any abilities if (key == PlayerAbilities.None && abilities != PlayerAbilities.None) { return; } //clear the data if it's used again abilityDict.Clear(); abilityCooldown.Clear(); abilities = key; //small sets of if statement to choose the correct ability (multi-ability is supported) //key.HasFlag detects if it contains a certain ability if (key.HasFlag(PlayerAbilities.DoubleJump)) { //ready the ability type w/ the corresponding class var tag = PlayerAbilities.DoubleJump; var obj = new DoubleJump(); //configures the ability's UnityEvent var e = ConfigureEvent(obj); //add the UnityEvent and cooldown at the dictionary abilityDict.Add(tag, e); abilityCooldown.Add(tag, obj.cooldown); } if (key.HasFlag(PlayerAbilities.Dash)) { var tag = PlayerAbilities.Dash; var obj = new Dash(); var e = ConfigureEvent(obj); abilityDict.Add(tag, e); abilityCooldown.Add(tag, obj.cooldown); controller.flipEvent += obj.OnFlip; } if (key.HasFlag(PlayerAbilities.LongJump)) { passiveAbility = new LongJump(); controller.m_JumpForce = passiveAbility.ApplyPassiveAbility( controller.m_JumpForce); } }
private void OnPlayerPickUpAbility(PlayerPickUpAbility e) { if (e.Ability.GetType() == typeof(PassiveAbility)) { UpdatePassiveAbility = (PassiveAbility)e.Ability; GameObject Player = CharacterOpenInfo.Self; CurrentSlot = 0; for (int i = 0; i < Player.GetComponent <CharacterAction>().EquipedPassiveAbility.Count; i++) { if (Player.GetComponent <CharacterAction>().EquipedPassiveAbility[i] == null) { CurrentSlot = i; return; } } } }
public static string Name(PassiveAbility ability) { var prefix = ""; var baseName = ""; int count = 0; foreach (var attribute in ability.attributes) { if (attribute.priority < 50 || count > 3) { break; } if (simplePrefixesTable.ContainsKey(attribute.type)) { prefix = simplePrefixesTable[attribute.type]; } else if (prefixesTable.ContainsKey(attribute.type)) { prefix = prefixesTable[attribute.type](attribute); } else if (simpleNamesTable.ContainsKey(attribute.type)) { baseName = simpleNamesTable[attribute.type]; } else if (namesTable.ContainsKey(attribute.type)) { baseName = namesTable[attribute.type](attribute); } else { baseName = "NAME NOT FOUND"; } count++; } if (prefix == "") { return(baseName); } else { return(prefix + " " + baseName); } }
private static AbilityAttribute GetBoostStat(PassiveAbility ability) { int degree = RNG.Int(3, 101); var stat = RNG.EnumValue <BaseStat>().ToString(); return(new AbilityAttribute { type = "boostStat", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "degree", value = (float)degree }, new AbilityAttributeParameter { name = "stat", value = stat } } }); }
public static SavedPassiveAbility ConvertFrom(PassiveAbility ability) { var obj = new SavedPassiveAbility(); if (ability == null) { return(null); } obj.icon = ability.icon; obj.name = ability.name; obj.description = ability.description; obj.points = ability.points; obj.level = ability.level; obj.xp = ability.xp; obj.skillTree = SavedSkillTree.ConvertFrom(ability.skillTree); foreach (var attribute in ability.attributes) { obj.attributes.Add(SavedAbilityAttribute.ConvertFrom(attribute)); } return(obj); }
public static int Select(PassiveAbility ability) { int count = 0; foreach (var attribute in ability.attributes) { if (attribute.priority < 50 || count > 3) { break; } if (simpleIconTable.ContainsKey(attribute.type)) { return(simpleIconTable[attribute.type]); } else if (iconTable.ContainsKey(attribute.type)) { return(iconTable[attribute.type](attribute)); } count++; } return(0); }
void AssertNextValue(int i, PassiveAbility ab, double valuePrimary, double?valueAux) { var factor = GetFactor(ab, true); var factorAux = GetFactor(ab, false); if (i < MaxAbilityInc) { Assert.Greater(factor, valuePrimary); if (valueAux != null) { Assert.Greater(factorAux, valueAux.Value); } } else { Assert.AreEqual(factor, valuePrimary); if (valueAux != null) { Assert.AreEqual(factorAux, valueAux.Value); } } }
public void ReplaceAbility(GameObject abi, int slot) { GameObject abilityObj = Instantiate(abi) as GameObject; AbilityModule ability = abilityObj.GetComponent <AbilityModule>(); AbilityModule unequip = abilitySlots[slot - 1]; if (unequip.passive) { PassiveAbility unequipPassive = unequip.GetComponent <PassiveAbility>(); unequipPassive.Detach(); } Destroy(unequip.gameObject); if (ability.passive) { PassiveAbility equipPassive = ability.GetComponent <PassiveAbility>(); equipPassive.Attach(); } abilitySlots[slot - 1] = ability; abilitySlots[slot - 1].cooldownImage = abilityCooldownImages[slot - 1]; abilityCooldownImages[slot - 1].sprite = abilitySlots[slot - 1].abilityCircleIcon; abilityOnCooldownImages[slot - 1].sprite = abilitySlots[slot - 1].abilityCircleIcon; abilitySlots[slot - 1].abilityText = abilityNameTexts[slot - 1]; abilitySlots[slot - 1].bottomImage = abilityBottomImages[slot - 1]; abilityBottomImages[slot - 1].sprite = abilitySlots[slot - 1].abilitySquareIcon; abilitySlots[slot - 1].bottomText = abilityBottomTexts[slot - 1]; //abilitySlots[slot - 1].abilityIcon = abilityIconImages[slot - 1]; abilitySlots[slot - 1].abilityButtonText = abilityButtonTexts[slot - 1]; }
private void Equip() { GameObject Player = CharacterOpenInfo.Self; PassiveAbility Current = Player.GetComponent <CharacterAction>().EquipedPassiveAbility[CurrentSlot]; if (Player.GetComponent <ControlStateManager>().AttachedAbilityObject.GetComponent <AbilityObject>().PriceType == AbilityObjectPriceType.Purchase) { EventManager.instance.Fire(new PlayerGetMoney(-Player.GetComponent <ControlStateManager>().AttachedAbilityObject.GetComponent <AbilityObject>().Price)); } if (Current != null) { Player.GetComponent <ControlStateManager>().AttachedAbilityObject.GetComponent <AbilityObject>().Ability = Current; Player.GetComponent <ControlStateManager>().AttachedAbilityObject.GetComponent <AbilityObject>().PriceType = AbilityObjectPriceType.Drop; Player.GetComponent <ControlStateManager>().AttachedAbilityObject.GetComponent <AbilityObject>().SetSelf(); } else { Destroy(Player.GetComponent <ControlStateManager>().AttachedAbilityObject); } EventManager.instance.Fire(new PlayerEquipPassiveAbility(UpdatePassiveAbility, CurrentSlot)); }
public static PassiveAbility Generate(int level = 1) { for (int i = 0; i < 10000; i++) { var startingPoints = AbilityCalculator.GetPointsFromLevel(level); int numAttributes = RNG.Int(1, 5); var ability = new PassiveAbility { points = startingPoints, level = level }; for (int j = 0; j < numAttributes; j++) { for (int k = 0; k < 10000; k++) { var attribute = AbilityAttributeGenerator.Generate(ability); if (attribute != null && attribute.points <= ability.points) { ability.attributes.Add(attribute); ability.points -= attribute.points; break; } } } ability.points = startingPoints; ability.SortAttributes(); ability.icon = AbilityIconSelector.Select(ability); ability.name = AbilityNamer.Name(ability); ability.description = AbilityDescriber.Describe(ability); if (ability.IsValid()) { ability.skillTree = new AbilitySkillTree(ability); return(ability); } } return(null); }
private static AbilityAttribute BoostElementalDamage(PassiveAbility ability) { int degree = RNG.Int(60, 151); string element = RNG.EnumValue <Element>().ToString(); while (element == "none") { element = RNG.EnumValue <Element>().ToString(); } return(new AbilityAttribute { type = "boostElementalDamage", parameters = new List <AbilityAttributeParameter> { new AbilityAttributeParameter { name = "degree", value = degree / 100f }, new AbilityAttributeParameter { name = "element", value = element } } }); }
static void Main(string[] args) { /* * Test Abilities: * -- General -- * Move: actor moves * Interact: actor interacts with stuff * UseItem: actor uses item * Wait: actor skipps turn * Attack: actor uses base attack * * -- Class Specific -- * Warrior * Warriors' Shout: Target a mighty warcry at an enemy to paralyze them in fear for one turn 3 turn cooldown * * Effects: Target = Change ActorStatus to paralyzed * * Conditions: Caster = Cooldown not in effect Within 3 tiles in any direction * * Enrage: When health dips below 20% user gets a boost to attack damage and agility. * * Effects: Caster = Agility=10% AtkDmg=10% * * Conditions: Caster = health below 20% * * Wizard * Magic Projectile: Shoot a ball of magic damage towards an enemy * * Effects: Target = Damage an enemy or object with magic damage * * Conditions: Caster = Must have enough mana * * Possesion: Gain control of a fallen enemy or ally and gain accces to most of thier abilities. While using posession * caster may not move or use abilities or they will break the link between them and the target. Using possesed units abilities * or moving them will cost caster mana. * * Effects: Target = Toggle control over to player of casted unit * * Conditions: Target = must be in dead status | Caster = Most not use actions, must have mana * * Power Overwhelming: Once per match When your mana reserves hit 0 cast 1 free spell for double its normal damage * IF possesion is used or already in use target of possesion will create an explosion of magic damage. * * Effects: Caster = Clear mana check for 1 spell, double damage special effect on other spell * * Conditions: Caster = mana must be 0, can only be used once per battle * * Rouge * Poison Dart: Throw a poison dart at a target to poison them. Poisoned targets get small reduction to their * agility, dexterity * * Effects: Target = Change status of actor to poisoned inflicting a small amount of damage overtime, if target * is already poisoned no effect will be applied * * Conditions: NONE * * Feign Death: The rouge fakes its own death making it untargetable by enmies for as long as they do not move max of 2 turns * any enemies targeting this character before hand will not longer target it, NOTE any target area skill will * still affect actor * * Effects: Caster = deaggro enemies & make actor unselectable by targeted skills * * Conditions: Caster = NONE * */ #region ConditionsList StatCondition healthDip = new StatCondition(ActorStats.HealthPoints, Evaluation.Less, 20, true); #endregion #region EffectsList StatModifier agilBuff = new StatModifier(ActorStats.Agility, 10, false, true); StatModifier damageBuff = new StatModifier(ActorStats.Strength, 10, false, true); StatModifier damage = new StatModifier(ActorStats.HealthPoints, 5, true, false); #endregion #region AbilitiesList #region Enrage Creation Code PassiveAbility enrage = new PassiveAbility("Enrage", "User explodes with anger", 0, 0, 9999); enrage.InitializeAbility(); enrage.AddEffect(agilBuff, true); enrage.AddEffect(damageBuff, true); enrage.AddEffect(damage, false); enrage.AddCondition(healthDip, true); #endregion #region Warrior's Shout #endregion #endregion Humanoid test = new Humanoid("A", "A", 40, 20, true); test.Class = HumaniodClass.Warrior; test.AssignBaseStats(); test.Agility = 10; test.Strength = 10; test.LearnedAbilities.Add(enrage); #region TEST CODE string availableAbilities = ""; foreach (var item in test.GetAvailableAbilites()) { int casterConditions = item.CasterConditions.Count; int targetConditions = item.TargetConditions.Count; availableAbilities += (item.Name + ": Conditions -- Caster =" + casterConditions + " Target = " + targetConditions + "\n"); } Console.WriteLine("===== {0} =====\n* Available Abilitites: {1}", test.Name, availableAbilities); Console.WriteLine("Press any key to continue"); Console.Read(); test.HealthPoints = 7; foreach (var item in test.GetAvailableAbilites()) { int casterConditions = item.CasterConditions.Count; int targetConditions = item.TargetConditions.Count; availableAbilities += (item.Name + ": Conditions -- Caster =" + casterConditions + " Target = " + targetConditions + "\n"); } Console.WriteLine("===== {0} =====\n* Available Abilitites: {1}", test.Name, availableAbilities); #endregion }
float GetFactor(PassiveAbility ab, bool primary) { return(ab.GetFactor(primary)); }
public void UnregisterListener(PassiveAbility passiveAbility) { passiveAbilities.Remove(passiveAbility); }