public void garrisonIn(Building b) { //make a new garrison instance as a child of the action group object Garrison gar = ObjectManager.initGarrison(transform); //set building to garrison in gar.setTarget(b); //add the action to the action group component mActions.prependAction(gar); }
public void setOutcome(string oname) { EntityHP ent_hp = mHitObject as EntityHP; EntityAction ent_act = mHitObject as EntityAction; Entity ent = mHitObject as Entity; Resource res = mHitObject as Resource; Building build = mHitObject as Building; Construction constro = mHitObject as Construction; WorkedBuilding wb = mHitObject as WorkedBuilding; mOutcomeString = oname; switch (oname) { case "Move": //Debug.Log(string.Format("Action keyword Move chosen", oname)); Movement move = ObjectManager.initMove(mSelection.transform); if (ent) { move.setDestination(ent); } else if (mHitPoint != Globals.InvalidPosition) { move.setDestination(mHitPoint); } mOutcomeAction = move; break; case "Wait": Wait wt = ObjectManager.initWait(mSelection.transform); if (ent) { wt.setDestination(ent); } else if (mHitPoint != Globals.InvalidPosition) { wt.setDestination(mHitPoint); } mOutcomeAction = wt; break; case "Attack": //Debug.Log(string.Format("Action keyword Attack chosen.", oname)); Attack att = ObjectManager.initAttack(mSelection.transform); if (ent_hp) { att.setTarget(ent_hp); mOutcomeAction = att; break; } else { mOutcome = false; } setActive(false); return; case "Exchange": Exchange ex = ObjectManager.initExchange(mSelection.transform); if (ent_act) { ex.setTarget(ent_act); mOutcomeAction = ex; break; } else { mOutcome = false; } setActive(false); return; case "Garrison": Garrison gar = ObjectManager.initGarrison(mSelection.transform); if (build) { gar.setTarget(build); mOutcomeAction = gar; break; } else { mOutcome = false; } setActive(false); return; case "Procreate": Procreate proc = ObjectManager.initProcreate(mSelection.transform); if (build) { proc.setGarrisonBuilding(build); mOutcomeAction = proc; break; } else { mOutcome = false; } setActive(false); return; case "Collect": Collect coll = ObjectManager.initCollect(mSelection.transform); if (res) { coll.setTarget(res); mOutcomeAction = coll; break; } else { mOutcome = false; } setActive(false); return; case "Work": Work wr = ObjectManager.initWork(mSelection.transform); if (wr) { wr.setTarget(wb); mOutcomeAction = wr; break; } else { mOutcome = false; } setActive(false); return; case "Construct": if (constro) { Construct constr = ObjectManager.initConstruct(mSelection.transform); constr.setTarget(constro); mOutcomeAction = constr; } else if (mHitPoint != Globals.InvalidPosition) { populateListMenu(); //constr.setTarget(mHitPoint); } else { mOutcome = false; setActive(false); return; } break; case "Explore": //Debug.Log("Explore action set as outcome"); Explore exp = ObjectManager.initExplore(mSelection.transform); mOutcomeAction = exp; break; case "Travel": //Debug.Log("travel selected"); Travel trav = ObjectManager.initTravel(mSelection.transform); if (build) { //Debug.Log("building is not null"); trav.setDestination(build); mOutcomeAction = trav; break; } else { mOutcome = false; //Debug.Log("building is null"); } setActive(false); break; default: Debug.LogError(string.Format("Action keyword {0} not recoginised.", oname)); break; } if (!mListActive) { mOutcome = true; } }