コード例 #1
0
 /// <summary>
 /// Build the '3rd layer' of buildings if enough units (more upgrades!)
 /// </summary>
 public void Build3rd()
 {
     //Debug.Log("build 3");
     string buildingToBuild = buildingText3.text;
     BuildingFactory buildingFactory = new BuildingFactory ();
     Building building = buildingFactory.getBuilding (buildingToBuild.Replace(" ", "") + "(Clone)");
     if(PlayerController.getCount() >= building.getCost()){
         if (buildingToBuild.Equals ("Bed")) {
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(bed, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, 0, 0));
             newObject.transform.Translate(new Vector3(0, 0.06193482f, 0));
             turrets.Add(newObject);
             lastHitObject.tag = "BedPlane";
         }
         if (buildingToBuild.Equals ("Snail Gun")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(snailGun, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(0, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
             Analytics.setBuildings(3);
         }
         if (buildingToBuild.Equals ("Tech Smith")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(gadgetSmith, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "Techsmith";
         }
         UpdateUnits(building);
         score_.addScoreBuilding(building.getCost());
         setBuildMenu();
     }
 }
コード例 #2
0
 /// <summary>
 /// Build the '1st layer' of buildings if enough units (build from scratch) 
 /// </summary>
 public void Build1st()
 {
     //Debug.Log("build 1");
     string buildingToBuild = buildingText1.text;
     BuildingFactory buildingFactory = new BuildingFactory ();
     Building building = buildingFactory.getBuilding (buildingToBuild.Replace(" ", "") + "(Clone)");
     if(PlayerController.getCount() >= building.getCost()){
         if (buildingToBuild.Equals ("Rock-Paper-Scissor turret")) {
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(basicTurret, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(0, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "BasicTurretPlane";
             Analytics.setBuildings(1);
         }
         if (buildingToBuild.Equals ("Cat-a-pult")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(catapult, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(0, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
             Analytics.setBuildings(2);
         }
         if (buildingToBuild.Equals ("Energy Boost Bed")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(energyBed, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, 0, 0));
             newObject.transform.Translate(new Vector3(0, 1.055501f, 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
         }
         if (buildingToBuild.Equals ("Generator")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(generator, place, Quaternion.identity);
             newObject.transform.Translate(new Vector3(0, 0.2050993f, 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
         }
         UpdateUnits(building);
         score_.addScoreBuilding(building.getCost());
         setBuildMenu();
     }
 }
コード例 #3
0
 /// <summary>
 /// Build the '2nd layer' of buildings if enough units (upgrade)
 /// </summary>
 public void Build2nd()
 {
     //Debug.Log("build 2");
     string buildingToBuild = buildingText2.text;
     BuildingFactory buildingFactory = new BuildingFactory ();
     Building building = buildingFactory.getBuilding (buildingToBuild.Replace(" ","") + "(Clone)");
     if(PlayerController.getCount() >= building.getCost()){
         if (buildingToBuild.Equals ("GearShack")) {
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(gearShack, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "GearShackPlane";
         }
         if (buildingToBuild.Equals ("Harpgoon")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(harpgoon, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(0, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
             Analytics.setBuildings(4);
         }
         if (buildingToBuild.Equals ("Health Boost Bed")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(healthBed, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, (Random.Range(0, 360)), 0));
             turrets.Add(newObject);
             lastHitObject.tag = "occupiedPlane";
         }
         if (buildingToBuild.Equals ("Gun Smith")) {
             Delete();
             Vector3 place = lastHitObject.transform.position;
             GameObject newObject = (GameObject)Instantiate(weaponSmith, place, Quaternion.identity);
             newObject.transform.Rotate(new Vector3(-90, 0, 0));
             newObject.transform.Translate(new Vector3(0, 0.1957196f, 0));
             turrets.Add(newObject);
             lastHitObject.tag = "Gunsmith";
         }
         UpdateUnits(building);
         score_.addScoreBuilding(building.getCost());
         setBuildMenu();
     }
 }