Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class HomeSpawner2 : MonoBehaviour {
- public VillagerSpawner other;
- public GameObject homePrefab;
- public GameObject villagerPrefab;
- Status status;
- int homeCount=0;
- public Vector3 homeVector = new Vector3 (343.86f, 50.74f, 273.76f);
- //Vector3 villagerVector = new Vector3(0f,0f,0f);
- int homeNumber = 0;
- //int vilNumber = 0;
- // public List <GameObject> villagerList;
- public List <GameObject> homeList;
- void Start ()
- {
- status = GameObject.FindGameObjectWithTag ("StatusMaker").GetComponent<Status> ();
- homeList=new List <GameObject>();
- // villagerList=new List <GameObject>();
- }
- public void CreateHome ()
- {
- if (status.Resources >= 20)
- {
- Vector3 villagerVector = homeVector;
- villagerVector.x = villagerVector.x + 10f;
- GameObject home = Instantiate (homePrefab, homeVector, Quaternion.identity) as GameObject;
- home.transform.parent = transform;
- status = GameObject.FindGameObjectWithTag ("StatusMaker").GetComponent<Status> ();
- status.HomeCount++;
- homeNumber ++;
- // status.VillagerCount = status.VillagerCount + 4;
- homeVector.x = homeVector.x + 33f;
- status.AvailWorkers= status.AvailWorkers +4;
- home.name = "Home" + homeNumber;
- homeList.Add(home);
- // //create 4 villagers infront of home
- // for (int i =0; i<newVillagerCnt; i++)
- // {
- // GameObject villager = Instantiate (villagerPrefab, villagerVector, Quaternion.identity) as GameObject;
- // home.transform.parent = transform;
- // vilNumber ++;
- // villager.name = "Villager" + vilNumber;
- // villagerList.Add(villager);
- // bool busy = false;
- // }
- //
- // newVillagerCnt =0;
- VillagerSpawner();
- if (homeCount >= 5)
- {
- homeVector.z= homeVector.z-33;
- homeVector.x= 343.86f;
- homeCount=0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement