예제 #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
    }
예제 #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);
            }
        }
    }
예제 #4
0
    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);
        }
    }
예제 #6
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        RubyController controller = collision.GetComponent <RubyController>();

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

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

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

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

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

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

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

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

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
예제 #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
        }
    }
예제 #16
0
    private void OnCollisionExit2D(Collision2D collision)
    {
        RubyController rubyController = collision.gameObject.GetComponent <RubyController>();

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

        if (player != null)
        {
            player.ChangeHealth(-1);
        }
    }
예제 #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);
        }
    }
예제 #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);
        }
    }
예제 #21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

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

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

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

        if (controller != null && controller.health < controller.maxHealth)
        {
            controller.ChangeHealth(1);
            Destroy(gameObject);
        }
    }
예제 #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);
        }
    }
예제 #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);
        }
    }
예제 #27
0
    void OnTriggerStay2D(Collider2D other)
    {
        RubyController controller = other.GetComponent <RubyController>();

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

        if (gController != null)
        {
            gController.ChangeHealth(-1);
            Debug.Log(gController.gHealth);
        }
    }
예제 #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
        }
    }