void Update()
 {
     if (Input.GetKeyDown(KeyCode.T))
     {
         //StatusEffect_Stunned.Create(gameObject, StunnedObj, 3f);
         StatusEffect_Knokback.Create(gameObject, Vector2.up, GM.testcur);
     }
 }
Exemple #2
0
    private void CheckOverlap()
    {
        Collider2D[] overlaps = Physics2D.OverlapBoxAll(transform.position, size, 0f, layerMask);

        if (overlaps == null)
        {
            return;
        }

        for (int i = 0; i < overlaps.Length; i++)
        {
            Rigidbody2D rb2D = overlaps[i].GetComponent <Rigidbody2D>();

            var mob = overlaps[i].GetComponent <Mob_Base>();

            if (mob != null && rb2D != null)
            {
                //Destroy(mob.gameObject);
                mob.GetComponent <IDamage>().Hit(new AttackData(Damage));
                StatusEffect_Knokback.Create(mob.gameObject, Vector2.up, curve);
            }

            var corpse = overlaps[i].GetComponent <Corpse>();

            if (corpse != null && rb2D != null && !corpses.Contains(corpse))
            {
                rb2D.velocity    = new Vector2(0, speed - corpseFallSpeed);
                rb2D.isKinematic = true;
                corpses.Add(corpse);
                corpse.DestroyOfTime(3f, () => { corpses.Remove(corpse.GetComponent <Corpse>()); });
            }

            if (overlaps[i].CompareTag("Player"))
            {
                PlayerStatus.AddEffect(new PlayerStatus_Knockback(SE_ID, gameObject, KnockbackMode.Strong, true, Vector2.up, curve));
                dt += Time.fixedDeltaTime;
                if (dt > 0.1f)
                {
                    dt = 0;
                    PlayerStats.Inst.Damage(new AttackData(Damage));
                }
                return;
            }
        }
    }
    //public static void CreateNormal(GameObject o, Vector2 d) => Create(o, d, 3, 0.5f);
    //public static void CreateSuper(GameObject o, Vector2 d) => Create(o, d, 4, 0.5f);

    public static void Create(GameObject obj, Vector2 dir, AnimationCurve power)
    {
        var SE_Obj = obj.GetComponent <StatusEffect_Object>();

        if (SE_Obj is null)
        {
            return;
        }

        StatusEffect_Knokback knokback = obj.GetComponent <StatusEffect_Knokback>();

        if (knokback.IsNull())
        {
            knokback = obj.AddComponent <StatusEffect_Knokback>();
            knokback.destroy_timer = new YCTimerData(power.keys[power.length - 1].time, () => Destroy(knokback));
        }

        knokback.priority = 9;
        knokback.mDir2d   = dir;
        knokback.pow      = power;

        YCTimer.Add(knokback.destroy_timer);
    }