예제 #1
0
    public static bool DestroyOnCollide(
        GameObject target,
        SpellPrefabManager src,
        List <string> ignore = null,
        bool reverse_ignore  = false)
    {
        if (ignore != null)
        {
            if (GameplayStatics.ObjHasTag(target, ignore, reverse_ignore))
            {
                return(false);
            }
        }

        if (src)
        {
            if (target != src.GetOwner() && !SpellVerifySameOwnership(target, src.GetOwner()))
            {
                GameObject.Destroy(src.gameObject);
                return(true);
            }
        }

        return(false);
    }
예제 #2
0
 public static void PullTargetToSrc(
     GameObject target,
     GameObject src,
     float pull_str,
     List <GameObject> objs_to_ignore,
     List <string> tags_to_ignore,
     bool negate_ignore = false)
 {
     if (GameplayStatics.ObjHasTag(target, tags_to_ignore, negate_ignore))
     {
         return;
     }
     if (target.GetComponent <Rigidbody2D>() && !GameplayStatics.IsObjInList(target.gameObject, objs_to_ignore))
     {
         Vector3 pos   = src.transform.position;
         Vector3 enemy = target.transform.position;
         Vector3 dir   = pos - enemy;
         dir.Normalize();
         Vector3 newpos = (dir * 0.001f * pull_str);
         newpos = new Vector3(newpos.x, newpos.y, 0);
         target.transform.position += newpos;
         //target.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
         //target.GetComponent<Rigidbody2D>().angularVelocity = 0.0f;
         //target.GetComponent<Rigidbody2D>().AddForce(dir * m_PullStrength);
     }
 }
예제 #3
0
    public static bool CastSpellOnCollide(
        GameObject target,
        SpellPrefabManager src,
        Spell spell,
        Vector3?spawn_pos    = null,
        List <string> ignore = null,
        bool reverse_ignore  = false)
    {
        if (ignore != null)
        {
            if (GameplayStatics.ObjHasTag(target, ignore, reverse_ignore))
            {
                return(false);
            }
        }

        if (src)
        {
            if (target != src.GetOwner() && !SpellVerifySameOwnership(target, src.GetOwner()))
            {
                spell.CastSpell(src.GetOwner(), target, spawn_pos);
                return(true);
            }
        }

        return(false);
    }
예제 #4
0
    public static bool SpawnEffectOnCollide(
        GameObject target,
        SpellPrefabManager src,
        GameObject effect,
        List <string> ignore = null,
        bool reverse_ignore  = false)
    {
        if (ignore != null)
        {
            if (GameplayStatics.ObjHasTag(target, ignore, reverse_ignore))
            {
                return(false);
            }
        }

        if (src)
        {
            if (target != src.GetOwner() && !SpellVerifySameOwnership(target, src.GetOwner()))
            {
                GameObject fx = MonoBehaviour.Instantiate(effect);
                fx.transform.position = GameplayStatics.GetTriggerContactPoint(target, src.gameObject);
                return(true);
            }
        }

        return(false);
    }
예제 #5
0
    public static bool DamageOnCollide(
        GameObject target,
        SpellPrefabManager src,
        float damage,
        List <string> ignore            = null,
        GameplayStatics.DamageType type = GameplayStatics.DamageType.Normal)
    {
        if (ignore != null)
        {
            if (GameplayStatics.ObjHasTag(target, ignore))
            {
                return(false);
            }
        }

        if (src)
        {
            if (target != src.GetOwner() && !SpellVerifySameOwnership(target, src.GetOwner()))
            {
                GameplayStatics.ApplyDamage(target, damage, type);
                return(true);
            }
        }
        return(false);
    }
예제 #6
0
    private bool ShouldCollide(Collider2D other)
    {
        var gameObj            = other.gameObject;
        var rockCollide        = !ignoreRock && (gameObj).CompareTag("Rock");
        var shouldNotIgnore    = (rockCollide || GameplayStatics.ObjHasTag(gameObj, TagsToIgnore, true));
        var ignoreInstantiator = shouldNotIgnore && !other.gameObject.CompareTag(_instantiatorTag);

        return(ignoreInstantiator);
    }
예제 #7
0
    public override void SpellTriggerEnter(Collider2D target, GameObject src)
    {
        GameObject         target_obj = target.gameObject;
        SpellPrefabManager s_manager  = src.GetComponent <SpellPrefabManager>();


        if (target_obj != s_manager.GetOwner() && GameplayStatics.ObjHasTag(target_obj, SpellUtilities.room))
        {
            GameObject.Destroy(src);
        }
    }
예제 #8
0
    public override void SpellCollisionEnter(Collision2D target, GameObject src)
    {
        Debug.Log("CollisionEnter");
        GameObject         target_obj = target.gameObject;
        SpellPrefabManager s_manager  = src.GetComponent <SpellPrefabManager>();

        SpellUtilities.CastSpellOnCollide(target.gameObject, s_manager, m_SpellToCast, spawn_pos: GameplayStatics.GetTriggerContactPoint(target.gameObject, src), SpellUtilities.invalid);
        if (target_obj != s_manager.GetOwner() && !GameplayStatics.ObjHasTag(target_obj, SpellUtilities.invalid))
        {
            GameObject.Destroy(src);
        }
    }
예제 #9
0
    public override void OnCollisionHitEvent(Collision2D collision, GameObject src, OnCollisionData data)
    {
        GameObject target_obj = collision.gameObject;

        Debug.Log("invalids = ");
        foreach (var str in data.m_DestroySelfData.m_ValidHitActors)
        {
            Debug.Log(str);
        }
        Debug.Log("Hitted Actor tag = " + collision.gameObject.tag);
        SpellPrefabManager s_manager = src.GetComponent <SpellPrefabManager>();

        if (target_obj != s_manager.GetOwner() && GameplayStatics.ObjHasTag(target_obj, data.m_DestroySelfData.m_ValidHitActors))
        {
            GameObject.Destroy(src);
        }
    }
예제 #10
0
    public override void SpellTriggerEnter(Collider2D target, GameObject src)
    {
        GameObject         target_obj = target.gameObject;
        SpellPrefabManager s_manager  = src.GetComponent <SpellPrefabManager>();

        if (m_OnHitEffect)
        {
            SpellUtilities.SpawnEffectOnCollide(target_obj, s_manager, m_OnHitEffect, SpellUtilities.invalid2);
        }
        SpellUtilities.DamageOnCollide(target_obj, s_manager, m_Damage, SpellUtilities.invalid2);


        if (target_obj != s_manager.GetOwner() && !GameplayStatics.ObjHasTag(target_obj, SpellUtilities.invalid2))
        {
            GameObject.Destroy(src);
        }

        // SpellUtilities.DestroyOnCollide(target_obj, s_manager, SpellUtilities.invalid2, true);
        //if (target_obj != s_manager.GetOwner() && !GameplayStatics.ObjHasTag(target_obj, SpellUtilities.invalid))
        //    GameObject.Destroy(src);
    }
예제 #11
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        List <string> tags_to_ignore = new List <string>()
        {
            "Untagged", "Room", "SpellUninteractive", "Item"
        };

        if (other.CompareTag("SpellInteractive"))
        {
            GameObject owner = other.gameObject.GetComponent <SpellPrefabManager>().GetOwner();
            if (owner == GetInstantiator())
            {
                return;
            }
        }
        if (GameplayStatics.ObjHasTag(other.gameObject, tags_to_ignore, true) && !GetInstantiator().CompareTag(other.gameObject.tag))
        {
            GameplayStatics.ApplyDamage(other.gameObject, 10);
            Destroy(gameObject);
        }
    }