Exemple #1
0
    //Get more cogs
    public void MoreCogs()
    {
        //Give the player 20 more cogs
        ruby.cogs           += 20;
        ruby.cogCounter.text = "Cogs: " + ruby.cogs.ToString();

        //COST: Lower the player health by 2
        ruby.ChangeHealth(-2);

        ruby.choices     = false; //Close the buttons
        ruby.canbuy      = false; //Stop from overbuying
        ruby.defaultLoss = true;  //Display default message when the player has no more chances
    }
Exemple #2
0
    // collission checker
    private void OnTriggerEnter2D(Collider2D other)
    {
        RubyController        controller  = other.GetComponent <RubyController>();
        RubyPlatformerControl controller2 = other.GetComponent <RubyPlatformerControl>();

        if (controller != null)
        {
            if (controller.health < controller.maxHealth)
            {
                // breytir health, eyðir objectinu, synir effect og spilar hljoðið
                controller.ChangeHealth(1);
                Destroy(gameObject);
                HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem;
                HealthCollisionEffect.Play();

                controller.PlaySound(collectedClip);
            }
        }

        if (controller2 != null)
        {
            if (controller2.health < controller2.maxHealth)
            {
                // breytir health, eyðir objectinu, synir effect og spilar hljoðið
                controller2.ChangeHealth(1);
                Destroy(gameObject);
                HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem;
                HealthCollisionEffect.Play();

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

        if (timer < 0)
        {
            direction = -direction;
            timer     = changeTime;
        }
        Vector2 position = rigidbody2D.position;

        if (vertical)
        {
            position.y = position.y + Time.deltaTime * speed * direction;
        }
        else
        {
            position.x = position.x + Time.deltaTime * speed;
        }
        rigidbody2D.MovePosition(position);


        void OnCollisionEnter2D(Collision2D other)
        {
            RubyController player = other.gameObject.GetComponent <RubyController>();

            if (player != null)
            {
                player.ChangeHealth(-1);
            }
        }
    }
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if ((controller != null) && (controller.CurrentHealth > 0))
        {
            controller.ChangeHealth(-amount);
        }
    }
    void OnCollisionEnter2D(Collision2D other)
    {
        RubyController ruby = other.gameObject.GetComponent <RubyController>();

        if (ruby)
        {
            ruby.ChangeHealth(-damage);
        }
    }
Exemple #6
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        RubyController controller = collision.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-25f);
        }
    }
Exemple #7
0
    void attck(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Exemple #8
0
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(areaDamage);
        }
    }
Exemple #9
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        RubyController controller = collision.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(healthChangeAmount);
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Exemple #11
0
    //触发检测
    private void OnCollisionEnter2D(Collision2D collision)
    {
        RubyController rubyController = collision.gameObject.GetComponent <RubyController>();//注意这里跟trigger的不太相同。

        if (rubyController != null)
        {
            rubyController.ChangeHealth(-1);
        }
    }
    void OnCollisionStay2D(Collision2D collision)
    {
        RubyController rc = collision.gameObject.GetComponent <RubyController>();

        if (rc)
        {
            rc.ChangeHealth(-1);
        }
    }
Exemple #13
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        RubyController rb = collision.GetComponent <RubyController>();

        if (rb != null)
        {
            rb.ChangeHealth(-1);
        }
    }
Exemple #14
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        RubyController player = collision.gameObject.GetComponent <RubyController>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
Exemple #15
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        RubyController player = other.gameObject.GetComponent <RubyController>(); // get the script from the player

        if (player != null)                                                       // if is not empty the variable
        {
            player.ChangeHealth(-1);                                              // damages the player
        }
    }
Exemple #16
0
    private void OnCollisionExit2D(Collision2D collision)
    {
        RubyController rubyController = collision.gameObject.GetComponent <RubyController>();

        if (rubyController != null)
        {
            rubyController.ChangeHealth(-1);
        }
    }
Exemple #17
0
    void OnCollisionEnter2D(Collision2D other)
    {
        RubyController player = other.gameObject.GetComponent <RubyController>();

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
Exemple #18
0
    void Trigger(GameObject other)
    {
        RubyController ruby = other.GetComponent <RubyController>();

        if (ruby)
        {
            ruby.ChangeHealth(-damage);
        }
    }
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null && controller.health >= 0)
        {
            controller.ChangeHealth(-1);
        }
    }
Exemple #20
0
    // Start is called before the first frame update
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController ruby = other.GetComponent <RubyController>();

        if (ruby != null)
        {
            ruby.ChangeHealth(-1);
        }
    }
Exemple #21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(1);
            Destroy(gameObject);
        }
    }
Exemple #22
0
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController> ();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
            audioSource.PlayOneShot(clip, volume);
        }
    }
Exemple #23
0
    void OnTriggerEnter2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-10);
            controller.PlaySound(collectedClip);
        }
    }
Exemple #24
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        RubyController controller = collision.GetComponent <RubyController>();

        if (controller != null && controller.health < controller.maxHealth)
        {
            controller.ChangeHealth(1);
            Destroy(gameObject);
        }
    }
Exemple #25
0
    // For every second on the damage zone, the player takes 1
    private void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        // controller handles if invincibility is active
        if (controller != null)
        {
            controller.ChangeHealth(-1);
        }
    }
Exemple #26
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        RubyController rubyController = collision.GetComponent <RubyController>();

        if (rubyController != null)
        {
            rubyController.ChangeHealth(-1);
            Debug.Log("ruby's health:" + rubyController.health);
        }
    }
Exemple #27
0
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null)
        {
            controller.ChangeHealth(-1);
            controller.PlaySound(hitFromDamageZoneClip);
        }
    }
Exemple #28
0
    void OnTriggerStay2D(Collider2D iOther)
    {
        RubyController gController = iOther.GetComponent <RubyController>();

        if (gController != null)
        {
            gController.ChangeHealth(-1);
            Debug.Log(gController.gHealth);
        }
    }
Exemple #29
0
    // Start is called before the first frame update
    void OnTriggerEnter2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

        if (controller != null && controller.ChangeHealth(1, false))
        {
            Destroy(gameObject);
            controller.PlaySound(collectedClip);
        }
    }
    void OnCollisionEnter2D(Collision2D other)
    {
        RubyController player = other.gameObject.GetComponent <RubyController> ();

        if (player != null)
        {
            player.ChangeHealth(-1);
            player.PlaySound(collectedClip);    //ruby getting hurt
        }
    }