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; } } }
void OnCollisionEnter2D(Collision2D collision) { bool hell = false; //collision with ff FerrofluidScript goo = collision.gameObject.GetComponent <FerrofluidScript> (); HealthScript playerHealth = GetComponent <HealthScript> (); FloorScript floor = collision.gameObject.GetComponent <FloorScript> (); PopUpScript popUp = collision.gameObject.GetComponent <PopUpScript> (); BossFight boss = collision.gameObject.GetComponent <BossFight> (); ShieldScript shield = collision.gameObject.GetComponent <ShieldScript> (); ShieldNumber shieldnumber = collision.gameObject.GetComponent <ShieldNumber> (); FfScript ffBottle = collision.gameObject.GetComponent <FfScript> (); WingsCounter wings = collision.gameObject.GetComponent <WingsCounter> (); RobotArm robot = GetComponent <RobotArm> (); OrangeCell orangeCell = collision.gameObject.GetComponent <OrangeCell>(); RedCell redCell = collision.gameObject.GetComponent <RedCell>(); BlueCell blueCell = collision.gameObject.GetComponent <BlueCell>(); MetalCell metalCell = collision.gameObject.GetComponent <MetalCell>(); MazePlatform maze = collision.gameObject.GetComponent <MazePlatform>(); //BridgePlatformScript bridge = GetComponent<BridgePlatformScript> (); if (collision.gameObject.tag == "orange") { // damagePlayer = true; // Debug.Log("shield not hit"); // if(playerHealth != null) // playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false); if (shieldGO.activeSelf == true) { damagePlayer = false; shieldHits--; metalCell.hitByShield = true; Debug.Log("shield hit"); //orangeCell = null; if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, true); } } else { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false); } } } if (collision.gameObject.tag == "red") { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(redCell.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.tag == "blue") { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(blueCell.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.tag == "metal") { // damagePlayer = true; // Debug.Log("shield not hit"); // if(playerHealth != null) // playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false); if (shieldGO.activeSelf == true) { damagePlayer = false; shieldHits--; metalCell.hitByShield = true; Debug.Log("shield hit"); } else { damagePlayer = true; Debug.Log("shield not hit"); if (playerHealth != null) { playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false); } } } if (floor != null) { damagePlayer = true; hell = true; } if (hell) { if (playerHealth != null) { playerHealth.Damage(floor.damage, respawnPosX, respawnPosY, false); } } if (collision.gameObject.name == "Checkpoint1") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint2") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint3") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } if (collision.gameObject.name == "Checkpoint4") { CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>(); respawnPosX = checkpoint.posX; respawnPosY = checkpoint.posY; Destroy(collision.gameObject.GetComponent <Collider2D>()); } // if (collision.gameObject.name == "atomo") { // popUp.showPopUp = true; // popUp.gameObject.GetComponent<Renderer>().enabled = false; // Destroy(popUp.gameObject.GetComponent<Collider2D>()); // } if (collision.gameObject.tag == "MovingPlatform") { this.transform.parent = collision.transform; } // if (collision.gameObject.tag == "lever"){ // RobotArm.move = true; // } // // if (collision.gameObject.tag == "lever1") { // RobotArm.move1 = true; // } if (collision.gameObject.tag == "Boss") { boss.gameObject.GetComponent <Renderer>().enabled = true; showPopUp = true; maxSpeed = 0; if (i == 5) { maxSpeed = 25; Destroy(boss.gameObject); boss.gameObject.GetComponent <Renderer>().enabled = false; } } if (collision.gameObject.tag == "Door") { Application.LoadLevel("Hidrofobia"); } if (wings != null) { wings.GetComponent <Renderer>().enabled = false; wings.GetComponent <PolygonCollider2D>().enabled = false; wingsCounter = 7; } if (collision.gameObject.tag == "shield") { ShieldCounterManager.AddShield(shieldnumber.shieldNumber); Destroy(shieldnumber.gameObject); shieldFlag = true; Debug.Log("Shield available"); } if (collision.gameObject.tag == "ffbottle") { FfCounterManager.AddFF(ffBottle.ffNumber); gunFlag = true; Destroy(ffBottle.gameObject); } //platform activator if (collision.gameObject.tag == "ActivatePlatform") { collision.gameObject.GetComponent <Animator>().enabled = true; } if (collision.gameObject.tag == "Boots") { collision.gameObject.GetComponent <Renderer>().enabled = false; collision.gameObject.GetComponent <PolygonCollider2D>().enabled = false; time = 5; } if (collision.gameObject.tag == "box") { bool founded = false; BoxController box = collision.gameObject.GetComponent <BoxController>(); box.Founded(true); Destroy(collision.gameObject); } if (collision.gameObject.tag == "Bridge1") { BridgePlatformScript.bridge1 = true; } if (collision.gameObject.tag == "Bridge2") { BridgePlatformScript.bridge2 = true; } if (collision.gameObject.tag == "Bridge3") { BridgePlatformScript.bridge3 = true; } if (collision.gameObject.tag == "Bridge4") { BridgePlatformScript.bridge4 = true; } if (collision.gameObject.tag == "Bridge5") { BridgePlatformScript.bridge5 = true; } if (collision.gameObject.tag == "Bridge6") { BridgePlatformScript.bridge6 = true; } if (collision.gameObject.tag == "Bridge7") { BridgePlatformScript.bridge7 = true; } if (collision.gameObject.name == "MetallicFloorFerroFluidMAP 159") { MazePlatform.ground = true; transform.parent = collision.transform; } }