Exemplo n.º 1
0
    public override void OnStart(EffectInstance instance, EntityEffector effector)
    {
        var dir      = instance.GetTrigger <ImpactData>().Position - effector.Entity.transform.position;
        var velocity = dir.normalized * Speed;

        effector.Entity.GetComponent <MovableEntity>().ForceMove(velocity);
    }
Exemplo n.º 2
0
 public override void OnUpdate(EffectInstance instance, EntityEffector effector)
 {
     var impact = instance.GetTrigger <ImpactData>();
 }
Exemplo n.º 3
0
    IEnumerator EffectCoroutine(EffectInstance instance, EntityEffector effector)
    {
        // Setup force
        var movable = effector.Entity.GetComponent <MovableEntity>();
        var impact  = instance.GetTrigger <ImpactData>();

        if (impact is null)
        {
            yield break;
        }
        var dir = Vector2.zero;

        switch (ForceType)
        {
        case ForceType.Constant:
            dir = Impulse.normalized;
            break;

        case ForceType.Divergent:
            dir = effector.Entity.transform.position - impact.Position;
            break;

        case ForceType.ImpactDirection:
            dir = impact.Direction;
            break;
        }
        if (ConstraintX)
        {
            dir.x = 0;
        }
        if (ConstraintY)
        {
            dir.y = 0;
        }
        dir = dir.normalized;
        var f = dir * Impulse.magnitude * instance.Strength;

        movable.PhysicalControl = true;
        if (ForceApplyMode == ForceApplyMode.AddImpulse)
        {
            movable.AddForce(f, ForceMode2D.Impulse);
        }
        else if (ForceApplyMode == ForceApplyMode.ModifyMomentum)
        {
            movable.SetMomentum(f);
        }

        foreach (var t in Utility.Timer(Duration))
        {
            movable.PhysicalControl = true;
            yield return(null);
        }
        do
        {
            movable.PhysicalControl = true;
            yield return(null);
        }while (movable.EnableGravity && !movable.OnGround);
        if (effector.GetEffect <PhysicalEffect>() == null)
        {
            movable.PhysicalControl = false;
        }
        effector.RemoveEffect(instance.Effect);
    }