//void Temp(IAsyncOperation<IList<IResourceLocation>> op){ // Debug.Log ("SHALALALALALALA"); //} /// <summary> /// apply the effect. override this for other extensions. /// </summary> public override void ApplyEffect() { Debug.Log("apply position prefab effect"); //if (Prefab != null) { IHasPositionEffects posSource = Source as IHasPositionEffects; if (posSource != null) { //Addressables.LoadAssets<IResourceLocation> ("Meteor", null).Completed += Temp; //Addressables.Instantiate<GameObject> ("Meteor.prefab",posSource.GetPosition(),Quaternion.identity); GameObject.Instantiate(Prefab, posSource.GetPosition(), Quaternion.identity); } //} }
public override void ApplyEffect() { // get the base stat value of the user of this effect int baseValue = 0; if (StatBase != "") { IHasStats owner = Source.GetOwner().GetComponent <IHasStats>(); if (owner != null) { owner.TryGetStatValue(StatBase, out baseValue); // prevents the case where the statname doesn't exist } } // get source as a positional source IHasPositionEffects positionSource = Source as IHasPositionEffects; if (positionSource == null) { return; } // get source owner IHasPerception perceptionOwner = Source.GetOwner().GetComponent <IHasPerception>(); if (perceptionOwner == null) { return; } // for each found percept, if the tag is inside the target type mask, process foreach (var percept in perceptionOwner.Perception.Percepts.Values) { IPerceivable perceivable = percept.Entity.GetComponent <IPerceivable>(); if (perceivable != null && ((perceivable.Tag & TargetType) != 0) && (Vector3.Magnitude(percept.Entity.transform.position - positionSource.GetPosition()) <= Radius)) { if (percept.Entity != Source.GetOwner() || IncludeSelf) { IHasStats target = percept.Entity.GetComponent <IHasStats> (); if (target != null) { target.ModifyStat(TargetStat, Modifier, FlatValue, baseValue); } } } } }