private void Migrate() { Debug.Log("!!!!!!!!!!!SMELL YA LATER!!!!!!"); //Stop counting agent in the current clan blackBoard.ChangeNumberAgentsInClan(clan, -1); //Check the colors of the agents currently in the clan int clanContainsNumberColorAgents = 0; List <Agent> agents = new List <Agent>(); if (clan == "Blue Clan") { agents = ((UnitCommanderBlueClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("UnitCommanderBlueClan(Clone)").GetComponent("UnitCommanderBlueClan")).GetAgents(); } else if (clan == "Red Clan") { agents = ((UnitCommanderRedClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("UnitCommanderRedClan(Clone)").GetComponent("UnitCommanderRedClan")).GetAgents(); } else if (clan == "Yellow Clan") { agents = ((UnitCommanderYellowClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("UnitCommanderYellowClan(Clone)").GetComponent("UnitCommanderYellowClan")).GetAgents(); } foreach (Agent agent in agents) { if (agent.getAgentType() == getAgentType()) { clanContainsNumberColorAgents++; } } //If there are none of that color left, remove it if (clanContainsNumberColorAgents == 1) { blackBoard.RemoveColorFromClan(clan, getAgentType()); } //Get the clan to migrate to blackBoard.SortClanScores(); List <string> clans = blackBoard.GetClans(); //Change the agents clan if (clan == clans[0] && clans.Count > 1) { SetClan(clans[1]); } else { SetClan(clans[0]); } //Increase the count in the new clan blackBoard.ChangeNumberAgentsInClan(clan, 1); //Move the agentObject transform.parent.parent = GameObject.Find(clan).transform.FindChild("Agents"); //Stop him from whatever thing his currently working on blackBoard.RemoveAgentFromOwnedNode(clan, this); Destroy(gameObject.transform.FindChild("Subsystem").gameObject); //Create a migrate plan //plan[0] = "MigrateAction"; //AddSubsystem(); //Alert the SupremeCommander of the new clan that the agent is coming if (clan == "Blue Clan") { ((SupremeCommanderBlueClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("SupremeCommanderBlueClan(Clone)").GetComponent("SupremeCommanderBlueClan")).ImmigratingAgentArriving(this); } else if (clan == "Red Clan") { ((SupremeCommanderRedClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("SupremeCommanderRedClan(Clone)").GetComponent("SupremeCommanderRedClan")).ImmigratingAgentArriving(this); } else if (clan == "Yellow Clan") { ((SupremeCommanderYellowClan)GameObject.Find(clan).transform.FindChild("Commanders").FindChild("SupremeCommanderYellowClan(Clone)").GetComponent("SupremeCommanderYellowClan")).ImmigratingAgentArriving(this); } }