Advertisement
Guest User

Home

a guest
May 26th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class HomeSpawner2 : MonoBehaviour {
  6. public VillagerSpawner other;
  7.  
  8. public GameObject homePrefab;
  9. public GameObject villagerPrefab;
  10. Status status;
  11. int homeCount=0;
  12. public Vector3 homeVector = new Vector3 (343.86f, 50.74f, 273.76f);
  13. //Vector3 villagerVector = new Vector3(0f,0f,0f);
  14. int homeNumber = 0;
  15. //int vilNumber = 0;
  16. // public List <GameObject> villagerList;
  17. public List <GameObject> homeList;
  18.  
  19.  
  20.  
  21.  
  22. void Start ()
  23. {
  24. status = GameObject.FindGameObjectWithTag ("StatusMaker").GetComponent<Status> ();
  25. homeList=new List <GameObject>();
  26. // villagerList=new List <GameObject>();
  27.  
  28. }
  29. public void CreateHome ()
  30. {
  31. if (status.Resources >= 20)
  32. {
  33. Vector3 villagerVector = homeVector;
  34. villagerVector.x = villagerVector.x + 10f;
  35.  
  36. GameObject home = Instantiate (homePrefab, homeVector, Quaternion.identity) as GameObject;
  37. home.transform.parent = transform;
  38. status = GameObject.FindGameObjectWithTag ("StatusMaker").GetComponent<Status> ();
  39. status.HomeCount++;
  40. homeNumber ++;
  41. // status.VillagerCount = status.VillagerCount + 4;
  42. homeVector.x = homeVector.x + 33f;
  43.  
  44. status.AvailWorkers= status.AvailWorkers +4;
  45. home.name = "Home" + homeNumber;
  46. homeList.Add(home);
  47.  
  48. // //create 4 villagers infront of home
  49. // for (int i =0; i<newVillagerCnt; i++)
  50. // {
  51. // GameObject villager = Instantiate (villagerPrefab, villagerVector, Quaternion.identity) as GameObject;
  52. // home.transform.parent = transform;
  53. // vilNumber ++;
  54. // villager.name = "Villager" + vilNumber;
  55. // villagerList.Add(villager);
  56. // bool busy = false;
  57. // }
  58. //
  59. // newVillagerCnt =0;
  60.  
  61. VillagerSpawner();
  62.  
  63. if (homeCount >= 5)
  64. {
  65.  
  66. homeVector.z= homeVector.z-33;
  67. homeVector.x= 343.86f;
  68. homeCount=0;
  69. }
  70.  
  71. }
  72. }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement