// Use this for initialization void Start() { canons = this; if(SceneManager.GetActiveScene().name != "Tutorial") //We are not in the tutorial scene { if(this.transform.root.name == "Marine(Clone)") //This is a marine { for(int i = 0; i < 6; i++) //Loop 6 times, one for each cannon { if(SpawnAI.cannonLevel[i] == 1) //Check if the index in cannonLevel[i] is level 1 { allCannons[i].GetComponent<MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } else if(SpawnAI.cannonLevel[i] == 2) //Check if the index in cannonLevel[i] is level 2 { allCannons[i].GetComponent<MeshFilter>().mesh = mesh2; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 2; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelTwo++; //Increase the counter to use it later for scrap value } else if(SpawnAI.cannonLevel[i] == 3) //Check if the index in cannonLevel[i] is level 3 { allCannons[i].GetComponent<MeshFilter>().mesh = mesh3; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 3; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelThree++; //Increase the counter to use it later for scrap value } } } else if(this.transform.root.name == "Cargo(Clone)") //This is the cargo ship { for(int i = 0; i < 2; i++) //Run the loop 2 times, one for each cannon { if(SpawnAI.cannonLevel[i] == 1) { allCannons[i].GetComponent<MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } else if(SpawnAI.cannonLevel[i] == 2) { allCannons[i].GetComponent<MeshFilter>().mesh = mesh2; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 2; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelTwo++; //Increase the counter to use it later for scrap value } else if(SpawnAI.cannonLevel[i] == 3) { allCannons[i].GetComponent<MeshFilter>().mesh = mesh3; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 3; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelThree++; //Increase the counter to use it later for scrap value } } } } else //This is the tutorial, so we want all cannons to be level 1 { for(int i = 0; i < 6; i++) //Loop 6 times, one for each cannon { allCannons[i].GetComponent<MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent<AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } } }
public AudioSource sourceRight; //Audiosource for the right cannons // Use this for initialization void Start() { canons = this; if (SceneManager.GetActiveScene().name != "Tutorial") //We are not in the tutorial scene { if (this.transform.root.name == "Marine(Clone)") //This is a marine { for (int i = 0; i < 6; i++) //Loop 6 times, one for each cannon { if (SpawnAI.cannonLevel[i] == 1) //Check if the index in cannonLevel[i] is level 1 { allCannons[i].GetComponent <MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } else if (SpawnAI.cannonLevel[i] == 2) //Check if the index in cannonLevel[i] is level 2 { allCannons[i].GetComponent <MeshFilter>().mesh = mesh2; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 2; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelTwo++; //Increase the counter to use it later for scrap value } else if (SpawnAI.cannonLevel[i] == 3) //Check if the index in cannonLevel[i] is level 3 { allCannons[i].GetComponent <MeshFilter>().mesh = mesh3; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 3; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelThree++; //Increase the counter to use it later for scrap value } } } else if (this.transform.root.name == "Cargo(Clone)") //This is the cargo ship { for (int i = 0; i < 2; i++) //Run the loop 2 times, one for each cannon { if (SpawnAI.cannonLevel[i] == 1) { allCannons[i].GetComponent <MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } else if (SpawnAI.cannonLevel[i] == 2) { allCannons[i].GetComponent <MeshFilter>().mesh = mesh2; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 2; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelTwo++; //Increase the counter to use it later for scrap value } else if (SpawnAI.cannonLevel[i] == 3) { allCannons[i].GetComponent <MeshFilter>().mesh = mesh3; //Change the mesh to look like a upgraded cannon cannonLevel[i] = 3; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelThree++; //Increase the counter to use it later for scrap value } } } } else //This is the tutorial, so we want all cannons to be level 1 { for (int i = 0; i < 6; i++) //Loop 6 times, one for each cannon { allCannons[i].GetComponent <MeshFilter>().mesh = mesh1; //Change the mesh cannonLevel[i] = 1; //Save the level this.GetComponentInParent <AIMaster>().cannonLevelOne++; //Increase the counter to use it later for scrap value } } }