Example #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        int realDmg             = DealtDamage;
        PotionEffectsScript pes = gameObject?.transform?.parent?.gameObject?.GetComponent <PotionEffectsScript>();

        if (pes != null)
        {
            realDmg = (int)(realDmg * pes.Strength);
        }

        Collider2D[] colliders = Physics2D.OverlapBoxAll(new Vector2(gameObject.transform.position.x + collider.offset.x, gameObject.transform.position.y + collider.offset.y), new Vector2(collider.bounds.size.x * 2, collider.bounds.size.y * 2), 0, AffectedLayer);
        for (int i = 0; i < colliders.Length; i++)
        {
            if ((AffectedLayer.value & (1 << colliders[i].gameObject.layer)) > 0)
            {
                HealthPointsScript hps = (colliders[i].GetComponent(typeof(HealthPointsScript)) as HealthPointsScript);
                if (hps != null)
                {
                    hps.GetHit(realDmg);
                }
                if (SelfDestroy)
                {
                    this.gameObject.SetActive(false);
                }
            }
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject          collider = collision.collider.gameObject;
        PotionEffectsScript pe       = collider.GetComponent <PotionEffectsScript>();

        if (pe != null)
        {
            switch (Type)
            {
            case PotionEffect.Agility:
                pe.ApplyAgility(Duration);
                break;

            case PotionEffect.Burning:
                pe.ApplyBurning(Duration);
                break;

            case PotionEffect.Frozen:
                pe.ApplyFrozen(Duration);
                break;

            case PotionEffect.Poison:
                pe.ApplyPoison(Duration);
                break;

            case PotionEffect.Strength:
                pe.ApplyStrength(Duration);
                break;
            }
            this.gameObject.SetActive(false);
        }
    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     animator = gameObject.GetComponent <Animator>();
     pool     = gameObject.GetComponent <ObjectPoolScript>();
     renderer = gameObject.GetComponent <SpriteRenderer>();
     Player   = GameObject.FindWithTag("Player");
     pc       = Player?.GetComponent <PlayerController>();
     pes      = GetComponent <PotionEffectsScript>();
 }
    // Start is called before the first frame update
    void Awake()
    {
        rigidbody2D = GetComponent <Rigidbody2D>();
        pes         = GetComponent <PotionEffectsScript>();
        attackD     = Damager.GetComponent <TemporalEnablerScript>();

        Player   = GameObject.FindWithTag("Player");
        pc       = Player?.GetComponent <PlayerController>();
        renderer = gameObject.GetComponent <SpriteRenderer>();
        animator = GetComponent <Animator>();
    }
    private void Awake()
    {
        damagerR  = AttackR.GetComponent <DamagerScript>();
        damagerL  = AttackL.GetComponent <DamagerScript>();
        damagerR2 = AttackR2.GetComponent <DamagerScript>();
        damagerL2 = AttackL2.GetComponent <DamagerScript>();
        attackR   = AttackR.GetComponent <TemporalEnablerScript>();
        attackL   = AttackL.GetComponent <TemporalEnablerScript>();
        attackR2  = AttackR2.GetComponent <TemporalEnablerScript>();
        attackL2  = AttackL2.GetComponent <TemporalEnablerScript>();
        hii       = SelectedItemDisplay.GetComponent <HeldItemImage>();
        cc2       = GetComponent <CapsuleCollider2D>();

        renderer    = GetComponent <SpriteRenderer>();
        rigidbody2D = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        inventory   = GetComponent <PlayerInventoryScript>();
        hps         = GetComponent <HealthPointsScript>();
        cam         = Camera.GetComponent <Camera>();
        pes         = GetComponent <PotionEffectsScript>();

        throwers.Clear();
        throwers.Add("BOMB", Thrower_Bomb.GetComponent <PlayerThrowScript>());
        throwers.Add("AF_P", Thrower_AF_P.GetComponent <PlayerThrowScript>());
        throwers.Add("AF_M", Thrower_AF_M.GetComponent <PlayerThrowScript>());
        throwers.Add("AF_F", Thrower_AF_F.GetComponent <PlayerThrowScript>());
        throwers.Add("AF_A", Thrower_AF_A.GetComponent <PlayerThrowScript>());
        throwers.Add("AF_H", Thrower_AF_H.GetComponent <PlayerThrowScript>());
        throwers.Add("PT_V", Thrower_PT_V.GetComponent <PlayerThrowScript>());
        throwers.Add("AR_R", Thrower_AR_R.GetComponent <PlayerThrowScript>());
        throwers.Add("AR_H", Thrower_AR_H.GetComponent <PlayerThrowScript>());
        throwers.Add("AR_F", Thrower_AR_F.GetComponent <PlayerThrowScript>());
        throwers.Add("AR_P", Thrower_AR_P.GetComponent <PlayerThrowScript>());
        throwers.Add("AR_M", Thrower_AR_M.GetComponent <PlayerThrowScript>());

        GroundCheck1 = GroundCheck + new Vector2(0.15f, 0f);
        GroundCheck2 = GroundCheck + new Vector2(-0.15f, 0f);

        //GOD MODE
        if (GodMode)
        {
            hps.IncreaseMax(100000);
            dmgMult = 10000;
            IncreaseAttackMult();
        }
    }
    // Update is called once per frame
    void Update()
    {
        Collider2D[] colliders = Physics2D.OverlapBoxAll(new Vector2(gameObject.transform.position.x, gameObject.transform.position.y), new Vector2(collider.bounds.size.x / 2, collider.bounds.size.y / 2), AffectedLayer);
        for (int i = 0; i < colliders.Length; i++)
        {
            if ((AffectedLayer.value & (1 << colliders[i].gameObject.layer)) > 0)
            {
                PotionEffectsScript pe = colliders[i].GetComponent <PotionEffectsScript>();

                if (pe != null)
                {
                    switch (Type)
                    {
                    case PotionEffect.Agility:
                        pe.ApplyAgility(Duration);
                        break;

                    case PotionEffect.Burning:
                        pe.ApplyBurning(Duration);
                        break;

                    case PotionEffect.Frozen:
                        pe.ApplyFrozen(Duration);
                        break;

                    case PotionEffect.Poison:
                        pe.ApplyPoison(Duration);
                        break;

                    case PotionEffect.Strength:
                        pe.ApplyStrength(Duration);
                        break;
                    }
                    this.gameObject.SetActive(false);
                }
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     pes = gameObject.GetComponent <PotionEffectsScript>();
 }