void revertSpeed() { GameObject player = GameObject.FindGameObjectWithTag("Player"); Ship_Movement boost = player.GetComponent <Ship_Movement>(); boost.speed = boost.Ospeed; }
public void Set_Sail() { Ship_Movement shipscript = ship.GetComponent <Ship_Movement>(); if (b_agent.hasPath && shipscript.get_crew_count() >= required_crew_count) { CameraScript camscript = cam.GetComponent <CameraScript>(); Camera_Orbit camorbit = cam.GetComponent <Camera_Orbit>(); camscript.enabled = false; camorbit.enabled = true; shipscript.inport = false; //set_sail_button.SetActive(false); //enter_market_button.SetActive(false); //enter_tavern_button.SetActive(false); uiScript.TownUI(false); uiScript.DestroyCrewTav(); audioScript.oceanSound(true); } else { uiScript.ErrorDisp("you must choose a destination before setting sail and have the required number of crew for your ship size"); } if (med_cargo_count + timber_cargo_count + spice_cargo_count + rum_cargo_count == 0 && gold <= 0) { uiScript.loseDisp("You have gone bankrupt and have no way to make money, off to prison for your debts"); } }
public void Confirm_course_Report() { Ship_Movement shipscript = ship.GetComponent <Ship_Movement>(); if (shipscript.get_target_port() != current_location) { CameraScript camscript = cam.GetComponent <CameraScript>(); Camera_Orbit camorbit = cam.GetComponent <Camera_Orbit>(); camscript.enabled = false; camorbit.enabled = true; //chart_course_button.SetActive(true); //set_sail_button.SetActive(true); //enter_market_button.SetActive(true); //enter_tavern_button.SetActive(true); //confirm_course_button.SetActive(false); //reset_course_button.SetActive(false); uiScript.ChartReportUI(false); uiScript.WeekInfoUI(true); courseCharter.GetComponent <Charting_a_Course>().enabled = false; } else { uiScript.ErrorDisp("You're either in town already, or need to let stocks replenish"); } }
private void Start() { movement = GetComponent <Ship_Movement>(); lineRenderer = CreateRenderer(false); lineRendererFuture = CreateRenderer(true); OnTurnStart(); }
// Temporary speed boost code IEnumerator speedBoost() { GameObject player = GameObject.FindGameObjectWithTag("Player"); Ship_Movement boost = player.GetComponent <Ship_Movement>(); boost.speed += 50; yield return(new WaitForSeconds(4)); revertSpeed(); }
public void hire_crew(int num) { //Debug.Log("hire_crew manager:"+num); Town townscript = current_location.GetComponent <Town>(); Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); townscript.hire_crew(num); //crew_count_text.text = ("Crew Count: "+ship_script.get_crew_count().ToString()); uiScript.updateCrewCount(ship_script.get_crew_count(), required_crew_count); }
public void give_rum() { if (rum_cargo_count > 0) { Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); ship_script.give_rum(); rum_cargo_count--; } else { uiScript.ErrorDisp("can't give what aint there"); print("can't give what aint there"); } }
public void In_To_Port(GameObject location) { Ship_Movement shipscript = ship.GetComponent <Ship_Movement>(); shipscript.inport = true; current_location = location; if (location.tag == "town") { SetUpTown(location); } CameraScript camscript = cam.GetComponent <CameraScript>(); Camera_Orbit camorbit = cam.GetComponent <Camera_Orbit>(); camscript.enabled = true; camorbit.enabled = false; }
public void upgrade_ship() { if (second_upgrade) { uiScript.ErrorDisp("no furthur upgrade available"); } else if (first_upgrade) { if (gold >= 500) { max_cargo = 40; required_crew_count = 9; //gold -= 500; second_upgrade = true; uiScript.updateUpgradeInfo("No more upgrades available"); change_gold(-500); Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); uiScript.updateCrewCount(ship_script.get_crew_count(), required_crew_count); uiScript.updateCargoCount(0, max_cargo); } else { uiScript.ErrorDisp("You don't have enough gold for an upgrade"); } } else { if (gold >= 250) { max_cargo = 25; required_crew_count = 6; first_upgrade = true; uiScript.updateUpgradeInfo("Cost: 500\nHold Storage: +15\nMinimum Crew: 9"); change_gold(-250); Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); uiScript.updateCrewCount(ship_script.get_crew_count(), required_crew_count); uiScript.updateCargoCount(0, max_cargo); } else { uiScript.ErrorDisp("You don't have enough gold for an upgrade"); } } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Create_point_and_line(); //StartCoroutine("Create_point_and_line"); } Draw_Chart_path.path = b_agent.path.corners; if (!(b_agent.pathPending)) { weekdis = (int)(Mathf.Floor(RemainingDistance(b_agent.path.corners) / dis_in_a_week)); Ship_Movement shipscript = boat.GetComponent <Ship_Movement>(); if (current_hit != null) { Town townscript = current_hit.GetComponent <Town>(); uiScript.updateTownInfo("Journey length: " + weekdis + " weeks\nRum price: " + townscript.get_buy_amount("rum") + "\nSpice price: " + townscript.get_buy_amount("spice") + "\nTimber price: " + townscript.get_buy_amount("timber") + "\nMedicine price: " + townscript.get_buy_amount("med") + "\nRations price: " + 1); } } }
public void fire_crew(int num) {//Removes a crewmate from crew listing //Debug.Log("fire_crew manager:"+num); print("num: " + num); Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); print(1); Crew r_fired = ship_script.get_crew_at_spot(num); print(2); Town townscript = current_location.GetComponent <Town>(); print(3); townscript.fired_crew(r_fired); print(4); ship_script.fire_crew(num); print(5); //crew_count_text.text = ("Crew Count: "+ship_script.get_crew_count().ToString()); uiScript.DestroyCrewShip(num); uiScript.updateCrewCount(ship_script.get_crew_count(), required_crew_count); }
void Create_point_and_line() { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (EventSystem.current.IsPointerOverGameObject() == false) // is the touch on the GUI { if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { if (hit.transform.tag == "town" || hit.transform.tag == "island") { Ship_Movement shipscript = boat.GetComponent <Ship_Movement>(); current_hit = hit.transform.gameObject; b_agent.SetDestination(hit.transform.GetChild(1).transform.position); shipscript.set_Port(hit.transform.gameObject); Draw_Chart_path.path = b_agent.path.corners; b_agent.isStopped = true; } } } }
private void LateUpdate() { if (!inPosition) { b_agent.isStopped = true; if (Vector3.Distance(transform.position, ship.transform.GetChild(0).transform.position) > 5.0) { transform.position = Vector3.Lerp(transform.position, ship.transform.GetChild(0).transform.position, zoomspeed * Time.deltaTime); } if (Vector3.Distance(transform.position, ship.transform.GetChild(0).transform.position) <= 5.0) { transform.position = Vector3.MoveTowards(transform.position, ship.transform.GetChild(0).transform.position, lookSpeed * Time.deltaTime); } if (transform.position == ship.transform.GetChild(0).transform.position) { inPosition = true; Ship_Movement shipscript = ship.GetComponent <Ship_Movement>(); shipscript.enabled = true; ManagerScript manage = manager.GetComponent <ManagerScript>(); if (!manage.in_week_report) { b_agent.isStopped = false; } } } if (inPosition) { offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * turnSpeed, Vector3.up) * offset; transform.position = ship.transform.position - offset; } //relPos = ship.transform.position - transform.position; //newRot = Quaternion.LookRotation(relPos); //transform.rotation = Quaternion.RotateTowards(transform.rotation, newRot, Time.time * lookSpeed); Vector3 pos = ship.transform.GetChild(1).transform.position; transform.LookAt(pos); }
public void Confirm_course() { Ship_Movement shipscript = ship.GetComponent <Ship_Movement>(); if (shipscript.get_target_port() != current_location) { CameraScript camscript = cam.GetComponent <CameraScript>(); camscript.Look_at_Location(current_location); //chart_course_button.SetActive(true); //set_sail_button.SetActive(true); //enter_market_button.SetActive(true); //enter_tavern_button.SetActive(true); //confirm_course_button.SetActive(false); //reset_course_button.SetActive(false); uiScript.ChartUI(false); uiScript.TownUI(true); courseCharter.GetComponent <Charting_a_Course>().enabled = false; } else { uiScript.ErrorDisp("You're already there you fool!"); } }
//code for the stuff that comes after events public void weekReport() { int rations_used = 0; in_week_report = true; Camera_Orbit camorbit = cam.GetComponent <Camera_Orbit>(); camorbit.enabled = false; Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); int spread = ship_script.handle_mutiny_spread(); if (spread > 0) { event_outcome += "\n" + spread + " crew members have lowered the loyalty of others in order to try and mutiny"; } int gold_change = ship_script.get_wages(); change_gold(-gold_change); //print(event_outcome); if (current_ration_state > (rations_cargo_count / 3)) { current_ration_state--; uiScript.ErrorDisp("ration plan has been lowered for the future due to lack of food"); } if (current_ration_state > (rations_cargo_count / 3)) { current_ration_state--; uiScript.ErrorDisp("ration plan has been lowered for the future due to lack of food"); } bool tempspice = using_spice; if (using_spice) { if (current_ration_state == 0) { tempspice = false; event_outcome += "\nAttempted to give your crew spice but you had no food to pair it with"; } else if (spice_cargo_count > 0) { spice_cargo_count--; event_outcome += "\nSpice was used and the loyalty of every crewmate was increased by 3"; } else { tempspice = false; event_outcome += "\nAttempted to give your crew spice when you had none"; } } if (current_ration_state == 2) { event_outcome += ship_script.extra_rations(tempspice); rations_cargo_count -= (ship_script.get_crew_count() * 2); rations_used = (ship_script.get_crew_count() * 2); } if (current_ration_state == 1) { event_outcome += ship_script.normal_rations(tempspice); rations_cargo_count -= ship_script.get_crew_count(); rations_used = ship_script.get_crew_count(); } if (current_ration_state == 0) { event_outcome += ship_script.no_rations(tempspice); rations_used = 0; } if (rations_cargo_count < 0) { rations_cargo_count = 0; } string report = gold_change + " gold was spent to pay your crew\n" + rations_used + " rations were used to fed your crew\n" + event_outcome; uiScript.weekInfoDisp(report); uiScript.EventResultUI(false); uiScript.WeekInfoUI(true); uiScript.updateCargoCount(((rations_cargo_count / 3) + med_cargo_count + timber_cargo_count + spice_cargo_count + rum_cargo_count), max_cargo); uiScript.cargoUpdate(); }
public void handle_event(Event e, int result) { Camera_Orbit camorbit = cam.GetComponent <Camera_Orbit>(); camorbit.enabled = false; if (e.get_id() == 0) { if (result == 1) { int stolen_good = Random.Range(0, 5); if (stolen_good == 0) { rum_cargo_count -= 3; event_outcome = "three cases of rum were stolen"; } if (stolen_good == 1) { spice_cargo_count -= 3; event_outcome = "three cases of spice were stolen"; } if (stolen_good == 2) { timber_cargo_count -= 3; event_outcome = "three crates of timber were stolen"; } if (stolen_good == 2) { med_cargo_count -= 3; event_outcome = "three crates of medicine were stolen"; } } if (result == 2) { int stolen_good = Random.Range(0, 5); if (stolen_good == 0) { rum_cargo_count -= 1; event_outcome = "three cases of rum were stolen"; } if (stolen_good == 1) { spice_cargo_count -= 1; event_outcome = "three cases of spice were stolen"; } if (stolen_good == 2) { timber_cargo_count -= 1; event_outcome = "three crates of timber were stolen"; } if (stolen_good == 2) { med_cargo_count -= 1; event_outcome = "three crates of rum were stolen"; } } if (med_cargo_count < 0) { med_cargo_count = 0; } if (timber_cargo_count < 0) { timber_cargo_count = 0; } if (spice_cargo_count < 0) { spice_cargo_count = 0; } if (rum_cargo_count < 0) { rum_cargo_count = 0; } } if (e.get_id() == 1) { if (result == 1) { timber_cargo_count -= 3; rations_cargo_count -= 3; event_outcome = "Three crates of timber and 3 rations were lost"; if (timber_cargo_count < 0) { uiScript.loseDisp("The storm tore your ship apart and with no resources to repair it, you and your crew remain adrift at sea"); } } if (result == 2) { event_outcome = "The loyalty of all crew was lowered by one"; } } if (e.get_id() == 2) { if (result == 0) { event_outcome = "The loyalty of all crew was raised by two"; } if (result == 1) { med_cargo_count -= 3; timber_cargo_count -= 3; event_outcome = "three crates of medicine and three crates of timber were lost"; if (timber_cargo_count < 0 || med_cargo_count < 0) { uiScript.loseDisp("Too many are out of action from the lack of supplies, and the your ship slowly sets adrift, with your crew unable to stop"); } } if (result == 2) { med_cargo_count--; timber_cargo_count--; event_outcome = "one crate of medicine and one crate of timber were lost"; if (timber_cargo_count < 0 || med_cargo_count < 0) { uiScript.loseDisp("Too many are out of action from the lack of supplies, and the your ship slowly sets adrift, with your crew unable to stop"); } } } if (e.get_id() == 3) { int r = Random.Range(0, 4); Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); int add = ship_script.get_lucky_num() * 2; if (r == 0) { rum_cargo_count += 1 + add; event_outcome = (1 + add) + " crates of rum were found as floatsam"; } if (r == 1) { spice_cargo_count += 1 + add; event_outcome = (1 + add) + " crates of spice were found as floatsam"; } if (r == 2) { timber_cargo_count += 1 + add; event_outcome = (1 + add) + " crates of timber were found as floatsam"; } if (r == 3) { med_cargo_count += 1 + add; event_outcome = (1 + add) + " crates of medicine were found as floatsam"; } } if (e.get_id() == 4) { if (result == 1) { med_cargo_count--; event_outcome = "one crate of medicine was lost to cure a sickness"; if (med_cargo_count < 0) { uiScript.loseDisp("Without medicine to help stop the spread, the disease ravages you all"); } } } if (e.get_id() == 5) { if (result == 1) { timber_cargo_count--; event_outcome = "one crate of timber was lost to fix up your ship from rough seas"; if (timber_cargo_count < 0) { uiScript.loseDisp("Unable to repair your ship, the damaged vessal slowly drifts to open ocean, never to be seen again"); } } } if (e.get_id() == 6) { timber_cargo_count--; event_outcome = "one crate of timber was lost to fix up your ship from an accident"; if (timber_cargo_count < 0) { uiScript.loseDisp("Unable to repair your ship, the damaged vessal slowly drifts to open ocean, never to be seen again"); } } if (e.get_id() == 7) { if (result == 0) { event_outcome = "One of your crew had their wage increase by 1 and their loyalty increase by 2"; } if (result == 1) { event_outcome = "One of your crew has lost 3 loyalty from being denied a raise"; } } if (e.get_id() == 8) { if (result == 0) { event_outcome = "all of your crew with less than 5 loyalty have lost 1 loyalty and the one who tried to mutiny is loyal again"; } if (result == 1) { event_outcome = "One of your crew has walked the plank, and the rest know now to fear you"; } } //uiScript.updateCargoCount(((rations_cargo_count / 3) + med_cargo_count + timber_cargo_count + spice_cargo_count + rum_cargo_count), max_cargo); //uiScript.cargoUpdate(); }
private void Start() { movement = GetComponent <Ship_Movement>(); CreateMarker(); }
// Start is called before the first frame update void Start() { crew_names = new List <string>(); trait1_lis = new List <string>(); trait2_lis = new List <string>(); trait1d = new List <string>(); trait2d = new List <string>(); current_location = start_town; using_spice = false; rum_dif_int = 0; spice_dif_int = 0; timber_dif_int = 0; med_dif_int = 0; rations_dif_int = 0; rations_dif_int = 0; change_gold(0); current_ration_state = 1; Ship_Movement ship_script = ship.GetComponent <Ship_Movement>(); uiScript.updateCrewCount(ship_script.get_crew_count(), required_crew_count); uiScript.updateCargoCount(0, max_cargo); uiScript.updateUpgradeInfo("Cost: 250\nHold Storage: +10\nMinimum Crew: 6"); //where you load the strings from a text file for crew generation StreamReader sr = new StreamReader("Assets/CrewNames.txt"); string line; while ((line = sr.ReadLine()) != null) { crew_names.Add(line); } sr.Close(); sr = new StreamReader("Assets/Traits_1.txt"); while ((line = sr.ReadLine()) != null) { trait1_lis.Add(line); } sr.Close(); sr = new StreamReader("Assets/Traits_2.txt"); while ((line = sr.ReadLine()) != null) { trait2_lis.Add(line); } sr.Close(); sr = new StreamReader("Assets/T1_D.txt"); while ((line = sr.ReadLine()) != null) { trait1d.Add(line); } sr.Close(); sr = new StreamReader("Assets/T2_D.txt"); while ((line = sr.ReadLine()) != null) { trait2d.Add(line); } sr.Close(); SetUpTown(start_town); //uiScript = canvas.GetComponent<UIManager>(); first_upgrade = false; second_upgrade = false; in_week_report = false; }