예제 #1
0
파일: Spell.cs 프로젝트: NerdDev/Hackmobile
 public void Activate(IAffectable caster, params GridSpace[] space)
 {
     Activate(new SpellCastInfo(caster)
     {
         TargetSpaces = space
     });
 }
예제 #2
0
파일: Spell.cs 프로젝트: NerdDev/Hackmobile
 public void Activate(IAffectable caster, params IAffectable[] targets)
 {
     Activate(new SpellCastInfo(caster)
     {
         TargetObjects = targets
     });
 }
예제 #3
0
    private void OnCollisionEnter(Collision other)
    {
        Vector3 contactPoint = other.GetContact(0).point;
        // Approximate the time of the collision,
        // taking in account the possibility of currently being faster due to catching up
        float timeOfCollision = lastTime +
                                (lastPosition - _rigidbody.position).magnitude / lastVelocity.magnitude;

        if (timeOfCollision > _deathTime)
        {
            Kill(DeathCause.Timeout, _deathTime);
            return;
        }

        IAffectable affectable = other.collider.GetComponent <IAffectable>();

        if (affectable != null)
        {
            affectable.Apply(_effect, timeOfCollision, -other.relativeVelocity, contactPoint);
            Kill(DeathCause.Contact, timeOfCollision);
        }
        else if (_bounces > 0)
        {
            _bounces--;
            if (_bounces == 0)
            {
                SetBouncyness(false);
            }
            AddPositionToRenderer(contactPoint);
        }
        else
        {
            Kill(DeathCause.Contact, timeOfCollision);
        }
    }
예제 #4
0
    public SpellCastInfo(List <SpellAspect> aspects)
    {
        int numLoc = 0;
        int numObj = 0;

        aspects.ForEach(aspect =>
        {
            if (aspect.Targeter.Style == TargetingStyle.TargetLocation)
            {
                numLoc = Math.Max(numLoc, aspect.Targeter.MaxTargets);
            }
            if (aspect.Targeter.Style == TargetingStyle.TargetObject)
            {
                numObj = Math.Max(numObj, aspect.Targeter.MaxTargets);
            }
        });
        // GridSpace targets overlap with objects
        numLoc -= numObj;
        if (numLoc < 0)
        {
            numLoc = 0;
        }
        _targetSpaces  = new GridSpace[numLoc];
        _targetObjects = new IAffectable[numObj];
    }
예제 #5
0
    public EffectInstance NewInstance(IAffectable caster, IAffectable target = null)
    {
        EffectInstance instance = this.Copy <EffectInstance>();

        instance.IsActive = true;
        instance.target   = target;
        instance.caster   = caster;
        instance.initialize();
        return(instance);
    }
예제 #6
0
 public void Target(IAffectable target)
 {
     if (spellTargets.Contains(target))
     {
         RemoveTarget(target);
     }
     else
     {
         AddTarget(target);
     }
 }
예제 #7
0
 internal void RemoveTarget(IAffectable target)
 {
     spellTargets.Remove(target);
     if (target is NPC)
     {
         foreach (GameObject block in ((NPC)target).GridSpace.Blocks)
         {
             block.renderer.sharedMaterial = NormalShaderGridspace;
         }
     }
 }
예제 #8
0
 internal void AddTarget(IAffectable target)
 {
     spellTargets.Add(target);
     if (target is NPC)
     {
         foreach (GameObject block in ((NPC)target).GridSpace.Blocks)
         {
             block.renderer.sharedMaterial = GlowShaderGridSpace;
         }
     }
 }
예제 #9
0
 private void Leave(IAffectable interactor)
 {
     if (this._affectables.TryGetValue(interactor, out int effectID))
     {
         this.Leave(interactor, effectID);
     }
     else
     {
         // never supposed to happen.
         Debug.LogError($"{this.name}: was left by an unknown interactor {interactor.name}.");
     }
 }
예제 #10
0
 public virtual void ApplyEffect(IAffectable caster, EffectInstance effect)
 {
     if (effect.TurnsToProcess != 0)
     {
         if (ContainsKey(effect.Name))
         {
             this[effect.Name] = this[effect.Name].Merge(effect);
         }
         else
         {
             this.Add(effect.Name, effect.ActivateOnObject(caster, owner));
         }
     }
     else
     {
         effect.ActivateOnObject(caster, owner);
     }
 }
예제 #11
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Bomb bomb = collision.collider.GetComponent <Bomb>();

        if (bomb != null)
        {
            Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, radius);

            for (int i = 0; i < colliders.Length; i++)
            {
                IAffectable affectable = colliders[i].GetComponent <IAffectable>();

                if (affectable != null)
                {
                    affectable.OnActivate();
                }
            }
        }
    }
예제 #12
0
 public virtual void Remove(IAffectable o)
 {
 }
예제 #13
0
 public virtual void Init(IAffectable target)
 {
 }
예제 #14
0
 public virtual void Apply(IAffectable target)
 {
 }
예제 #15
0
파일: Spell.cs 프로젝트: NerdDev/Hackmobile
 public SpellCastInfo GetCastInfoPrototype(IAffectable caster)
 {
     return(new SpellCastInfo(caster, CastInfo));
 }
예제 #16
0
    public EffectInstance ActivateOnObject(IAffectable caster, IAffectable o)
    {
        EffectInstance instance = NewInstance(caster, o);

        return(instance);
    }
예제 #17
0
 public static void BindTo(this IAffectable target, IAffector affector)
 {
     target.BindAffectorPose = Matrix.Invert(affector.GlobalPose);
     target.Affector         = affector;
     affector.Affectable     = target;
 }
예제 #18
0
 public AppliedEffects(IAffectable owner)
 {
     this.owner = owner;
 }
예제 #19
0
 public static void UnBindFrom(this IAffectable target, IAffector affector)
 {
     target.BindAffectorPose = Matrix.Identity;
     target.Affector         = null;
     affector.Affectable     = null;
 }
예제 #20
0
 public SpellCastInfo(IAffectable caster)
 {
     Caster = caster;
 }
예제 #21
0
    //public void ApplyEffect(EffectInstance effect)
    //{
    //    Effects.ApplyEffect(effect);
    //}

    public void ApplyEffect(IAffectable caster, EffectInstance effect)
    {
        Effects.ApplyEffect(caster, effect);
    }
예제 #22
0
 public SpellCastInfo(IAffectable caster, SpellCastInfo rhs)
 {
     Caster         = caster;
     _targetSpaces  = new GridSpace[rhs.TargetSpaces.Length];
     _targetObjects = new IAffectable[rhs.TargetObjects.Length];
 }
예제 #23
0
 private void Leave(IAffectable interactor, int effectID)
 {
     interactor.CancelCanTrigger(effectID);
     this._affectables.Remove(interactor);
 }
예제 #24
0
파일: Spell.cs 프로젝트: NerdDev/Hackmobile
 public void Activate(IAffectable caster)
 {
     Activate(new SpellCastInfo(caster));
 }
예제 #25
0
 /// <summary>
 /// Extension for <see cref="IAffectable.AffectBy"/>
 /// </summary>
 public static void Affect <TEffect>(this TEffect effect, IAffectable <TEffect> affectable) where TEffect : Effect
 {
     affectable.AffectBy(effect);
 }