//Create Knight, such as exiting a building public guardAI createGuard(Vector3 referencePoint, Quaternion rotation) { GameObject gobj = (GameObject)Instantiate(Guard, referencePoint, rotation); guardAI gAI = gobj.GetComponentInChildren <guardAI>(); return(gAI); }
void exitAsGuard() { // Now, if pending knights, timer before decreasing human and night count // then create new knight (or advanced human later)... if none, get out if( pendingGuards == 0 ) return; // decrease timere... if still more time, get out. Not time to generate knight newGuardDelay -= Time.deltaTime; if( newGuardDelay > 0f ) return; // decrease knight count first, then the human count... pendingGuards--; humanCount--; // if STILL any pending knights, reset the counter if( pendingGuards > 0 ) newGuardDelay = 2.0f; // NOW, we had a knight and time was reached... // generate one outside the safe house vicinity, // then, decrease the knight AND human count. Since the human count // is in case it breaks open the building, the total "people" inside. // as the human count is a basis of other points and such within. float x, z; // Since the building is NOT destroyed, we want our spawning OUTSIDE the // building and NOT within it... Just go min values respectively since no // spwan, go based on the house's position less the 1/2 of x or z dimensions Transform t = gameObject.transform; x = t.position.x - ( t.localScale.x / 2.0f ) -1.0f; z = t.position.z + ( t.localScale.z / 2.0f ) +1.0f; guardAI gAI = globalEvents.characterCreator.createGuard(new Vector3(x, 1, z), new Quaternion(0f, 0f, 0f, 0f)); gAI.stationary = false; gAI.moveAfterCombat = true; ((commonAI)gAI).GetComponent<Animation>().Play("walk"); ((commonAI)gAI).baseSpeed = 4.5f; ((commonAI)gAI).runSpeed = 7.0f; }