public bool checkSelected() { if (eType == BuildingType.Outpost) { bOutpost outpost = GetComponent <bOutpost>(); return(!outpost.getSelected()); // logic is backwards somewhere w the negation sign but this works } else { Debug.LogWarning("its not an outpost?"); } return(false); }
public void setOutlineSelected() { if (eType == BuildingType.Outpost) { SpriteRenderer sr = GetComponent <SpriteRenderer>(); if (sr) { bOutpost outpost = GetComponent <bOutpost>(); var s = outpost.getSelected(_level); sr.sprite = s; outpost.setSelected(false); } } }
public void SelectionMade(bool cond) { if (cond) { _zone.confirmed(); } else { //canceled } _numTroops = 0; // Turn all the outposts back to unselected foreach (BuildableObject b in _zone.getOutposts()) { bOutpost outpost = b.gameObject.GetComponent <bOutpost>(); if (outpost) { outpost.resetSprite(b.getLevel()); } } ShowSelection(false, 0, null); }
// Called from MVC controller public void DemolishSomething() { //Dismiss all workers dismissCurrentWorker(); SoundManager.Instance.PlayDemolish(); SoundManager.Instance.PlayDemolish(); // Debug.Log("Time to Destroy Something" ); switch (eType) { case (BuildingType.House): bHouse house = this.GetComponent <bHouse>(); house.DemolishAction(_level); Destroy(house); eType = BuildingType.Vacant; eState = BuildingState.Available; _sr.sprite = _sStateConstruction; // Debug.Log("Destroyed a house"); break; case (BuildingType.Farm): bFarm farm = this.GetComponent <bFarm>(); farm.DemolishAction(); Destroy(farm); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; // Debug.Log("Destroyed a Farm"); break; case (BuildingType.Banner): bBanner banner = this.GetComponent <bBanner>(); Destroy(banner); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; Destroy(this.GetComponent <Animator>()); // Debug.Log("Destroyed a Banner"); break; case (BuildingType.Outpost): bOutpost outpost = this.GetComponent <bOutpost>(); outpost.DemolishAction(); Destroy(outpost); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; //Need to Reset Worker Object to Base // tell UI menu RemoveOutpostWorkers UIAssignmentMenu.Instance.RemoveOutpostWorkers(_Workers); // tell game manager PlayerOutpostDestroyed GameManager.Instance.PlayerOutpostDestroyed(this); ResetWorkers(); // Debug.Log("Destroyed an Outpost"); break; case (BuildingType.TownCenter): bTownCenter btc = this.GetComponent <bTownCenter>(); Destroy(btc); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; // Debug.Log("Destroyed a TownCenter"); break; case (BuildingType.GarbageCan): bGarbageCan garbagecan = this.GetComponent <bGarbageCan>(); Destroy(garbagecan); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; break; case (BuildingType.WoodPile): bWoodPile wp = this.GetComponent <bWoodPile>(); Destroy(wp); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; break; case (BuildingType.StonePile): bStonePile sp = this.GetComponent <bStonePile>(); Destroy(sp); eType = BuildingType.Vacant; eState = BuildingState.Building; _sr.sprite = _sStateConstruction; break; } //Drop Demolished Resources GameObject pickup = Resources.Load <GameObject>("ResourceIcons/Collectable_Resource"); if (pickup) { if (_level >= 1) { GameObject ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation); CoinResource cr = ppp.GetComponent <CoinResource>(); cr.setResourceType(ResourceManagerScript.ResourceType.Trash); cr.setResourceAmount(2 * _level); } if (_level >= 2) { GameObject ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation); CoinResource cr = ppp.GetComponent <CoinResource>(); cr.setResourceType(ResourceManagerScript.ResourceType.Wood); cr.setResourceAmount(2 * _level); } if (_level >= 3) { GameObject ppp = GameObject.Instantiate(pickup, this.transform.position, this.transform.rotation); CoinResource cr = ppp.GetComponent <CoinResource>(); cr.setResourceType(ResourceManagerScript.ResourceType.Stone); cr.setResourceAmount(2 * _level); } } UpdateState(); _DestroyMenu.showMenu(false, Vector3.zero, null, this); _level = 0; // handle the other stuff in demolish complete i guess StartCoroutine(DemolishCoroutine()); }
// used to be from MVC controller to let the building know its been clicked public void imClicked() { if (_Team == 2) { return; } // Debug.Log("Building is Clicked state is" + eState); if (eState == BuildingState.Built) { //Create a new menu interaction on a built object, downgrade? Demolish? Show resource output etc. Needs Something if (eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile) { if (getEmployeeCount() == 0) // if someone is working here, player cant gather { //Debug.Log("I am gathering!"); Searchable s = GetComponent <Searchable>(); if (s) { // s.GatherAction(20); s.ImClicked(); // should use ImClicked instead of GatherAction and encapsulate gather action into searchables functionality } } } else if (eType == BuildingType.Outpost && _cameraController.getOverrideMode()) { bOutpost outpost = GetComponent <bOutpost>(); if (outpost.getSelected()) { setOutlineSelected(); UITroopSelection.Instance.addTroops(getEmployeeCount()); } else { setOutlineAvailable(); UITroopSelection.Instance.addTroops(0 - getEmployeeCount()); } } else { StartCoroutine(ClickDelay(true, _DestroyMenu)); StartCoroutine(ClickDelay(false, _BuildMenu)); StartCoroutine(ClickDelay(false, _BuildingCapMenu)); } } else if (eState == BuildingState.Available || eState == BuildingState.Idle) { // Turns off the "notification exclamation mark" as the player is now aware of obj eState = BuildingState.Idle; //check if we can afford a building slot if (ResourceManagerScript.Instance.getNoBuildingSlots() < GameManager.Instance.GetBuildingCap()) { StartCoroutine(ClickDelay(true, _BuildMenu)); } else { //TO-DO: Show new menu that tells player at cap and to upgrade TC StartCoroutine(ClickDelay(true, _BuildingCapMenu)); } StartCoroutine(ClickDelay(false, _DestroyMenu)); //Disconnect here, MVC controller is now responsible for talking to UI } else if (eState == BuildingState.Building) { //IncrementConstruction(1); //Show a menu that asks to spend a shiny to increment _InstanceConstructionButton.SetActive(true); MVCController.Instance.setLastInstantConstruction(_InstanceConstructionButton); } if (!_cameraController.getOverrideMode()) { UpdateState(); } }