Example #1
0
    void OnTriggerEnter2D(Collider2D collider2d)
    {
        if (collider2d.gameObject.CompareTag("Player"))
        {
            BuildPlayer.Instance.gameStats.PowerLight += powerLight;

            int     tempAmount = powerLight * COLOR_AMOUNT_MULTIPLER;
            Color32 tempColor  = LightController.Instance.Color;
            if ((tempColor.r + tempAmount) < 255 &&
                (tempColor.g + tempAmount) < 255 &&
                (tempColor.b + tempAmount) < 255)
            {
                tempColor = new Color32((byte)(tempColor.r + tempAmount),
                                        (byte)(tempColor.g + tempAmount),
                                        (byte)(tempColor.b + tempAmount),
                                        tempColor.a);
                LightController.Instance.Color = tempColor;
            }
            if (gameObject.transform.parent)
            {
                DestroyParent dp = gameObject.transform.parent.GetComponent <DestroyParent>();
                if (dp)
                {
                    dp.RemoveChild(gameObject);
                }
            }
            Destroy(gameObject);
        }
    }
Example #2
0
 //Método que destruye al gameObject al morir.
 public void Dead()
 {
     DropObjectOnDeath drop = GetComponent<DropObjectOnDeath>();
     if (drop != null) drop.DropObject();
     DestroyParent destroy = GetComponent <DestroyParent>();
     if (destroy != null) destroy.DestroyP();
     AudioToPlay audio = GetComponent<AudioToPlay>();
     if (audio != null) audio.SendAudioToPlay(); 
     if (tag == "Player") GameManager.instance.Respawn();
     else Destroy(gameObject);
 }
Example #3
0
 private void OnTriggerEnter2D(Collider2D collider2d)
 {
     toDestroy = collider2d.transform;
     toDestroy.gameObject.SetActive(false);
     if (toDestroy.parent)
     {
         DestroyParent dp = toDestroy.parent.GetComponent <DestroyParent>();
         if (dp)
         {
             dp.RemoveChild(toDestroy.gameObject);
         }
     }
     Destroy(toDestroy.gameObject);
 }
Example #4
0
    //Cuando coincide con un obstaculo lo destruye, y acto seguido se destruye ella misma si choca con cualquier otra cosa != jugador se destruye
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag.Equals("Obstacle"))
        {
            Destroy(collision.gameObject);
            //Elimina las restricciones de movimiento cuando el jugador esta pegado a una pared y esta se destruye.
            GameManager.instance.ReturnPlayer().GetComponent <PlayerMovement>().RemoveRestrictions();
        }
        DestroyParent parentD = GetComponent <DestroyParent>();

        if (parentD != null)
        {
            parentD.DestroyP();
        }
        Destroy(this.gameObject);
    }