public virtual void PerformAOETick(IAbilityCaster source, GameObject target, float outputShare, AbilityEffectContext abilityEffectInput, float castDelay) { //Debug.Log(resourceName + ".AOEEffect.PerformAbilityEffect(): outputShare: " + outputShare); AbilityEffectContext modifiedOutput = GetSharedOutput(outputShare, abilityEffectInput); (source as MonoBehaviour).StartCoroutine(WaitForTickDelay(source, target, modifiedOutput, castDelay)); }
public override bool Cast(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectContext) { if (target == null) { return(false); } bool returnResult = base.Cast(source, target, abilityEffectContext); if (returnResult == true) { if (target != null) { GatheringNodeComponent gatheringNodeComponent = GatheringNodeComponent.GetGatheringNodeComponent(target); if (gatheringNodeComponent != null) { gatheringNodeComponent.Gather(); } } else { //Debug.Log(MyName + ".GatherAbility.Cast(): target was null"); } } return(returnResult); }
public override bool CanUseOn(Interactable target, IAbilityCaster source, AbilityEffectContext abilityEffectContext = null, bool playerInitiated = false, bool performRangeCheck = true) { if (target == null) { return(false); } CharacterUnit characterUnit = CharacterUnit.GetCharacterUnit(target); if (characterUnit == null) { return(false); } if (characterUnit.BaseCharacter.CharacterStats.IsAlive == false && characterUnit.BaseCharacter.CharacterStats.IsReviving == false) { return(true); } if (characterUnit.BaseCharacter.CharacterStats.IsAlive == true) { if (playerInitiated) { source.AbilityManager.ReceiveCombatMessage("Cannot cast " + resourceName + ". Target is already alive"); } } if (characterUnit.BaseCharacter.CharacterStats.IsReviving == true) { if (playerInitiated) { source.AbilityManager.ReceiveCombatMessage("Cannot cast " + resourceName + ". Target is already reviving"); } } return(false); }
public override void CastTick(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectContext) { //Debug.Log(DisplayName + ".PetControlEffect.CastTick()"); base.CastTick(source, target, abilityEffectContext); CheckPetSpawn(source, target, abilityEffectContext); }
public virtual void PerformAOEComplete(IAbilityCaster source, Interactable target, float outputShare, AbilityEffectContext abilityEffectInput, float castDelay) { //Debug.Log(abilityEffectName + ".AOEEffect.PerformAbilityEffect(): outputShare: " + outputShare); AbilityEffectContext modifiedOutput = GetSharedOutput(outputShare, abilityEffectInput); (source as MonoBehaviour).StartCoroutine(WaitForCompleteDelay(source, target, modifiedOutput, castDelay)); }
public override void PerformAbility(IAbility ability, GameObject target, AbilityEffectContext abilityEffectContext) { //Debug.Log(gameObject.name + ".PlayerAbilityManager.PerformAbility(" + ability.MyName + ")"); base.PerformAbility(ability, target, abilityEffectContext); // DON'T DO GCD ON CASTS THAT HAVE TIME BECAUSE THEIR CAST TIME WAS ALREADY A TYPE OF GLOBAL COOLDOWN OnPerformAbility(ability); SystemEventManager.MyInstance.NotifyOnAbilityUsed(ability as BaseAbility); (ability as BaseAbility).NotifyOnAbilityUsed(); }
/// <summary> /// Does the actual work of hitting the target with an ability /// </summary> /// <param name="ability"></param> /// <param name="source"></param> /// <param name="target"></param> public override void PerformAbilityHit(IAbilityCaster source, GameObject target, AbilityEffectContext abilityEffectInput) { //Debug.Log(resourceName + ".ResurrectEffect.PerformAbilityEffect(" + source.name + ", " + (target == null ? "null" : target.name) + ") effect: " + resourceName); AbilityEffectContext abilityEffectOutput = new AbilityEffectContext(); abilityEffectOutput.groundTargetLocation = abilityEffectInput.groundTargetLocation; ResurrectTarget(target); base.PerformAbilityHit(source, target, abilityEffectOutput); }
public void CheckPetSpawn(IAbilityCaster source, GameObject target, AbilityEffectContext abilityEffectInput) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn()"); List <CharacterUnit> unitsToRemove = new List <CharacterUnit>(); foreach (CharacterUnit characterUnit in petUnits) { //if (characterUnit != null) { if (characterUnit.MyCharacter.CharacterStats.IsAlive == false) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): ADDING DEAD PET TO REMOVE LIST"); unitsToRemove.Add(characterUnit); } //} } foreach (CharacterUnit characterUnit in unitsToRemove) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): REMOVING DEAD PET"); petUnits.Remove(characterUnit); } if (petUnits.Count == 0) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): SPAWNING PETS"); // spawn pet List <AbilityEffect> castList = new List <AbilityEffect>(); foreach (AbilityEffect petEffect in realPetEffectList) { //if (source.MyCharacterAbilityManager.HasAbility(petAbilityName)) { if (SystemResourceManager.MatchResource(petEffect.DisplayName, DisplayName)) { Debug.LogError(DisplayName + ".PerformAbilityEffects(): circular reference detected. Tried to cast self. CHECK INSPECTOR AND FIX ABILITY EFFECT CONFIGURATION!!!"); } else { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): adding to cast list"); castList.Add(petEffect); } //} } if (castList.Count > 0) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): castlist.count: " + castList.Count); Dictionary <PrefabProfile, GameObject> rawObjectList = PerformAbilityEffects(source, target, abilityEffectInput, castList); foreach (KeyValuePair <PrefabProfile, GameObject> tmpObject in rawObjectList) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): LOOPING THROUGH RAW OBJECT LIST "); CharacterUnit _characterUnit = tmpObject.Value.GetComponent <CharacterUnit>(); if (_characterUnit != null) { //Debug.Log(MyName + ".PetEffect.CheckPetSpawn(): ADDING PET TO UNIT LIST"); petUnits.Add(_characterUnit); } } } } }
public void Initialize(float velocity, IAbilityCaster source, GameObject target, Vector3 positionOffset, AbilityEffectContext abilityEffectInput) { //Debug.Log("ProjectileScript.Initialize(" + velocity + ", " + source.name + ", " + (target == null ? "null" : target.name) + ", " + positionOffset + ")"); this.source = source; this.velocity = velocity; this.target = target; this.positionOffset = positionOffset; this.abilityEffectInput = abilityEffectInput; initialized = true; }
public override bool Cast(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectContext) { //Debug.Log("CraftAbility.Cast(" + (target ? target.name : "null") + ")"); bool returnResult = base.Cast(source, target, abilityEffectContext); if (returnResult == true) { CraftingUI.MyInstance.CraftNextItemWait(); } return(returnResult); }
public void Initialize(float velocity, IAbilityCaster source, Interactable target, Vector3 positionOffset, GameObject go, AbilityEffectContext abilityEffectContext) { //Debug.Log(gameObject.name + ".ProjectileScript.Initialize(" + velocity + ", " + source.AbilityManager.Name + ", " + (target == null ? "null" : target.name) + ", " + positionOffset + ")"); projectileGameObject = go; this.source = source; this.velocity = velocity; this.target = target; this.positionOffset = positionOffset; this.abilityEffectContext = abilityEffectContext; initialized = true; }
public override bool RecoverResource(AbilityEffectContext abilityEffectContext, PowerResource powerResource, int amount, IAbilityCaster source, bool showCombatText = true, CombatMagnitude combatMagnitude = CombatMagnitude.normal) { bool returnValue = base.RecoverResource(abilityEffectContext, powerResource, amount, source, showCombatText, combatMagnitude); if (returnValue == false) { return(false); } CombatLogUI.MyInstance.WriteSystemMessage("You gain " + amount + " " + powerResource.DisplayName); return(returnValue); }
public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, GameObject target, GameObject originalTarget, AbilityEffectContext abilityEffectInput) { //Debug.Log(MyName + ".InstantEffect.Cast()"); if (abilityEffectInput == null) { abilityEffectInput = new AbilityEffectContext(); } Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectInput); PerformAbilityHit(source, target, abilityEffectInput); return(returnObjects); }
protected virtual AbilityEffectContext GetSharedOutput(float outputShare, AbilityEffectContext abilityEffectInput) { AbilityEffectContext modifiedOutput = new AbilityEffectContext(); foreach (ResourceInputAmountNode resourceInputAmountNode in abilityEffectInput.resourceAmounts) { modifiedOutput.AddResourceAmount(resourceInputAmountNode.resourceName, (int)(resourceInputAmountNode.amount * outputShare)); } modifiedOutput.groundTargetLocation = abilityEffectInput.groundTargetLocation; return(modifiedOutput); }
public override bool Cast(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectContext) { // this code could lead to a situation where an instanteffect was allowed to perform its ability effects even if the wrong weapon was equipped. // need to change cast to a bool to pass that success or not up the casting stack bool castResult = base.Cast(source, target, abilityEffectContext); if (castResult) { PerformAbilityEffects(source, target, abilityEffectContext); } return(castResult); }
public override bool TakeDamage(AbilityEffectContext abilityEffectContext, PowerResource powerResource, int damage, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect, bool reflectDamage = false) { //Debug.Log("PlayerCombat.TakeDamage(" + damage + ", " + source.name + ")"); // enter combat first because if we die from this hit, we don't want to enter combat when dead EnterCombat(source); // added damageTaken bool to prevent blood effects from showing if you ran out of range of the attack while it was in progress /* * bool damageTaken = base.TakeDamage(damage, sourcePosition, source, combatMagnitude, abilityEffect, reflectDamage = false); * return damageTaken; */ return(base.TakeDamage(abilityEffectContext, powerResource, damage, source, combatMagnitude, abilityEffect, reflectDamage = false)); }
protected virtual AbilityEffectContext GetSharedOutput(float outputShare, AbilityEffectContext abilityEffectInput) { // modify the resource amounts by multiplying them by the output share AbilityEffectContext modifiedOutput = abilityEffectInput.GetCopy(); modifiedOutput.resourceAmounts.Clear(); foreach (ResourceInputAmountNode resourceInputAmountNode in abilityEffectInput.resourceAmounts) { modifiedOutput.AddResourceAmount(resourceInputAmountNode.resourceName, (int)(resourceInputAmountNode.amount * outputShare)); } return(modifiedOutput); }
/* * public override void ClearAggro(GameObject target) { * base.ClearAggro(target); * aiController.ClearTarget(); * } */ public override bool TakeDamage(AbilityEffectContext abilityEffectContext, PowerResource powerResource, int damage, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect) { //Debug.Log("AICombat.TakeDamage(" + damage + ", " + sourcePosition + ", " + source + ")"); if (!((baseCharacter.CharacterController as AIController).MyCurrentState is EvadeState) && !((baseCharacter.CharacterController as AIController).MyCurrentState is DeathState)) { // order is important here. we want to set target before taking damage because taking damage could kill us, and we don't want to re-trigger and agro on someone after we are dead // this should happen automatically inside the update loop of idle state //baseCharacter.MyCharacterController.SetTarget(source); return(base.TakeDamage(abilityEffectContext, powerResource, damage, source, combatMagnitude, abilityEffect)); } return(false); }
public override bool Cast(IAbilityCaster source, GameObject target, AbilityEffectContext abilityEffectContext) { //Debug.Log(MyName + ".InstantEffectAbility.Cast(" + source.name + ", " + (target == null ? "null" : target.name) + ", " + groundTarget + ")"); // this code could lead to a situation where an instanteffect was allowed to perform its ability effects even if the wrong weapon was equipped. // need to change cast to a bool to pass that success or not up the casting stack bool castResult = base.Cast(source, target, abilityEffectContext); if (castResult) { PerformAbilityEffects(source, target, abilityEffectContext); } return(castResult); }
private void OnDisable() { //Debug.Log(gameObject.name + " " + gameObject.GetInstanceID() + ".ProjectileScript.OnDisable()"); if (SystemGameManager.IsShuttingDown) { return; } projectileGameObject = null; source = null; target = null; positionOffset = Vector3.zero; targetPosition = Vector3.zero; velocity = 0f; initialized = false; abilityEffectContext = null; OnCollission = delegate { }; }
public override bool CanUseOn(GameObject target, IAbilityCaster source, AbilityEffectContext abilityEffectContext = null) { if (target == null) { return(false); } CharacterUnit characterUnit = target.GetComponent <CharacterUnit>(); if (characterUnit == null) { return(false); } if (characterUnit.MyCharacter.CharacterStats.IsAlive == false && characterUnit.MyCharacter.CharacterStats.IsReviving == false) { return(true); } return(false); }
public AbilityEffectContext GetCopy() { // make a new ability effect context AbilityEffectContext returnValue = new AbilityEffectContext(); // copy all properties returnValue.resourceAmounts = resourceAmounts; returnValue.overrideDuration = overrideDuration; returnValue.savedEffect = savedEffect; returnValue.castTimeMultiplier = castTimeMultiplier; returnValue.spellDamageMultiplier = spellDamageMultiplier; returnValue.reflectDamage = reflectDamage; returnValue.groundTargetLocation = groundTargetLocation; returnValue.originalTarget = originalTarget; returnValue.baseAbility = baseAbility; returnValue.powerResource = powerResource; // return the new object return(returnValue); }
public override bool Cast(IAbilityCaster source, GameObject target, AbilityEffectContext abilityEffectContext) { if (target == null) { return(false); } bool returnResult = base.Cast(source, target, abilityEffectContext); if (returnResult == true) { if (target != null) { target.GetComponent <GatheringNode>().Gather(); } else { //Debug.Log(MyName + ".GatherAbility.Cast(): target was null"); } } return(returnResult); }
public void CheckPetSpawn(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectInput) { //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn()"); CharacterPetManager characterPetManager = null; if ((source as BaseCharacter) is BaseCharacter) { characterPetManager = (source as BaseCharacter).CharacterPetManager; } else { //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): source is not basecharacter"); return; } List <AbilityEffect> castList = new List <AbilityEffect>(); foreach (SummonEffect petEffect in petEffectList) { if (SystemDataFactory.MatchResource(petEffect.DisplayName, DisplayName)) { Debug.LogError(DisplayName + ".PerformAbilityEffects(): circular reference detected. Tried to cast self. CHECK INSPECTOR AND FIX ABILITY EFFECT CONFIGURATION!!!"); } else { //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): adding to cast list"); if (petEffect.UnitProfile != null && characterPetManager.ActiveUnitProfiles.ContainsKey(petEffect.UnitProfile) == false) { //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): adding cast:" + petEffect.DisplayName); castList.Add(petEffect); } } } if (castList.Count > 0) { //Debug.Log(DisplayName + ".PetEffect.CheckPetSpawn(): castlist.count: " + castList.Count); Dictionary <PrefabProfile, GameObject> rawObjectList = PerformAbilityEffects(source, target, abilityEffectInput, castList); } }
/// <summary> /// Does the actual work of hitting the target with an ability /// </summary> /// <param name="ability"></param> /// <param name="source"></param> /// <param name="target"></param> public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, Interactable target, Interactable originalTarget, AbilityEffectContext abilityEffectContext) { //Debug.Log(DisplayName + ".AOEEffect.Cast(" + (source == null ? "null" : source.AbilityManager.UnitGameObject.name) + ", " + (target == null ? "null" : target.name) + ")"); if (abilityEffectContext == null) { abilityEffectContext = new AbilityEffectContext(); } Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectContext); TargetAOEHit(source, target, abilityEffectContext); // ground targeted spells should play the audio on the prefab object, not the character if (prefabSpawnLocation == PrefabSpawnLocation.GroundTarget) { base.PlayAudioEffects(onHitAudioProfiles, null); } else { base.PlayAudioEffects(onHitAudioProfiles, target); } return(returnObjects); }
public IEnumerator DestroyAbilityEffectObject(Dictionary <PrefabProfile, GameObject> abilityEffectObjects, IAbilityCaster source, GameObject target, float timer, AbilityEffectContext abilityEffectInput, FixedLengthEffect fixedLengthEffect) { //Debug.Log("CharacterAbilityManager.DestroyAbilityEffectObject(" + (source == null ? "null" : source.name) + ", " + (target == null ? "null" : target.name) + ", " + timer + ")"); float timeRemaining = timer; // keep track of temporary elapsed time between ticks float elapsedTime = 0f; bool nullTarget = false; CharacterStats targetStats = null; if (target != null) { CharacterUnit _characterUnit = target.GetComponent <CharacterUnit>(); if (_characterUnit != null) { targetStats = _characterUnit.MyCharacter.CharacterStats; } } else { nullTarget = true; } int milliseconds = (int)((fixedLengthEffect.TickRate - (int)fixedLengthEffect.TickRate) * 1000); float finalTickRate = fixedLengthEffect.TickRate; if (finalTickRate == 0) { finalTickRate = timer + 1; } //Debug.Log(abilityEffectName + ".StatusEffect.Tick() milliseconds: " + milliseconds); //TimeSpan tickRateTimeSpan = new TimeSpan(0, 0, 0, (int)finalTickRate, milliseconds); //Debug.Log(abilityEffectName + ".StatusEffect.Tick() tickRateTimeSpan: " + tickRateTimeSpan); //fixedLengthEffect.MyNextTickTime = System.DateTime.Now + tickRateTimeSpan; //Debug.Log(abilityEffectName + ".FixedLengthEffect.Tick() nextTickTime: " + nextTickTime); while (timeRemaining > 0f) { yield return(null); if (nullTarget == false && (targetStats == null || fixedLengthEffect == null)) { //Debug.Log(gameObject.name + ".CharacterAbilityManager.DestroyAbilityEffectObject: BREAKING!!!!!!!!!!!!!!!!!: fixedLengthEffect: " + (fixedLengthEffect == null ? "null" : fixedLengthEffect.MyName) + "; targetstats: " + (targetStats == null ? "null" : targetStats.name)); break; } if (fixedLengthEffect.MyPrefabSpawnLocation != PrefabSpawnLocation.GroundTarget && fixedLengthEffect.RequiresTarget == true && (target == null || (targetStats.IsAlive == true && fixedLengthEffect.RequireDeadTarget == true) || (targetStats.IsAlive == false && fixedLengthEffect.RequiresLiveTarget == true))) { //Debug.Log("BREAKING!!!!!!!!!!!!!!!!!"); break; } else { timeRemaining -= Time.deltaTime; if (elapsedTime > finalTickRate) { //Debug.Log(abilityEffectName + ".FixedLengthEffect.Tick() TickTime!"); fixedLengthEffect.CastTick(source, target, abilityEffectInput); elapsedTime -= finalTickRate; } } } //Debug.Log(fixedLengthEffect.MyName + ".FixedLengthEffect.Tick() Done ticking and about to perform ability affects."); fixedLengthEffect.CastComplete(source, target, abilityEffectInput); foreach (GameObject go in abilityEffectObjects.Values) { if (abilityEffectGameObjects.Contains(go)) { abilityEffectGameObjects.Remove(go); } Destroy(go, fixedLengthEffect.MyPrefabDestroyDelay); } abilityEffectObjects.Clear(); destroyAbilityEffectObjectCoroutine = null; }
public void BeginDestroyAbilityEffectObject(Dictionary <PrefabProfile, GameObject> abilityEffectObjects, IAbilityCaster source, GameObject target, float timer, AbilityEffectContext abilityEffectInput, FixedLengthEffect fixedLengthEffect) { foreach (GameObject go in abilityEffectObjects.Values) { abilityEffectGameObjects.Add(go); } destroyAbilityEffectObjectCoroutine = StartCoroutine(DestroyAbilityEffectObject(abilityEffectObjects, source, target, timer, abilityEffectInput, fixedLengthEffect)); }
public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, GameObject target, GameObject originalTarget, AbilityEffectContext abilityEffectContext) { //Debug.Log(MyName + ".ProjectileEffect.Cast(" + source.name + ", " + (target == null ? "null" : target.name) + ")"); Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectContext); if (returnObjects != null) { foreach (GameObject go in returnObjects.Values) { //Debug.Log(MyName + ".ProjectileEffect.Cast(): found gameobject: " + go.name); go.transform.parent = PlayerManager.MyInstance.MyEffectPrefabParent.transform; ProjectileScript projectileScript = go.GetComponent <ProjectileScript>(); if (projectileScript != null) { //Debug.Log(MyName + ".ProjectileEffect.Cast(): found gameobject: " + go.name + " and it has projectile script"); abilityEffectContext = ApplyInputMultiplier(abilityEffectContext); projectileScript.Initialize(projectileSpeed, source, target, new Vector3(0, 1, 0), abilityEffectContext); projectileScript.OnCollission += HandleCollission; } } } return(returnObjects); }
public void HandleCollission(IAbilityCaster source, GameObject target, GameObject _abilityEffectObject, AbilityEffectContext abilityEffectInput) { //Debug.Log(MyName + ".ProjectileEffect.HandleCollission()"); PerformAbilityHit(source, target, abilityEffectInput); Destroy(_abilityEffectObject); }
public override void CastComplete(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectContext) { //Debug.Log(abilityEffectName + ".DirectEffect.CastComplete()"); base.CastComplete(source, target, abilityEffectContext); PerformAbilityComplete(source, target, abilityEffectContext); }