public void OnTriggerEnter(Collider other) { if (!triggerBased) { return; } // only players can activate trigger based unit spawn nodes. we don't want npcs wandering around patrolling to activate these CharacterUnit _characterUnit = other.gameObject.GetComponent <CharacterUnit>(); if (_characterUnit == null || _characterUnit != PlayerManager.MyInstance.MyCharacter.CharacterUnit) { return; } if (triggerLimit > 0 && triggerCount >= triggerLimit) { // this has already been activated the number of allowed times return; } triggerCount++; // already in the middle of spawning. do nothing if (countDownRoutine != null) { return; } // all check passed, safe to spawn Spawn(); }
public override bool Interact(CharacterUnit source) { bool returnValue = PickUp(); PopupWindowManager.MyInstance.interactionWindow.CloseWindow(); return(returnValue); }
public override bool Interact(CharacterUnit source) { //Debug.Log(gameObject.name + ".AnimatedObject.Interact(" + (source == null ? "null" : source.name) +")"); if (coroutine != null) { //Debug.Log(gameObject.name + ".AnimatedObject.Interact(): coroutine is not null, exiting"); return(false); } base.Interact(source); PopupWindowManager.MyInstance.interactionWindow.CloseWindow(); // loop through the animatedobjects prefabobjects // check their state (open / closed) if (interactable.MyPrefabProfile == null) { Debug.Log(gameObject.name + ".AnimatedObject.Interact(): prefabprofile was null"); return(false); } if (objectOpen) { coroutine = StartCoroutine(animateObject(interactable.MyPrefabProfile.MyRotation, interactable.MyPrefabProfile.MyPosition, interactable.MyPrefabProfile.UnsheathAudioProfile)); } else { coroutine = StartCoroutine(animateObject(interactable.MyPrefabProfile.MySheathedRotation, interactable.MyPrefabProfile.MySheathedPosition, interactable.MyPrefabProfile.SheathAudioProfile)); } // lerp them to the other state, using the values defined in their sheathed and regular positions return(false); }
private void Spawn() { //Debug.Log(gameObject.name + ".UnitSpawnNode.Spawn(): GetMaxUnits(): " + GetMaxUnits()); int spawnIndex = UnityEngine.Random.Range(0, spawnPrefabs.Count - 1); if ((spawnReferences.Count < GetMaxUnits() || GetMaxUnits() == -1) && MyPrerequisitesMet) { //GetSpawnLocation(); //Debug.Log("UnitSpawnNode.Spawn(): Spawning " + spawnPrefabs[spawnIndex].name); //GameObject spawnReference = Instantiate(spawnPrefabs[spawnIndex], GetSpawnLocation(), Quaternion.identity); GameObject spawnReference = Instantiate(spawnPrefabs[spawnIndex]); //Debug.Log("UnitSpawnNode.Spawn(): gameObject spawned at: " + spawnReference.transform.position); Vector3 newSpawnLocation = GetSpawnLocation(); //Debug.Log("UnitSpawnNode.Spawn(): newSpawnLocation: " + newSpawnLocation); NavMeshAgent navMeshAgent = spawnReference.GetComponent <NavMeshAgent>(); AIController aIController = spawnReference.GetComponent <AIController>(); aIController.MyStartPosition = newSpawnLocation; //Debug.Log("UnitSpawnNode.Spawn(): navhaspath: " + navMeshAgent.hasPath + "; isOnNavMesh: " + navMeshAgent.isOnNavMesh + "; isOnOffMeshLink: " + navMeshAgent.isOnOffMeshLink + "; pathpending: " + navMeshAgent.pathPending + "; warping now!"); //spawnReference.transform.position = newSpawnLocation; navMeshAgent.Warp(newSpawnLocation); //Debug.Log("UnitSpawnNode.Spawn(): afterMove: navhaspath: " + navMeshAgent.hasPath + "; isOnNavMesh: " + navMeshAgent.isOnNavMesh + "; pathpending: " + navMeshAgent.pathPending); CharacterUnit _characterUnit = spawnReference.GetComponent <CharacterUnit>(); if (_characterUnit != null) { _characterUnit.OnDespawn += HandleDespawn; } int _unitLevel = (dynamicLevel ? PlayerManager.MyInstance.MyCharacter.MyCharacterStats.MyLevel : unitLevel) + extraLevels; _characterUnit.MyCharacter.MyCharacterStats.SetLevel(_unitLevel); spawnReferences.Add(spawnReference); } }
private Dictionary <PrefabProfile, GameObject> Spawn(BaseCharacter source) { //Debug.Log(MyName + ".SummonEffect.Spawn(): prefabObjects.count: " + prefabObjects.Count); foreach (KeyValuePair <PrefabProfile, GameObject> tmpPair in prefabObjects) { //Debug.Log(MyName + ".SummonEffect.Spawn(): looping through prefabObjects"); //GameObject spawnReference = Instantiate(summonObject, PlayerManager.MyInstance.MyAIUnitParent.transform, true); tmpPair.Value.transform.parent = null; //Debug.Log("UnitSpawnNode.Spawn(): gameObject spawned at: " + spawnReference.transform.position); //Vector3 newSpawnLocation = GetSpawnLocation(); Vector3 newSpawnLocation = source.MyCharacterUnit.transform.position; //Debug.Log("UnitSpawnNode.Spawn(): newSpawnLocation: " + newSpawnLocation); NavMeshAgent navMeshAgent = tmpPair.Value.GetComponent <NavMeshAgent>(); AIController aIController = tmpPair.Value.GetComponent <AIController>(); aIController.MyStartPosition = newSpawnLocation; //Debug.Log("UnitSpawnNode.Spawn(): navhaspath: " + navMeshAgent.hasPath + "; isOnNavMesh: " + navMeshAgent.isOnNavMesh + "; isOnOffMeshLink: " + navMeshAgent.isOnOffMeshLink + "; pathpending: " + navMeshAgent.pathPending + "; warping now!"); //spawnReference.transform.position = newSpawnLocation; navMeshAgent.Warp(newSpawnLocation); //Debug.Log("UnitSpawnNode.Spawn(): afterMove: navhaspath: " + navMeshAgent.hasPath + "; isOnNavMesh: " + navMeshAgent.isOnNavMesh + "; pathpending: " + navMeshAgent.pathPending); CharacterUnit _characterUnit = tmpPair.Value.GetComponent <CharacterUnit>(); /* * if (_characterUnit != null) { * _characterUnit.OnDespawn += HandleDespawn; * } */ //int _unitLevel = (dynamicLevel ? PlayerManager.MyInstance.MyCharacter.MyCharacterStats.MyLevel : unitLevel) + extraLevels; int _unitLevel = source.MyCharacterStats.MyLevel; _characterUnit.MyCharacter.MyCharacterStats.SetLevel(_unitLevel); (_characterUnit.MyCharacter.MyCharacterStats as AIStats).ApplyControlEffects(source); //spawnReferences.Add(spawnReference); } return(prefabObjects); }
/* * // bypass the creation of the status effect and just make its visual prefab * public void RawCast(BaseCharacter source, GameObject target, GameObject originalTarget, AbilityEffectOutput abilityEffectInput) { * base.Cast(source, target, originalTarget, abilityEffectInput); * } */ public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, Interactable target, Interactable originalTarget, AbilityEffectContext abilityEffectInput) { //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target? target.name : "null") + ")"); if (!CanUseOn(target, source)) { //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target ? target.name : "null") + ") CANNOT USE RETURNING"); return(null); } Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectInput); // make ourselves the top threat in his threat table CharacterUnit targetCharacterUnit = CharacterUnit.GetCharacterUnit(target); if (targetCharacterUnit != null) { if (targetCharacterUnit.BaseCharacter != null && targetCharacterUnit.BaseCharacter.CharacterCombat != null && targetCharacterUnit.BaseCharacter.CharacterCombat.AggroTable != null) { //Debug.Log("StatusEffect.Cast(" + source.name + ", " + (target ? target.name : "null") + ") CHARACTER COMBAT IS NOT NULL"); AggroNode AgroNode = targetCharacterUnit.BaseCharacter.CharacterCombat.AggroTable.MyTopAgroNode; float usedAgroValue = 0f; if (AgroNode != null) { usedAgroValue = AgroNode.aggroValue; } if (source != null) { source.AbilityManager.GenerateAgro(targetCharacterUnit, (int)(usedAgroValue + extraThreat)); } } } // override aggro checks return(returnObjects); }
public override void PerformAbilityHit(IAbilityCaster source, Interactable target, AbilityEffectContext abilityEffectInput) { base.PerformAbilityHit(source, target, abilityEffectInput); List <StatusEffectNode> removeEffects = new List <StatusEffectNode>(); CharacterUnit targetCharacterUnit = CharacterUnit.GetCharacterUnit(target); if (targetCharacterUnit != null && targetCharacterUnit.BaseCharacter != null && targetCharacterUnit.BaseCharacter.CharacterStats != null) { foreach (StatusEffectNode statusEffectNode in targetCharacterUnit.BaseCharacter.CharacterStats.StatusEffects.Values) { if (statusEffectNode.StatusEffect.StatusEffectType != null && effectTypes.Contains(statusEffectNode.StatusEffect.StatusEffectType)) { removeEffects.Add(statusEffectNode); } if (maxClearEffects != 0 && removeEffects.Count >= maxClearEffects) { break; } } foreach (StatusEffectNode statusEffectNode in removeEffects) { statusEffectNode.CancelStatusEffect(); } } }
public override void PerformAbilityHit(BaseCharacter source, GameObject target, AbilityEffectOutput abilityEffectInput) { base.PerformAbilityHit(source, target, abilityEffectInput); List <StatusEffectNode> removeEffects = new List <StatusEffectNode>(); CharacterUnit targetCharacterUnit = target.GetComponent <CharacterUnit>(); if (targetCharacterUnit != null && targetCharacterUnit.MyCharacter != null && targetCharacterUnit.MyCharacter.MyCharacterStats != null) { foreach (StatusEffectNode statusEffectNode in targetCharacterUnit.MyCharacter.MyCharacterStats.MyStatusEffects.Values) { if (statusEffectNode.MyStatusEffect.MyStatusEffectType != null && effectTypes.Contains(statusEffectNode.MyStatusEffect.MyStatusEffectType)) { removeEffects.Add(statusEffectNode); } if (maxClearEffects != 0 && removeEffects.Count >= maxClearEffects) { break; } } foreach (StatusEffectNode statusEffectNode in removeEffects) { statusEffectNode.CancelStatusEffect(); } } }
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 bool Cast(BaseCharacter source, GameObject target, Vector3 groundTarget) { //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, groundTarget); if (castResult) { // these effects may include things which do not do damage (status debuffs) or take a while to do damage (slow ticks). // We need to pull enemies into combat at this point if (target != null) { CharacterUnit targetCharacterUnit = target.GetComponent <CharacterUnit>(); if (targetCharacterUnit != null && targetCharacterUnit.MyBaseCharacter != null) { if (Faction.RelationWith(targetCharacterUnit.MyBaseCharacter, source) <= -1) { if (targetCharacterUnit.MyBaseCharacter.MyCharacterCombat != null) { // agro includes a liveness check, so casting necromancy on a dead enemy unit should not pull it into combat with us if we haven't applied a faction or master control buff yet targetCharacterUnit.MyBaseCharacter.MyCharacterController.Agro(source.MyCharacterUnit); } } } } PerformAbilityEffects(source, target, groundTarget); } return(castResult); }
//private bool initialized = false; //private float radius = 0.5f; /* * private void Update() { * } */ public void Initialize(CharacterUnit source, GameObject target, float radius) { //Debug.Log("ProjectileScript.Initialize(" + source.name + ", " + target.name + ", " + radius + ")"); this.source = source; this.target = target; sphereCollider.radius = radius; //initialized = true; }
public override bool Interact(CharacterUnit source) { //Debug.Log(gameObject.name + ".PortalInteractable.Interact()"); base.Interact(source); LevelManager.MyInstance.LoadLevel(sceneName); return(true); }
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 override bool CanInteract(CharacterUnit source) { bool returnValue = base.CanInteract(source); if (returnValue == false) { return(false); } return(GetCurrentOptionCount() == 0 ? false : true); }
public void SetupRotateModel() { CharacterUnit tmpUnit = GetComponent <CharacterUnit>(); DynamicCharacterAvatar dynamicCharacterAvatar = GetComponent <DynamicCharacterAvatar>(); if (tmpUnit == null && dynamicCharacterAvatar == null) { rotateModel = true; } }
void Awake() { anyRPGCharacterController = GetComponent <AnyRPGCharacterController>(); characterUnit = GetComponent <CharacterUnit>(); //Set currentState to idle on startup. currentState = AnyRPGCharacterState.Idle; rpgCharacterState = AnyRPGCharacterState.Idle; airForwardDirection = transform.forward; }
public override bool Interact(CharacterUnit source) { if (lootTableNames == null) { //Debug.Log(gameObject.name + ".GatheringNode.Interact(" + source.name + "): lootTable was null!"); return(true); } PickUp(); PopupWindowManager.MyInstance.interactionWindow.CloseWindow(); return(true); }
public override bool ProcessAbilityHit(Interactable target, int finalAmount, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect, AbilityEffectContext abilityEffectContext, PowerResource powerResource) { bool returnValue = CharacterUnit.GetCharacterUnit(target).BaseCharacter.CharacterCombat.TakeDamage(abilityEffectContext, powerResource, finalAmount, source, combatMagnitude, this); if (returnValue == false) { return(false); } return(base.ProcessAbilityHit(target, finalAmount, source, combatMagnitude, abilityEffect, abilityEffectContext, powerResource)); }
public override bool Interact(CharacterUnit source) { if (!chestWindow.IsOpen) { AddItems(); chestWindow.OnCloseWindowCallback += OnCloseWindow; chestWindow.OpenWindow(); return(true); } return(false); }
private void ResurrectTarget(GameObject target) { CharacterUnit characterUnit = target.GetComponent <CharacterUnit>(); if (characterUnit == null) { //Debug.Log("CharacterUnit is null? target despawn during cast?"); return; } characterUnit.MyCharacter.MyCharacterStats.Revive(); }
public void HandleTakeDamage(BaseCharacter source, CharacterUnit target, int damage, string abilityName) { Color textColor = Color.white; if (target == PlayerManager.MyInstance.MyCharacter.MyCharacterUnit) { textColor = Color.red; } string combatMessage = string.Format("<color=#{0}>{1} Takes {2} damage from {3}'s {4}</color>", ColorUtility.ToHtmlStringRGB(textColor), target.MyDisplayName, damage, source.MyCharacterName, abilityName); WriteCombatMessage(combatMessage); }
public override bool Interact(CharacterUnit source) { //Debug.Log(gameObject.name + ".Bank.Interact(" + (source == null ? "null" : source.name) +")"); base.Interact(source); PopupWindowManager.MyInstance.interactionWindow.CloseWindow(); if (!PopupWindowManager.MyInstance.bankWindow.IsOpen) { PopupWindowManager.MyInstance.bankWindow.OpenWindow(); return(true); } return(false); }
public void HandleTakeDamage(IAbilityCaster source, CharacterUnit target, int damage, string abilityName) { //Debug.Log("LogManager.HandleTakeDamage()"); Color textColor = Color.white; if (playerManager.UnitController != null && target == playerManager.UnitController.CharacterUnit) { textColor = Color.red; } string combatMessage = string.Format("<color=#{0}>{1} Takes {2} damage from {3}'s {4}</color>", ColorUtility.ToHtmlStringRGB(textColor), target.DisplayName, damage, source.AbilityManager.Name, abilityName); WriteCombatMessage(combatMessage); }
public void OnTriggerEnter(Collider other) { if (!triggerBased) { return; } CharacterUnit _characterUnit = other.gameObject.GetComponent <CharacterUnit>(); if (_characterUnit != null && _characterUnit == PlayerManager.MyInstance.MyCharacter.MyCharacterUnit) { Spawn(); } }
public override bool ProcessAbilityHit(Interactable target, int finalAmount, IAbilityCaster source, CombatMagnitude combatMagnitude, AbilityEffect abilityEffect, AbilityEffectContext abilityEffectContext, PowerResource powerResource) { //Debug.Log(DisplayName + ".HealEffect.ProcessAbilityHit(" + (target == null ? "null" : target.gameObject.name) + ", " + finalAmount + ", " + source.AbilityManager.UnitGameObject.name + ")"); abilityEffectContext.powerResource = powerResource; bool returnValue = CharacterUnit.GetCharacterUnit(target).BaseCharacter.CharacterStats.RecoverResource(abilityEffectContext, powerResource, finalAmount, source, true, combatMagnitude); if (returnValue == false) { return(false); } return(base.ProcessAbilityHit(target, finalAmount, source, combatMagnitude, abilityEffect, abilityEffectContext, powerResource)); }
private void Awake() { if (characterUnit == null) { characterUnit = GetComponent <CharacterUnit>(); } if (characterUnit == null) { characterUnit = GetComponentInParent <CharacterUnit>(); } if (characterUnit == null) { //Debug.Log(gameObject.name + ".CharacterAnimationEventReceiver.Awake(): could not find character unit!"); } }
public override CharacterUnit ReturnTarget(CharacterUnit source, CharacterUnit target) { //Debug.Log("HealEffect.ReturnTarget(" + (source == null ? "null" : source.MyName) + ", " + (target == null ? "null" : target.MyName) + ")"); if (target == null) { //Debug.Log("Heal spell cast, but there was no target"); return(source); } if (Faction.RelationWith(target.MyCharacter, source.MyCharacter) <= -1) { //if (Faction.RelationWith(source.MyCharacter, target.MyCharacter) < 0) { //Debug.Log("The target is an enemy. Casting on self instead."); return(source); } return(target); }
private void ResurrectTarget(Interactable target) { if (target == null) { // our target despawned in the middle of the cast return; } CharacterUnit characterUnit = CharacterUnit.GetCharacterUnit(target); if (characterUnit == null) { //Debug.Log("CharacterUnit is null? target despawn during cast?"); return; } characterUnit.BaseCharacter.CharacterStats.Revive(); }
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 override bool CanUseOn(GameObject target, BaseCharacter source) { if (target == null) { return(false); } CharacterUnit characterUnit = target.GetComponent <CharacterUnit>(); if (characterUnit == null) { return(false); } if (characterUnit.MyCharacter.MyCharacterStats.IsAlive == false && characterUnit.MyCharacter.MyCharacterStats.MyIsReviving == false) { return(true); } return(false); }