/// <summary> /// /// </summary> private void SelectNewSpawnLocation() { //location = clsGameConstants.enLocations.Pad1; //return; System.Array values = null; //add all of the enumerations to the array values = clsGameConstants.enLocations.GetValues(typeof(clsGameConstants.enLocations)); //randomly select the location to spawn from location = (clsGameConstants.enLocations)values.GetValue(random.Next(0, intAvailableDestinations)); //make sure the location and destination are not the same while (location == destination) { //randomly select the location to spawn from location = (clsGameConstants.enLocations)values.GetValue(random.Next(0, intAvailableDestinations)); } }
/// <summary> /// /// </summary> public void PlayBoardTaxiAnimation() { //figure out which door is closest float fltDistToLeftDoor = (scrTaxiDriver.Instance.LeftDoor.transform.position - gameObject.transform.position).magnitude; float fltDistToRightDoor = (scrTaxiDriver.Instance.RightDoor.transform.position - gameObject.transform.position).magnitude; //default to the left door Vector3 vctDoorPosition = scrTaxiDriver.Instance.LeftDoor.transform.position; //if the right door is closer, use it if (fltDistToRightDoor < fltDistToLeftDoor) vctDoorPosition = scrTaxiDriver.Instance.RightDoor.transform.position; //see how far away we are from the door float fltDistToDoor = (vctDoorPosition - gameObject.transform.position).magnitude; if (fltDistToDoor > 0.5) { //if we are more than half a unit from there, then keep walking gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, vctDoorPosition, Time.deltaTime * 0.7f); } else { //we have arrived at the door //make the passenger invisible so he appears to have gotten in the taxi clsHelper.SetObjectVisiblity(false, gameObject); stateManager.SetState(clsPassengerStateManager.enState.Riding); location = clsGameConstants.enLocations.InTheTaxi; } }
/// <summary> /// /// </summary> private void SelectNewDestination() { Debug.Log("Entered SelectNewDestination. dest left " + destinationQueue.Count); //get the next destination from the queue if (destinationQueue.Count > 0) { destination = destinationQueue.Dequeue(); Debug.Log("selected " + destination); } else { //nowhere left to go but up destination = clsGameConstants.enLocations.Up; } }
private void PlayDeBoardTaxiAnimation2() { //float fltWaving = 0; //float fltWalking = 1.0f; fltWaving = 0; //please remain seated until we have come to a full stop! :) //if the taxi is still moving, dont start the deboard animation //also, keep track of if the animation has started. if the taxi takes off again, we want to //complete the animation if (scrTaxiDriver.Instance.location == clsGameConstants.enLocations.InTransit && stateManager.PlayingUnboardAnimation == false) return; //once the taxi has landed, start the animation stateManager.PlayingUnboardAnimation = true; //move the passenger location to the taxi location location = scrTaxiDriver.Instance.location; //find out where on the pad we should walk to Vector3 PassengerWalkToLocation = GetPadsBestPassengerLocation(location.ToString(), scrTaxiDriver.Instance.transform.position); if (stateManager.InitUnboardAnimation == false) { stateManager.InitUnboardAnimation = true; //place the passenger next to the door closest to the walk to point gameObject.transform.position = scrTaxiDriver.Instance.transform.position - Vector3.up * 0.75f; //make the passenger visible so he looks like he got out of the cab clsHelper.SetObjectVisiblity(true, gameObject); } //see how far away we are from the door float fltDistToWalkToLocation = (PassengerWalkToLocation - gameObject.transform.position).magnitude; if (fltDistToWalkToLocation > 0.5) { //if we are more than half a unit from there, then keep walking //point the passenger at the walkto location gameObject.transform.LookAt(PassengerWalkToLocation); fltWalking = 1; } else { //we have arrived at the walk to point //make the passenger invisible so he appears to have gotten in the building fltWalking = 0; gameObject.transform.LookAt(new Vector3(PassengerWalkToLocation.x, transform.position.y, PassengerWalkToLocation.z)); clsHelper.SetObjectVisiblity(false, gameObject); stateManager.SetState(clsPassengerStateManager.enState.Leaving); } //send variables to the animation controller anim.SetFloat("walking", fltWalking); anim.SetFloat("waving", fltWaving); }
/// <summary> /// /// </summary> /// <param name="other"></param> void OnTriggerEnter(Collider other) { Debug.Log("Passenger contact with " + other.gameObject.transform.name); string strColliderTag = other.gameObject.transform.tag; Debug.Log("strColliderTag = " + strColliderTag); //find out what hit us if ((strColliderTag == clsGameConstants.strPlayerTag)) { //Debug.Log(" "); //if (taxiDriverScript.state == scrTaxiDriver.enStates.flying) //{ // Debug.Log("taxi is flying. so we got ran over "); // //it looks like the player just ran us over // stateManager.SetState(clsPassengerStateManager.enState.Dying); //} //else if (taxiDriverScript.state == scrTaxiDriver.enStates.landed) //{ // Debug.Log("taxi is landed. so we just got on board "); // stateManager.SetState(clsPassengerStateManager.enState.Riding); //} //we have arrived at the door //make the passenger invisible so he appears to have gotten in the taxi clsHelper.SetObjectVisiblity(false, gameObject); stateManager.SetState(clsPassengerStateManager.enState.Riding); location = clsGameConstants.enLocations.InTheTaxi; } }
/// <summary> /// /// </summary> public void PlayDeBoardTaxiAnimation() { //please remain seated until we have come to a full stop! :) //if the taxi is still moving, dont start the deboard animation //also, keep track of if the animation has started. if the taxi takes off again, we want to //complete the animation if (scrTaxiDriver.Instance.location == clsGameConstants.enLocations.InTransit && stateManager.PlayingUnboardAnimation == false) return; //once the taxi has landed, start the animation stateManager.PlayingUnboardAnimation = true; //move the passenger location to the taxi location location = scrTaxiDriver.Instance.location; //find out from the pad where the passenger should walk to Vector3 PassengerWalkToLocation = GetPadsBestPassengerLocation(location.ToString(), scrTaxiDriver.Instance.transform.position); if (stateManager.InitUnboardAnimation == false) { stateManager.InitUnboardAnimation = true; //figure out which door is closest float fltDistToLeftDoor = (scrTaxiDriver.Instance.LeftDoor.transform.position - PassengerWalkToLocation).magnitude; float fltDistToRightDoor = (scrTaxiDriver.Instance.RightDoor.transform.position - PassengerWalkToLocation).magnitude; //default to the left door Vector3 vctDoorPosition = scrTaxiDriver.Instance.LeftDoor.transform.position; //if the right door is closer, use it if (fltDistToRightDoor < fltDistToLeftDoor) vctDoorPosition = scrTaxiDriver.Instance.RightDoor.transform.position; //place the passenger next to the door closest to the walk to point gameObject.transform.position = vctDoorPosition; //make the passenger visible so he looks like he got out of the cab clsHelper.SetObjectVisiblity(true, gameObject); } //see how far away we are from the door float fltDistToWalkToLocation = (PassengerWalkToLocation - gameObject.transform.position).magnitude; if (fltDistToWalkToLocation > 0.5) { //if we are more than half a unit from there, then keep walking gameObject.transform.position = Vector3.Lerp(gameObject.transform.position, PassengerWalkToLocation, Time.deltaTime * 0.7f); } else { //we have arrived at the walk to point //make the passenger invisible so he appears to have gotten in the building clsHelper.SetObjectVisiblity(false, gameObject); stateManager.SetState(clsPassengerStateManager.enState.Leaving); } }
/// <summary> /// /// </summary> /// <param name="strLandingSite"></param> private void ResolveLocation(string strLandingSite) { if (strLandingSite.StartsWith(clsGameConstants.strPad1Tag)) location = clsGameConstants.enLocations.Pad1; else if (strLandingSite.StartsWith(clsGameConstants.strPad2Tag)) location = clsGameConstants.enLocations.Pad2; else if (strLandingSite.StartsWith(clsGameConstants.strPad3Tag)) location = clsGameConstants.enLocations.Pad3; else if (strLandingSite.StartsWith(clsGameConstants.strPad4Tag)) location = clsGameConstants.enLocations.Pad4; else if (strLandingSite.StartsWith(clsGameConstants.strPad5Tag)) location = clsGameConstants.enLocations.Pad5; else if (strLandingSite.StartsWith(clsGameConstants.strPad6Tag)) location = clsGameConstants.enLocations.Pad6; else if (strLandingSite.StartsWith(clsGameConstants.strPad7Tag)) location = clsGameConstants.enLocations.Pad7; else if (strLandingSite.StartsWith(clsGameConstants.strPad8Tag)) location = clsGameConstants.enLocations.Pad8; else if (strLandingSite.StartsWith(clsGameConstants.strPad9Tag)) location = clsGameConstants.enLocations.Pad9; else location = clsGameConstants.enLocations.InTransit; }