public void addToPlayerRodents(Rodent r) { if (_PlayerRodents != null) { //List Should not add Duplicates if (_PlayerRodents.Contains(r)) { // Debug.Log("Trying to add a rodent thats already in player List:" + r.getName() +"" + r.gameObject); return; } else { _PlayerRodents.Add(r); if (_rm) { _rm.UpdateCurrentPopulation(); } else { ResourceManagerScript.Instance.UpdateCurrentPopulation(); } //Keep organized in hierarchy r.gameObject.transform.SetParent(_PlayerRodentDummy); } } }
/**Find rodents whove been teleported */ private List <GameObject> findfromCached() { // Debug.Log("Finding from Cached"); List <GameObject> chosen = new List <GameObject>(); //Get the player GameObject player = GameObject.FindGameObjectWithTag("Player"); chosen.Add(player); //get the royal guard PlayerStats ps = player.GetComponent <PlayerStats>(); if (ps) { foreach (var e in ps.getEmployees()) { chosen.Add(e); //everytime we teleport clear previous targets and go back to royal guarding Rodent r = e.GetComponent <Rodent>(); if (r) { var ss = e.GetComponent <SubjectScript>(); if (ss) { ss.setRoyalGuard(); } } } } //get the previously teleported troops foreach (Rodent child in _TeleportDummy.GetComponentsInChildren <Rodent>()) { chosen.Add(child.gameObject); //put them back in heirarchy child.transform.SetParent(GameObject.FindGameObjectWithTag("PlayerRodents").transform); } //If were coming back from the neutral zone to player zone if ((_zone == 2 && !_isRightZone) || (_zone == 3 && _isRightZone)) { //Reset the rodents to go back to the outpost foreach (BuildableObject b in _outposts) { List <GameObject> workers = b.getEmployees(); foreach (var go in workers) { //b.AssignWorker(go.GetComponent<Rodent>()); Rodent r = go.GetComponent <Rodent>(); if (r) { r.setTarget(b.gameObject); // setting target will reset them back to outpost duties } } } } _TroopLocations.Clear(); return(chosen); }
public void RemoveDeadRodent(Rodent r) { if (_TroopLocations.ContainsKey(r)) { _TroopLocations.Remove(r); } }
public void Assign(Rodent r) { // Debug.Log("ASsign in Employee" + r.name + test); if (!_Locked && !_Occupied) { //Debug.Log("Pass"); // Debug.Log("Assign in Employee" +r.getName()); //This script is on the portrait outline because its the visible clickable thing _PortraitOutline.GetComponent <bWorkerScript>().setWorker(r); _WorkerObj.GetComponent <SpriteRenderer>().sprite = r.GetPortrait(); //Stupid Bugg... makes no sense , something seems to break if u assign and the gameobject is turned off // Debug.Log("Portraitnameis " + r.GetPortrait()); //print(_WorkerObj.GetComponent<SpriteRenderer>()); // print(_WorkerObj.GetComponent<SpriteRenderer>().sprite); // sp = _WorkerObj.GetComponent<SpriteRenderer>(); _Occupied = true; _currentRodent = r; r.SetJob(this); ShowWeaponClass(true); SetWeaponClassImg(r.isRanged()); //subscribe to the event system - unused now //EventSystem.Instance.rodentDead += Dismiss; SoundManager.Instance.PlayAssign(); } }
public void IDied(Rodent r) { if (rodentDead != null) { rodentDead(r); } }
public void Dismiss(Rodent r) { if (r == null) { return; } // Debug.Log("heard Dismiss Employee :" + r.getName()); if (_Occupied) { if (_currentRodent && _currentRodent == r) { _currentRodent.setTarget(null); _PortraitOutline.GetComponent <bWorkerScript>().setWorker(null); _WorkerObj.GetComponent <SpriteRenderer>().sprite = null; //print("dismiss"); _Occupied = false; _currentRodent = null; ShowRedX(false); UIAssignmentMenu.Instance.ResetButtons(); ShowWeaponClass(false); //unsubscribe - unused now //EventSystem.Instance.rodentDead -= Dismiss; SoundManager.Instance.PlayDismiss(); r.ShowDismissMenu(false); } } }
// Start is called before the first frame update void Start() { this.GetComponent <SpriteRenderer>().sprite = _Default; setUpAnimators(); Rodent r = this.GetComponent <Rodent>(); if (r) { r.setRodentType(Rodent.eRodentType.Rat); r.setSpeed(_MoveSpeed); r.setHpMax(_HpMax); r.setHp(_Hp); r.setAttackDmg(_AttackDamage); r.setPortrait(_Portrait); r.setBuildRate(_buildRate); r.setGatherRate(_gatherRate); setUpProperBoxCollider(); int curr = ResourceManagerScript.Instance.getCurrentPopulation(); r.setRecruitmentCost(_RecruitmentCost + curr); } //TMP Test - Finds and follows the player // this.GetComponent<SubjectScript>().currentTarget = GameObject.FindObjectOfType<PlayerStats>().gameObject; }
public void AddtoRodents(Rodent r) { if (!_AllRodents.Contains(r)) { _AllRodents.Add(r); _RodentHashTable.Add(r.getID(), r); } }
public void Recruit(Rodent r, UIRecruitMenu menu) { // Debug.Log("MVC Rodent Recruit: " + _lastRodent); menu.showMenu(false, Vector3.zero, "", 0, 0); r.tag = "PlayerRodent"; //obsolete now r.Recruit(); CheckClicks(true); }
public void showKingGuardMenu(bool cond, Rodent r) { // Tell the MVC were the active menu MVCController.Instance.SetRecruitMenu(this); _active = cond; buttons[1].gameObject.SetActive(cond); _Name2.text = r.getName(); }
private void IncrementBuilding() { if (currentTarget == townCenterLoc) { //Debug.Log("INcrement On" + savedTarget.gameObject); Rodent r = this.GetComponent <Rodent>(); // no null check cuz would never happen savedTarget.GetComponent <BuildableObject>().IncrementConstruction(r.getBuildRate()); } }
private void spawnThis(GameObject toSpawn, bool Enemy) { if (Enemy) { GameObject _spawnedRodent = GameObject.Instantiate(toSpawn, _spawnLoc, this.transform.rotation); //parent this to keep hierarchy clean if (_EnemySpawnDummy) { _spawnedRodent.transform.SetParent(_EnemySpawnDummy); } else { Debug.LogWarning("No Enemy Dummy for Hierarchy"); } // Tag becoming obsolete _spawnedRodent.tag = "EnemyRodent"; // Ensure Sprite is enemy Rodent r = _spawnedRodent.GetComponent <Rodent>(); if (r) { r.setTeam(2); SubjectScript ss = r.GetComponent <SubjectScript>(); if (ss) { ss.setDefender(); StartCoroutine(RoyalGuardDelay(ss)); } // Force them to be aggressive and head toward player //hack if (_inPlayerZone) { r.setTargetEnemyVersion(GameManager.Instance.getTownCenter().gameObject); } } // Increase some kind of count --_EnemyCount; if (_EnemyCount == 0) { _occupied = true; } } else { _occupied = true; GameObject _spawnedRat = GameObject.Instantiate(toSpawn, _spawnLoc, this.transform.rotation); //parent this thing to this obj keep hierarchy cleaner? Might end up negatively affecting the subject Script? _spawnedRat.transform.SetParent(this.transform); // Tag becoming obsolete _spawnedRat.tag = "NeutralRodent"; // Ensure Sprite is Neutral _spawnedRat.GetComponent <Rodent>().setTeam(0); // Increase some kind of count } }
public void RodentAssigned(Rodent r) { if (_printStatements) { Debug.Log("heard rodent Assigned " + _lastClicked + " is last clicked"); } //Might want to do some other checks, like the building state? if (_lastClicked) { BuildableObject _Building = _lastClicked.GetComponent <BuildableObject>(); if (_Building) { //Check if this building is occupied // if (_Building.CheckOccupied()) { //To-Do: //play negative sound? //No Longer able to check this way } // else // free to assign { //Rodent Things , status update etc //r.setTarget(_lastClicked); _Building.AssignWorker(r); clearLastClicked(); // Dont want menu to close so we can keep assigning in the mode //_AssignmentMenu.showMenu(false); //instead reset the buttons UIAssignmentMenu.Instance.ResetButtons(); } } else { if (_printStatements) { Debug.Log("Assign to PLayer"); } PlayerStats Player = _lastClicked.GetComponent <PlayerStats>(); if (Player) { Player.AssignWorker(r); //Need a check to see if he can be assigned // r.setTarget(_lastClicked); clearLastClicked(); UIAssignmentMenu.Instance.ResetButtons(); } } } }
public void RemoveFromRodents(Rodent r) {//Rodent died if (_AllRodents != null) { if (_AllRodents.Contains(r)) { _AllRodents.Remove(r); } } }
void Start() { this.rodent = this.GetComponentInParent <Rodent>(); // need this in start bc Sean B Lee added components in Awake() this.mainCameraRotation = Camera.main.transform.rotation; this.username.text = rodent.statSheet.name; // Define max xp level up chart in game stat controller, placeholder 100 this.maxExp = 100; }
/** Find rodents from the players outpost */ private List <GameObject> findfromOutposts() { List <GameObject> chosen = new List <GameObject>(); //Get the player GameObject player = GameObject.FindGameObjectWithTag("Player"); chosen.Add(player); //get the royal guard PlayerStats ps = player.GetComponent <PlayerStats>(); if (ps) { foreach (var e in ps.getEmployees()) { chosen.Add(e); } } // print("called find selected() size= " + _outposts.Count); foreach (var b in _outposts) { // print("checking building:" + b.name); if (b.checkSelected()) { //print(b.name + "is true"); List <GameObject> recieved = b.getEmployees(); foreach (var e in recieved) { //print("we found employee " + e); chosen.Add(e); Rodent r = e.GetComponent <Rodent>(); if (r) { if (!_TroopLocations.ContainsKey(r)) { _TroopLocations.Add(r, b); } //Do we have to remove them from the outpost? what happens if they die // in combat? do they unassign then? var ss = e.GetComponent <SubjectScript>(); if (ss) { ss.setRoyalGuard(); } //Set them to a new item in the heirarchy to teleport back later e.transform.SetParent(_TeleportDummy.transform); } } } } return(chosen); }
public void AssignWorker(Rodent r) { // Debug.Log("AssignWorker!" + r.getName() + "to " + this.gameObject); // print("USed Slots =" + ResourceManagerScript.Instance.getNoBuildingSlots()); //print("Max cap = " + GameManager.Instance.GetBuildingCap()); if (eType == BuildingType.Vacant) { return; } bool okayToAdd = true; int index = findAvailableSlot(); if (index > -1) //This is kind of a hack { if (ResourceManagerScript.Instance.getNoBuildingSlots() >= GameManager.Instance.GetBuildingCap()) { if (eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile) { okayToAdd = false; //print("not okay to add type:" + eType); } } if (okayToAdd) { //print("okay to add"); _Workers[index].Assign(r); r.setTarget(this.gameObject); //Start Construction or Gathering if (eState == BuildingState.Building) { // if (getEmployeeCount() != 0) // StartCoroutine(BeginConstructionLoop()); } else if (eState == BuildingState.Built && eType == BuildingType.Farm || eType == BuildingType.GarbageCan || eType == BuildingType.WoodPile || eType == BuildingType.StonePile) { if (getEmployeeCount() != 0) { //StartCoroutine(BeginSearchLoop()); //Old wya to auto do } if (eType != BuildingType.Farm) { if (ResourceManagerScript.Instance.getNoBuildingSlots() < GameManager.Instance.GetBuildingCap()) { //Add to our building cap ResourceManagerScript.Instance.IncrementBuildingSlots(1); } } } } } }
public void LoadData() { sRodentData data = sSaveSystem.LoadRodentData(); int[] IDs = data._IDs; for (int i = 0; i < data._IDs.Length; ++i) { int id = IDs[i]; Rodent r = _RodentHashTable[id]; r.LoadData(id, data._team[i], data._Type[i], data._BuildingID[i], data._position[i]); } }
private void IncrementGathering() { if (currentTarget == townCenterLoc) { Debug.Log("INcrement On" + savedTarget.gameObject); Rodent r = this.GetComponent <Rodent>(); // no null check cuz would never happen savedTarget.GetComponent <BuildableObject>().IncrementGathering(r.getGatherRate()); } else { Debug.Log("current target is" + currentTarget.gameObject); } }
private bool CheckIfRat() { Rodent r = GetComponent <Rodent>(); if (r) { if (r.GetRodentType() == Rodent.eRodentType.Rat || r.GetRodentType() == Rodent.eRodentType.Mouse) { return(true); } } return(false); }
public void AssignWorker(Rodent r) { //Debug.Log("AssignWorker!" + r.getName()); int index = findAvailableSlot(); if (index > -1) //This is kind of a hack { _RoyalGuards[index].Assign(r); r.setTarget(this.gameObject); } // else // Debug.Log("no Empty"); }
public void RodentDismissed(Rodent _Rodent) { Employee _Job = _Rodent.GetJob(); if (_Job) { _Job.Dismiss(_Rodent); } //remove from player rodent list (in gamemanager) GameManager.Instance.RemovePlayerRodent(_Rodent); //make rodent available again (no hat) _Rodent.setTeam(0); _Rodent.ShowDismissMenu(false); }
//unused, logic handled elsewhere in Employee now public void dismissRodent() { //Debug.Log("heard Dismiss"); if (bo) { bo.DismissWorker(_worker); } else if (ps) { ps.DismissWorker(_worker); } _worker = null; MVCController.Instance.showRedX(false); }
public void DismissWorker(Rodent r) { foreach (var e in _RoyalGuards) { if (e.isOccupied()) { if (e.getCurrentRodent() == r) { //Debug.Log("We found the right Employee"); e.Dismiss(r); break; } } } }
// Start is called before the first frame update void Start() { getAnimator(); facingRight = false; // a backup condition to get the right speed Rodent r = this.GetComponent <Rodent>(); if (r) { moveSpeed = r.getSpeed(); } WaitDuration = 10f; testSwap(); townCenterLoc = GameManager.Instance.getTownCenter().transform.gameObject; isRanged = this.GetComponent <Rodent>().isRanged(); projectileSpawnPoint = gameObject.transform.Find("ProjectileSpawn"); }
public void RemovePlayerRodent(Rodent r) { if (_PlayerRodents != null) { if (_PlayerRodents.Contains(r)) { _PlayerRodents.Remove(r); } _rm.UpdateCurrentPopulation(); //Keep organized in hierarchy if (!r.isDead()) { r.gameObject.transform.SetParent(_NeutralRodentDummy); } //Debug.Log("Set to neutralStack:" + r.gameObject); } }
public void SpawnaKing() { //Cant spawn multiple if ((!GameManager.Instance.RightSideKingAlive && _rightSide) || (!GameManager.Instance.LeftSideKingAlive && !_rightSide)) { GameObject king = Resources.Load <GameObject>("Rodent/King_Enemy/EnemyKingPreFab"); GameObject _spawnedRodent = GameObject.Instantiate(king, _spawnLoc, this.transform.rotation); if (_EnemySpawnDummy) { _spawnedRodent.transform.SetParent(_EnemySpawnDummy); } Rodent r = _spawnedRodent.GetComponent <Rodent>(); if (r) { r.setTeam(2); // Force them to be aggressive and head toward player //hack if (_inPlayerZone) { r.setTargetEnemyVersion(GameManager.Instance.getTownCenter().gameObject); } } EKing ek = _spawnedRodent.GetComponent <EKing>(); if (ek) { ek.setRightSideCrown(_rightSide); // tell the king which crown he represents } if (_rightSide) // getting lazy wit dat crunch { GameManager.Instance.RightSideKingAlive = true; } else { GameManager.Instance.LeftSideKingAlive = true; } } else { print("Failed " + this.gameObject.name); } }
public void showDismissMenu(bool cond, Rodent r) { //MVCController.Instance.TurnThingsoff(); // Tell the MVC were the active menu MVCController.Instance.SetRecruitMenu(this); _Rodent = r; _active = cond; buttons[2].gameObject.SetActive(cond); _Name2.text = r.getName(); if (r.isRanged()) { _weaponClass2.sprite = _iconRanged; } else { _weaponClass2.sprite = _iconMelee; } }
private GameObject FoundRodent(GameObject _TMPlastClicked) { _lastRodent = _TMPlastClicked.transform.parent.GetComponent <Rodent>(); if (_printStatements) { Debug.Log("Clicked a Rodent"); } if (_lastRodent.getTeam() == 0) { _lastRodent.imClicked(); _recruitDummy = true; } else if (_lastRodent.getTeam() == 1) { _lastRodent.imClicked(); _recruitDummy = true; } return(_lastRodent.gameObject); }
private GameObject FoundSpawnVolume(GameObject _TMPlastClicked) { _lastRodent = _TMPlastClicked.GetComponent <Rodent>(); if (_printStatements) { Debug.Log("Clicked a Rodent through spawn volume"); } if (_lastRodent.getTeam() == 0) { _lastRodent.imClicked(); _recruitDummy = true; } else if (_lastRodent.getTeam() == 1) { _lastRodent.imClicked(); _recruitDummy = true; } return(_lastRodent.gameObject); }