// Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;

        if (timer <= 0)
        {
            // Create explosion particle effect for a set duration before destroying self
            if (!explode)
            {
                gameObject.GetComponent <ParticleSystem>().Play();
                gameObject.GetComponent <SpriteRenderer>().enabled = false;
                timer   = 1f;
                explode = true;
                player  = GameObject.FindGameObjectWithTag("Player");

                // If distance to player is < 3, apply freeze and slow debuff
                if ((player != null) && (Vector3.Distance(player.transform.position, transform.position) < 3))
                {
                    player.GetComponent <PlayerHealth>().TakeDamage(power);
                    BuffFreeze freeze = player.AddComponent <BuffFreeze>();
                    player.GetComponent <BuffHandler>().AddBuff(freeze);

                    BuffSlow slow = player.AddComponent <BuffSlow>();
                    slow.SetBuffTimer(5f);
                    player.GetComponent <BuffHandler>().AddBuff(slow);
                }
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
 public void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && other.GetComponent <PlayerStats>().teamId != m_team)
     {
         players.Add(other.GetComponent <PlayerStats>());
         Globals.WriteLog("IceSkill3: Meto a " + other.GetComponent <PlayerStats>().id);
         BuffSlow bs = other.GetComponent <PlayerStats>().gameObject.AddComponent <BuffSlow>();
         bs.Init(m_ralentizacion, m_duration, m_skillId, m_handler.m_PlayerStats);
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && other.GetComponent <PlayerStats>().teamId != m_team)
     {
         BuffSlow buff = other.gameObject.AddComponent <BuffSlow>();
         buff.Init(100, 2f, m_skillId, m_handler.m_PlayerStats);
         GetComponent <ParticleSystem>().Stop();
         Destroy(gameObject, 1f);
     }
 }
Example #4
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     // If hit player, inflict slow for 3 seconds. Also destroy self
     if (collision.gameObject.tag == "Player")
     {
         BuffSlow slow = collision.gameObject.AddComponent <BuffSlow>();
         slow.SetBuffTimer(3f);
         collision.gameObject.GetComponent <BuffHandler>().AddBuff(slow);
         Destroy(gameObject);
     }
 }
Example #5
0
 public override void TransferBuff(GameObject target)
 {
     if ((gameObject.tag != "EnemyAttack") && (gameObject.tag != "Attack"))        // Messy quick fix
     {
         // Attach slow debuff to whatever this object instantiates if the instantiated object has a BuffHandler component
         if (target.GetComponent <BuffHandler>() != null)
         {
             BuffSlow transferSlow = target.AddComponent <BuffSlow>();
             transferSlow.Instantiated(true);
             transferSlow.SetBuffTimer(GetMaxBuffTimer());
             target.GetComponent <BuffHandler>().AddBuff(transferSlow);
         }
     }
 }
 private void ApplyDebuff(string[] tagName)
 {
     // This function finds all gameobjects with the given string[] tagName and applies the slow debuff to them
     for (int j = 0; j < tagName.Length; j++)
     {
         targets = GameObject.FindGameObjectsWithTag(tagName[j]);
         for (int i = 0; i < targets.Length; i++)
         {
             if (targets[i].GetComponent <BuffHandler>() != null)
             {
                 slow = targets[i].AddComponent <BuffSlow>();
                 slow.SetBuffTimer(power);
                 targets[i].GetComponent <BuffHandler>().AddBuff(slow);
             }
         }
     }
     targets = null; // Reset
 }
Example #7
0
 public override void TransferBuff(GameObject target)
 {
     // Whoever the projectile hits will have a buffslow applied to it
     if (target.GetComponent <BuffHandler>() != null)
     {
         if ((target.tag == "Player") || (target.tag == "Enemy") || (target.tag == "GunEnemy") || (target.tag == "Boss"))
         {
             if (Random.Range(0, 100) < slowChance)
             {
                 BuffSlow slow = target.AddComponent <BuffSlow>();
                 slow.SetBuffTimer(5f);
                 target.GetComponent <BuffHandler>().AddBuff(slow);
             }
         }
         else // When instantiating an object (likely projectile), give this buff to it. Untested on summoning enemies
         {
             target.GetComponent <BuffHandler>().AddBuff(target.AddComponent <BuffApplySlow>());
         }
     }
 }