public async Task <BaseAbility> UpdateBaseAbility(BaseAbility baseAbility) { var result = await _dbContext.BaseAbilities .FirstOrDefaultAsync(a => a.Id == baseAbility.Id); if (result != null) { result.Name = baseAbility.Name; result.Description = baseAbility.Description; result.HtmlDescription = baseAbility.HtmlDescription; result.AdvancesSkills = baseAbility.AdvancesSkills; result.IsProfessional = baseAbility.IsProfessional; result.ModifiesBaseTrainingValues = baseAbility.ModifiesBaseTrainingValues; result.SupportsBaseSkills = baseAbility.SupportsBaseSkills; result.UsesBaseAttributes = baseAbility.UsesBaseAttributes; result.Type = baseAbility.Type; //foreach (var value in baseAbility.ModifiesBaseTrainingValues) //{ // _dbContext.Entry(value).State = EntityState.Unchanged; //} _dbContext.Entry(baseAbility.ModifiesBaseTrainingValues).State = EntityState.Unchanged; return(result); } return(null); }
public static int calculateDamage(GameObject caster, GameObject target, BaseAbility ability) { int calculatedDamage; int casterPower; int targetResist; int abilityBasePower = ability.baseDamage; if (ability.damageType == 2) { casterPower = caster.GetComponent <CombatCharacterController>().magAtk; targetResist = target.GetComponent <CombatCharacterController>().magResist; } else { casterPower = caster.GetComponent <CombatCharacterController>().physAtk; targetResist = target.GetComponent <CombatCharacterController>().physResist; } if (targetResist <= 0) { targetResist = 1; } if (casterPower <= 0) { casterPower = 1; } calculatedDamage = (casterPower - targetResist / 2) * abilityBasePower / 100; return(calculatedDamage); }
// Register ability private void RegisterAbility(BaseAbility ability) { // Run function for when the ability is added ability.OnAbilityAdd(); // Add ability to dictionary _abilities.Add(ability.GetName, ability); }
public void CheckAbiliteisForStatusEffects(BaseAbility usedAbility) { switch (usedAbility.AbilityStatusEffect.StatusEffectName) { case ("Burn"): if (TryToApplyStatusEffect(usedAbility)) { Debug.Log("RETURN TRUE, APPLIED EFFECT"); TurnBasedCombatStateMachine.statusEffectBaseDamage = (int)usedAbility.AbilityStatusEffect.StatusEffectPower; Debug.Log(TurnBasedCombatStateMachine.statusEffectBaseDamage); } else { TurnBasedCombatStateMachine.statusEffectBaseDamage = 0; } Debug.Log("Try To Apply Effect. Ability Has: " + usedAbility.AbilityStatusEffect.StatusEffectApplyPercentage + "% Chance"); TurnBasedCombatStateMachine.currentState = TurnBasedCombatStateMachine.BattleStates.CALULATEDAMAGE; break; default: Debug.LogError("ERROR IN STATUS EFFECT"); break; } }
public void CreateTrackingProjectile(BaseEntity source, BaseAbility ability, ProjectileItemParams param) { var projectile = new ProjectileItem(source, ability, param); projectile.ProjectileType = ProjectileType.Tracking; projectiles.Add(projectile); }
public void Input1(BaseAbility ButtonAction)//attack button { HeroChoice.Attacker = HeroesToManage[0].name; HeroChoice.AttackersGameObject = HeroesToManage[0]; HeroChoice.Type = "Hero"; HeroChoice.chosenAttack = ButtonAction; ActionPanel.SetActive(false); TargetSelectPanel.SetActive(true); if (HeroChoice.chosenAttack.abilityType == "Attack") { EnemyButtons(); } if (HeroChoice.chosenAttack.abilityType == "Buff") { HeroButtons(); } if (HeroChoice.chosenAttack.abilityType == "Stance") { Input2(HeroChoice.AttackersGameObject); } if (HeroChoice.chosenAttack.abilityType == "Aura") { Input2(HeroChoice.AttackersGameObject); } if (HeroChoice.chosenAttack.abilityType == "Cleave") { Input2(EnemiesInBattle[0]); } }
public void CheckAbilityForStatusEffect(BaseAbility usedAbility) { switch (usedAbility.AbilityStatusEffect.StatusEffectName) { case ("Harassed"): if (ApplyStatusEffect(usedAbility)) { TurnBasedCombatStateMachine.statusEffectBaseDamage = usedAbility.AbilityStatusEffect.StatusEffectDamage; } else { TurnBasedCombatStateMachine.statusEffectBaseDamage = 0; } TurnBasedCombatStateMachine.currentState = TurnBasedCombatStateMachine.BattleStates.CALCULATE_DAMAGE; break; case ("Empty"): if (ApplyStatusEffect(usedAbility)) { TurnBasedCombatStateMachine.statusEffectBaseDamage = usedAbility.AbilityStatusEffect.StatusEffectDamage; } else { TurnBasedCombatStateMachine.statusEffectBaseDamage = 0; } TurnBasedCombatStateMachine.currentState = TurnBasedCombatStateMachine.BattleStates.CALCULATE_DAMAGE; break; default: Debug.LogError("error in status effects"); break; } }
//Coroutine to handle the player turn. //switch statement is used to select the right damage formula based on what the type of move was chosen by the player. //information about damage / healing is returned and sent to the method to handle displaying on screen text for feedback. public IEnumerator DoPlayerTurn() { int damage = 0; BaseAbility chosenAbility = handleTurn.abilityChosen.GetComponent <BaseAbility> (); BaseEnemy chosenTarget = handleTurn.AttackersTarget.GetComponent <BaseEnemy> (); switch (handleTurn.attackType) { case AttackType.skill: damage = damageCalc.dealMagicalDamage(player.intelligence, chosenAbility.abilityDamage, chosenTarget.wisdom); player.currentMP -= chosenAbility.mpCost; chosenTarget.takeDamage(damage); displayFeedBackText(chosenTarget.enemyName, damage, "damageEnemy"); break; case AttackType.attack: damage = damageCalc.dealPhysicalDamage(player.intelligence, chosenAbility.abilityDamage, chosenTarget.vitality); player.currentMP -= chosenAbility.mpCost; chosenTarget.takeDamage(damage); displayFeedBackText(chosenTarget.enemyName, damage, "damageEnemy"); break; case AttackType.heal: damage = damageCalc.healDamage(player.wisdom, chosenAbility.abilityDamage); player.healDamage(damage); player.currentMP -= chosenAbility.mpCost; displayFeedBackText(player.name, damage, "healPlayer"); break; } yield return(new WaitForSeconds(0.5f)); }
private object GetOrCreateItem(Item item) { var typeName = $"Ensage.SDK.Abilities.Items.{item.Id}"; var type = Type.GetType(typeName); if (type == null) { return(null); } BaseAbility cacheItem = null; if (this.itemCache.TryGetValue(type, out cacheItem)) { if (cacheItem?.Item?.IsValid == false) { cacheItem = null; } } if (cacheItem == null) { cacheItem = (BaseAbility)Activator.CreateInstance(type, item); this.itemCache[type] = cacheItem; } return(cacheItem); }
//method to handle adding the ability game objects to the list and dictionary //dictionary adds abilities in abilityelement groups e.g. all fire ability elements would be grouped together for easy access of all fire type abilities. public void AddToAbilityDictionary(AbilityElement element, BaseAbility ability) { ability.gameObject.name = ability.abilityName; ability.abilityElement = element; abilityDictionary.Add(ability.abilityName, ability); abilityElementsDictionary [element].Add(ability); }
/// <summary> /// /// </summary> /// <param name="baseAbility"></param> /// <returns></returns> public bool CheckAbilityUpdateAllow( BaseAbility baseAbility ) { BaseTreeNode baseTreeNode = m_TreeNodes.GetValue( baseAbility ); if ( baseTreeNode == null ) return false; return baseTreeNode.CheckTreeNodeInfo(); }
// Register ability public void RegisterAbility(BaseAbility ability) { // Run function for when the ability is added ability.OnAbilityAdd(); // Add ability to dictionary Abilities.Add(ability.GetName, ability); Debug.Log(ability.GetName); }
public void removeFromMovelist(BaseAbility move) { this._movelist[move.job].Remove(move.name); if (this._movelist[move.job].Count == 0) { this._movelist.Remove(move.job); } }
public void addToMovelist(BaseAbility move) { if (!this._movelist.ContainsKey(move.job)) { this._movelist[move.job] = new Dictionary <string, BaseAbility>(); } this._movelist[move.job].Add(move.name, move); }
/* * Author: egoisto * Modified by: Kroy * * Shadowmeld racial ability. * * Parameter ba BaseAbility. * Parameter c Character to apply the ability on. */ public static void OnCastShadowmeld(BaseAbility ba, Mobile c) { AuraEffect ae = (AuraEffect)ba; Aura aura = new Aura(); aura.OnRelease = new Aura.AuraReleaseDelegate(OnCastShadowmeldEnded); c.Visible = InvisibilityLevel.Lesser; c.AddAura(ae, aura); }
// Use this for initialization void Start() { baseAbility = AbilityManager.ins.Abilities.Find(x => x.ability == ability); texts = GetComponentsInChildren <Text> (); button = GetComponentInChildren <Button> (); button.onClick.AddListener(OnCast); currentImg = GetComponentInChildren <Image> (); UpdateContainer(); }
public bool AssignAbility(BaseAbility ability, int index) { if (this[index] == null || !this[index].CanBeAssigned) { this[index] = ability; return true; } return false; }
public int CalculateTotalEnemyDamage(BaseAbility usedAbility) { totalUsedAbilityDamage = (int)(CalculateAbilityDamage(usedAbility)); Debug.Log(totalUsedAbilityDamage); totalPlayerDamage = totalUsedAbilityDamage + CalculateStatusEffectDamage(); TurnBasedCombatStateMachine.enemyCompletedTurn = true; return((int)totalPlayerDamage); }
// Unregister ability public void UnregisterAbility(BaseAbility ability) { string aName = ability.GetName; // Run function for when the ability is added ability.OnAbilityRemove(); // Remove ability from dictionary Abilities.Remove(aName); }
private bool TryToApplyStatusEffect(BaseAbility usedAbility) { int randomTemp = Random.Range(1, 101); if (randomTemp <= usedAbility.AbilityStatusEffect.StatusEffectApplyPercentage) { return(true); } return(false); }
private void Debugger_Remote_RemoveAbility(BaseAbility ability) { if (Player) { if (Player.HasAbility(ability)) { Player.RemoveAbility(ability); } } }
public void AddAbility(BaseAbility ability) { if (Player) { if (!Player.HasAbility(ability)) { Player.AddAbility(ability); } } }
public void Destroy() { TriggerEvent(ModifierEventType.OnDestroy); states.Clear(); properties.Clear(); eventActions.Clear(); caster = null; parent = null; ability = null; }
public void RemoveAbility(BaseAbility ability) { if (Player) { if (Player.HasAbility(ability)) { Player.RemoveAbility(ability); } } }
public int CalculateTotalEnemyDamage(BaseAbility ability) { _enemy = GameInformation.Enemy; _enemyDamageModifier = _enemy.EnemyDifficulty * 2; _totalPlayerDamage = ability.AbilityDamage[_enemy.EnemyDifficulty] + _enemyDamageModifier; CombatStateMachine.enemyCompletedTurn = true; return(_totalPlayerDamage); }
public void CalculateEnemyAbilityDamage(BaseAbility usedAbility) { Debug.Log("Used Ability: " + usedAbility.AbilityName); Debug.Log(usedAbility.AbilityPower); totalUsedAbilityDamage = usedAbility.AbilityPower + 15; Debug.Log(totalUsedAbilityDamage); //CombatStateMachine.enemyDidCompleteTurn = true; GameInfoManager.CurrentHitPoints -= totalUsedAbilityDamage; CombatStateMachine.currentState = CombatStateMachine.BattleStates.END_TURN; }
// Add ability public void AddAbility <T>() where T : BaseAbility { // Make sure the ability isn't already there if (gameObject.GetComponent <T>() == null) { // Add ability to player and register it BaseAbility ability = gameObject.AddComponent <T>(); RegisterAbility(ability); } }
public void CalculatePlayerAbilityDamage(BaseAbility usedAbility) { Debug.Log("Used Ability: " + usedAbility.AbilityName); Debug.Log(usedAbility.AbilityPower); //Debug.Break(); totalUsedAbilityDamage = usedAbility.AbilityPower + CalculateDamage(); Debug.Log(totalUsedAbilityDamage); //CombatStateMachine.playerDidCompleteTurn = true; BattleStateStart.newEnemy.CurrentHitPoints -= totalUsedAbilityDamage; CombatStateMachine.currentState = CombatStateMachine.BattleStates.END_TURN; }
public void onClick() { CombatUiStateKeeper.hideCombatUi(); this._ability = AbilityFactory.getAbility(this.name); this.abilityRangeSelection = new Range(Rangefinder.findAllTilesInRange(TurnOrder.getActiveCharacter().GetComponent <CharacterBase>().getCurrentTileOfCharacter(), this._ability.range), "ability"); this.abilityRangeSelection.colorRange(); this._targetMode = true; CombatUiStateKeeper.jumpBackEnabled = false; }
void Start() { for (int i = 0; i < AbilityObjects.Count; i++) { var type = Type.GetType(AbilityObjects[i].fileName); BaseAbility newAbility = (BaseAbility)Activator.CreateInstance(type); abilities.Add(newAbility); abilities[i]?.PassStatsFromSO(AbilityObjects[i]); } }
public void CalculateTotalEnemyDamage(BaseAbility usedAbility) { playerUsedAbility = usedAbility; totalUsedAbilityDamage = (int)CalculateAbilityDamage(usedAbility); totalCritStrikeDamage = CalculateCriticalStrikeDamage(); statusEffectDamage = (int)CalculateStatusEffectDamage(); totalPlayerDamage = totalUsedAbilityDamage + totalCritStrikeDamage + statusEffectDamage; totalPlayerDamage += Random.Range(-(totalPlayerDamage * damageVarianceModifer), (totalPlayerDamage * damageVarianceModifer)); TurnBasedCombatStateMachine.enemyDidCompleteTurn = true; //rnBasedCombatStateMachine.currentState = TurnBasedCombatStateMachine.BattleStates.ENEMYCHOICE; }
public int GetEnemyAbilityCost(BaseAbility ability) { if (ability.AbilityCost[0] == 0) { return(_ambitionCost = 0); } else { return(_ambitionCost = ability.AbilityCost[_enemy.EnemyDifficulty - 1]); } }
/** * Load from Xml * */ void Load() { TextAsset textAsset = (TextAsset) Resources.Load("Entities/"+definition); if (!textAsset) Debug.Log("failed to load xml resource"); var doc = new XmlDocument(); doc.LoadXml (textAsset.text); XmlNodeList entity = doc.SelectNodes ("entity"); var atlist = entity.Item(0).Attributes.GetNamedItem("attrib").Value.Split(' '); int count = 0; foreach (string atr in atlist) { attrib[count] = new BaseAttrib(); attrib[count].baseValue = int.Parse(atr); count++; } level = int.Parse (entity.Item (0).Attributes.GetNamedItem ("level").Value); profession = entity.Item (0).Attributes.GetNamedItem ("class").Value; XmlNodeList myskills = doc.SelectNodes ("entity/skills/skill"); foreach (XmlNode node in myskills) { //Debug.Log("skill "+node.Attributes.GetNamedItem("id").Value); BaseSkill s = new BaseSkill(); s.Name = node.Attributes.GetNamedItem("id").Value; s.baseValue = int.Parse(node.Attributes.GetNamedItem("level").Value); skills.Add(s); } XmlNodeList myabilities = doc.SelectNodes ("entity/skills/abilities"); foreach (XmlNode node in myabilities) { //Debug.Log("skill "+node.Attributes.GetNamedItem("id").Value); BaseAbility a = new BaseAbility(); a.Name = node.Attributes.GetNamedItem("id").Value; abilities.Add(a); } XmlNodeList myitems = doc.SelectNodes ("entity/inventory/item"); foreach (XmlNode node in myitems) { //Debug.Log("item "+node.Attributes.GetNamedItem("id").Value); var item = GameInstance.ItFactory.CreateItem(node.Attributes.GetNamedItem("id").Value); int idx = UnityEngine.Random.Range(100,90000); if (inventory.ContainsKey(idx)) idx = UnityEngine.Random.Range(90000,200000); inventory[idx] = item; } }
//needs a new script eventually public BaseAbility ChooseEnemyAbility() { totalPlayerHealth = GameInfoManager.PlayerCurrentHealth; playerHealthPercentage = (totalPlayerHealth / 100) * 100; if (playerHealthPercentage >= 75) { enemyAttack = new SwordSlash(); return enemyAttack; } else if (playerHealthPercentage < 75 && playerHealthPercentage >= 50) { enemyAttack = new BasicAttack(); return enemyAttack; } else if (playerHealthPercentage < 50) { enemyAttack = new BasicAttack(); return enemyAttack; } enemyAttack = new BasicAttack(); return enemyAttack; }
public void SetSelectedOffensiveAbility(OffensiveAbility oa) { selectedOffensiveAbility = oa; selectedAbility = oa; }
BaseAbility this[int index] { get { return index == -1 ? passiveAbility : _abilitySlots[index]; } set { if (index == -1) passiveAbility = value; else { _abilitySlots[index] = value; }; } }
public void SetSelectedDefensiveAbility(DefensiveAbility da) { selectedDefensiveAbility = da; selectedAbility = da; }
/// <summary> /// /// </summary> public void RegisterAbility( BaseAbility baseAbility, BaseTreeNode baseTreeNode ) { m_TreeNodes.Add( baseAbility, baseTreeNode ); }
/// <summary> /// /// </summary> public void AddAbility( BaseAbility baseAbility ) { m_Abilitys.Add( baseAbility, baseAbility ); }
public void ResetSelectedAbilities() { selectedOffensiveAbility = null; selectedDefensiveAbility = null; selectedAbility = null; }