예제 #1
0
 protected override ActionBlock[] GetBlocks()
 {
     return new [] {
         new ActionBlock("Add Effect", () => {
             EffectHandler handler = (EffectHandler) target;
             if (GUILayout.Button("UnconsciousEffect"))
                 handler.AddEffect(new UnconsciousEffect(3));
             if (GUILayout.Button("BurnEffect"))
                 handler.AddEffect(new BurnEffect());
         })
     };
 }
예제 #2
0
    public override void OnUpdate()
    {
        if (timer > 0)
        {
            timer--;
        }
        else
        {
            timer = 20;
            health.Damage(new DamageBase(Handler.gameObject, 2));

            if (firstTranslate)
            {
                foreach (Collider2D collider in Handler.gameObject.GetComponent <NearestObjects>().NearestColliders)
                {
                    EffectHandler handler = collider.gameObject.GetComponent <EffectHandler>();
                    if (handler != null)
                    {
                        handler.AddEffect(new BurnEffect());
                    }
                }
                firstTranslate = false;
            }
        }
    }
예제 #3
0
    private IEnumerator DamageRoutine()
    {
        var damageFilter = GetComponent <DamageFilter>();

        damageFilter.IsInvulnerable = true;

        float blinkTime     = 0.1f;
        float flashDuration = 0.15f;
        float blinkDuration = 0.75f;

        effectsHandler.AddEffect(new FlashEffect(flashDuration));
        yield return(new WaitForSeconds(flashDuration));

        effectsHandler.AddEffect(new BlinkEffect(blinkDuration, blinkTime));
        yield return(new WaitForSeconds(blinkTime));

        damageFilter.IsInvulnerable = false;
    }
예제 #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        EffectHandler handler = other.gameObject.GetComponent <EffectHandler>();

        if (handler != null)
        {
            handler.AddEffect(new UnconsciousEffect(float.Parse(GetComponent <SpawnedData>().spawnedData[0])));
            Destroy(gameObject);
        }
    }
예제 #5
0
    public override bool OnAdded()
    {
        health = Handler.gameObject.GetComponent <Health>();
        if (health == null)
        {
            return(false);
        }

        NearestObjects nearestObjects = Handler.gameObject.GetComponent <NearestObjects>();

        if (nearestObjects == null)
        {
            return(false);
        }

        nearestObjects.GetEventSystem <NearestObjects.OnNearestEnter>().SubcribeEvent(e => {
            EffectHandler handler = e.Collider.gameObject.GetComponent <EffectHandler>();
            if (handler != null)
            {
                handler.AddEffect(new BurnEffect());
            }
        });

        List <Collider2D> colliders = Utils.GetComponentsRecursive <Collider2D>(Handler.gameObject);

        if (Handler.gameObject.GetComponent <MeshFilter>() != null && Handler.gameObject.GetComponent <MeshFilter>().mesh == GameManager.singleton.OnePlane)
        {
            for (int x = 2; x < Handler.gameObject.transform.localScale.x; x += 4)
            {
                for (int y = 2; y < Handler.gameObject.transform.localScale.y; y += 4)
                {
                    Collider2D[] touching = Physics2D.OverlapPointAll(
                        Utils.ToVector2(Handler.gameObject.transform.position) + new Vector2(x, y),
                        GameManager.singleton.TrapLayerMask);

                    foreach (Collider2D collider in touching)
                    {
                        if (colliders.Exists(i => i.Equals(collider)))
                        {
                            emitters.Add(MonoBehaviour.Instantiate(GameManager.singleton.FireObjectParticle,
                                                                   Handler.gameObject.transform.position + new Vector3(x, y, -1), new Quaternion(),
                                                                   Handler.gameObject.transform));
                        }
                    }
                }
            }
        }
        else
        {
            int mask = LayerMask.GetMask(LayerMask.LayerToName(Handler.gameObject.layer));
            for (int x = -200; x < 200; x += 10)
            {
                for (int y = -200; y < 200; y += 10)
                {
                    Collider2D[] touching = Physics2D.OverlapPointAll(
                        Utils.ToVector2(Handler.gameObject.transform.position) + new Vector2(x, y),
                        mask);

                    foreach (Collider2D collider in touching)
                    {
                        if (colliders.Exists(i => i.Equals(collider)))
                        {
                            emitters.Add(MonoBehaviour.Instantiate(GameManager.singleton.FireObjectParticle,
                                                                   Handler.gameObject.transform.position + new Vector3(x, y, -1), new Quaternion(),
                                                                   Handler.gameObject.transform));
                        }
                    }
                }
            }
        }

        return(true);
    }