// Use this for initialization void Start() { // Create or (ultimately load) a new town model and view OR load the town from file currentTown = new Town("forest"); currentView = new TownView(currentTown, basicTiles, buildingComponents); // Populate the selectors PopulateComponentSelector(currentTown.componentTypes); PopulateBuildingSelector(); // Find the menu objects newBuildScreen = GameObject.Find("NewBuildingControls"); buildScreenMenu = GameObject.Find("BuildScreenMenu"); // Find the townobject the sprite map will be attached to GameObject townObject = GameObject.Find("Town"); // Add a sprite renderer townObject.AddComponent <SpriteRenderer>(); // Attache the views map texture to the sprite renderer townObject.GetComponent <SpriteRenderer>().sprite = Sprite.Create(currentView.mapTexture, new Rect(0, 0, currentView.mapTexture.width, currentView.mapTexture.height), new Vector2(0, 0)); townObject.GetComponent <SpriteRenderer>().sortingOrder = -2; // Scale the sprite map to the appropriate size // Debug.Log(townObject.GetComponent<SpriteRenderer>().sprite.pixelsPerUnit); townObject.transform.localScale = new Vector3(PIXEL_TO_UNIT_CONVERSION, PIXEL_TO_UNIT_CONVERSION, 1); // Set the builder defaults vertical = true; component = "floor"; currentFloor = 0; // Create building parts list StartNewBuilding(); }
// Use this for initialization void Awake() { menu = gameObject.GetComponent <TownView>(); Random r = new Random(DateTime.Now.Millisecond); int townNumber = r.Next(1, 100); town = new Town("Town" + townNumber); town.AddMarket(ResourceUtil.Wheat); town.AddMarket(ResourceUtil.Wood); town.AddMarket(ResourceUtil.Ore); town.AddMarket(ResourceUtil.Metal); town.AddMarket(ResourceUtil.Tools); roundUpdateListener = new UnityAction(RoundActions); EventManager.StartListening("UpdateRound", roundUpdateListener); for (int i = 0; i < 5; i++) { town.SpawnAgent(Entity.EntityType.farmer); town.SpawnAgent(Entity.EntityType.woodcutter); town.SpawnAgent(Entity.EntityType.miner); town.SpawnAgent(Entity.EntityType.smelter); town.SpawnAgent(Entity.EntityType.blacksmith); } }
private void OnSelected(TownView view) { _selectedTownId.Value = view.townId; foreach (var townView in _views.Where(v => v != view)) { townView.OnUnselected(); } }
private void Start() { _speed = Game.Config.CharacterWalkSpeed; _townController = GameObject.Find("TownController"); _townScript = _townController.GetComponent <TownView>(); _playerState = PlayerState.Init; }
public async Task Build() { int cityMax = datamodel.cities.Count; for (int i = 0; i < cityMax; i++) { TownView town = new TownView(); town.setdata(datamodel.cities[i].id, datamodel.cities[i].name); town.SetDelegate(ClickOnMain); town.Opacity = 0; layout.Children.Add(town); pickerlist.Add(town); } await Show(); }