Exemple #1
0
        public override void ApplyEffect()
        {
            // get the base stat value of the user of this effect
            int baseValue = 0;

            if (StatBase != 0)               // prevents people forgetting to give a stat base name
            {
                IHasStats owner = Source.GetOwner().GetComponent <IHasStats>();
                if (owner != null)
                {
                    owner.TryGetStatValue(StatBase, out baseValue);                      // prevents the case where the statname doesn't exist
                }
            }

            // apply effect to target
            IHasTargetEffects targetSource = Source as IHasTargetEffects;

            if (targetSource != null)
            {
                if (targetSource.GetTarget() != null)
                {
                    IHasStats target = targetSource.GetTarget().GetComponent <IHasStats> ();
                    if (target != null)
                    {
                        target.ModifyStat(StatBase, TargetStat, Modifier, FlatValue, baseValue);
                    }
                }
            }
        }
Exemple #2
0
        public override void ApplyEffect()
        {
            // get the base stat value of the user of this effect
            int baseValue = 0;

            if (StatBase != "")               // prevents people forgetting to give a stat base name
            {
                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 targettable source
            IHasTargetEffects targetSource = Source as IHasTargetEffects;

            if (targetSource == 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 - targetSource.GetTarget().transform.position) <= Radius))
                {
                    if (percept.Entity != targetSource.GetTarget() || IncludeTarget)
                    {
                        IHasStats target = percept.Entity.GetComponent <IHasStats> ();
                        if (target != null)
                        {
                            target.ModifyStat(TargetStat, Modifier, FlatValue, baseValue);
                        }
                    }
                }
            }
        }
Exemple #3
0
        //void Temp(IAsyncOperation<IList<IResourceLocation>> op){
        //}

        /// <summary>
        /// apply the effect. override this for other extensions.
        /// </summary>
        public override void ApplyEffect()
        {
            Debug.Log("apply target prefab effect");
            //if (Prefab != null) {
            IHasTargetEffects targetSource = Source as IHasTargetEffects;

            if (targetSource != null)
            {
                if (targetSource.GetTarget() != null)
                {
                    //Addressables.LoadAssets<IResourceLocation> ("Meteor", null).Completed += Temp;
                    //Addressables.Instantiate<GameObject> ("Meteor.prefab",targetSource.GetTarget ().transform.position,Quaternion.identity);
                    GameObject.Instantiate(Prefab, targetSource.GetTarget().transform.position, Quaternion.identity);
                }
            }
            //}
        }