public void LoadData(int id, int team, int type, int WorkID, float xPos) { if (_ID != id) { Debug.LogWarning("Rodent IDs do not match, save data failure"); } //Set the Position this.transform.position = new Vector3(xPos, this.transform.position.y, 0); //Set the Team _Team = team; //Set the Species setRodentType((eRodentType)type); //Figure out place of employment if (WorkID == -1) { setTarget(null); } else if (WorkID == -2) // is a royal guard { GameObject player = GameObject.FindGameObjectWithTag("Player"); setTarget(player); player.GetComponent <PlayerStats>().AssignWorker(this); } else { BuildableObject b = BuildingSlotManager.Instance.getBuildingFromID(WorkID); setTarget(b.gameObject); b.AssignWorker(this); if (b == null) { Debug.LogWarning("Rodent should work at building but its null, Possible Save Game Corruption"); } } }
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(); } } } }