Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D colliderData)
    {
        // ORIGINAL
        HealthSystemAttribute healthScript = colliderData.gameObject.GetComponent <HealthSystemAttribute>();

        if (healthScript != null)
        {
            // subtract health from the player
            healthScript.ModifyHealth(healthChange);

            if (destroyWhenActivated)
            {
                Destroy(this.gameObject);
            }
        }

        // PROFE
        HealthSystemProfe healthScriptProfe = colliderData.gameObject.GetComponent <HealthSystemProfe>();

        if (healthScriptProfe != null)
        {
            // subtract health from the player
            healthScriptProfe.ModifyHealth(healthChange);

            if (destroyWhenActivated)
            {
                Destroy(this.gameObject);
            }
        }
    }
Beispiel #2
0
    private void Awake()
    {
        rb = GetComponent <Rigidbody2D>();

        animator = GetComponentInChildren <Animator>();
        if (animator == null)
        {
            Debug.LogError("Couldn't find Animator component for " + gameObject.name);
        }
        animatorObject = animator.gameObject;

        baseScaleX = transform.localScale.x;

        healthSystem = GetComponent <HealthSystemProfe>();

        // Si es enemigo, buscar al player
        if (isEnemy)
        {
            InitEnemy();
        }
    }