Пример #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        NanitoControllerScript nanito = GetComponent <NanitoControllerScript> ();

        if (collision.gameObject.tag == "bullet")
        {
            Destroy(this.gameObject);
        }
    }
Пример #2
0
    void Update()
    {
        NanitoControllerScript nanito = GetComponent <NanitoControllerScript> ();

        if (ground == true)
        {
            anim.SetBool("ground", true);
        }
    }
Пример #3
0
    void Update()
    {
        NanitoControllerScript nanito = GetComponent <NanitoControllerScript> ();
        BulletScript           bullet = GetComponent <BulletScript> ();

        if (count >= 3 && hitByShield == true)
        {
            Destroy(this.gameObject);
        }
    }
Пример #4
0
    void Shoot()
    {
        //Debug.Log ("Test");
        Vector2 firePointPosition = new Vector2(firePoint.position.x, firePoint.position.y);

        NanitoControllerScript nanito = nanitoGO.GetComponent <NanitoControllerScript>();

        //Debug.Log ("Test");

        clone = (GameObject)Instantiate(projectile, firePointPosition, Quaternion.identity);
        //clone.tag = "bullet";
        if (nanito.facingRight)
        {
            clone.gameObject.GetComponent <Rigidbody2D> ().velocity = transform.right * speed;
        }
        else
        {
            clone.gameObject.GetComponent <Rigidbody2D> ().velocity = -transform.right * speed;
        }
    }
Пример #5
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        MetalCell metalCell           = collision.gameObject.GetComponent <MetalCell>();
        NanitoControllerScript nanito = collision.gameObject.GetComponent <NanitoControllerScript>();



        if (collision.gameObject.tag == "Enemy")
        {
            Destroy(this.gameObject);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "orange")
        {
            Destroy(this.gameObject);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "red")
        {
            Destroy(this.gameObject);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "blue")
        {
            Destroy(this.gameObject);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "metal")
        {
            metalCell.count++;
            Destroy(this.gameObject);
        }

        if (collision.gameObject.tag == "platform")
        {
            Destroy(this.gameObject);
        }

        if (collision.gameObject.tag == "lever")
        {
            Destroy(this.gameObject);
        }


        if (collision.gameObject.tag == "lever1")
        {
            Destroy(this.gameObject);
        }

        if (collision.gameObject.tag == "lever")
        {
            if (LeverScript.hitcount == 2)
            {
                RobotArm.move       = true;
                collision.isTrigger = true;
            }
            else
            {
                LeverScript.hitcount += 1;
            }
        }

        if (collision.gameObject.tag == "lever1")
        {
            if (LeverScript.hitcount1 == 2)
            {
                RobotArm.move1      = true;
                collision.isTrigger = true;
            }
            else
            {
                LeverScript.hitcount1 += 1;
            }
        }
    }
Пример #6
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        HealthScript           playerHealth = GetComponent <HealthScript> ();
        OrangeCell             orangeCell   = collision.gameObject.GetComponent <OrangeCell>();
        RedCell                redCell      = collision.gameObject.GetComponent <RedCell>();
        BlueCell               blueCell     = collision.gameObject.GetComponent <BlueCell>();
        NanitoControllerScript nanito       = nanitoGO.GetComponent <NanitoControllerScript>();

        if (collision.gameObject.tag == "orange")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, nanito.respawnPosX, nanito.respawnPosY, true);
                }
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "red")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(redCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "blue")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(blueCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }
    }