public override GameObject[] PlanFinalPosition() { GameObject[] result = new GameObject[1]; float distance = (TheShip.ShipBase.GetShipBaseDistance() + Speed * GetMovement1()); Vector3 position = TheShip.GetPosition(); position = Vector3.MoveTowards(position, position + TheShip.TransformDirection(Vector3.forward), distance); GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, TheShip.GetRotation(), BoardTools.Board.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); if (!DebugManager.DebugMovementShowTempBases) { foreach (var render in renderers) { render.enabled = false; } } result[0] = ShipStand; return(result); }
public override GameObject[] PlanMovement() { int precision = (IsSimple) ? 10 : 100; GameObject[] result = new GameObject[precision + 1]; float distancePart = (TheShip.ShipBase.GetShipBaseDistance() + Speed * GetMovement1()) / (float)precision; Vector3 position = TheShip.GetPosition(); for (int i = 0; i <= precision; i++) { if (i > 0) { position = Vector3.MoveTowards(position, position + TheShip.TransformDirection(Vector3.forward), distancePart); } GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, TheShip.GetRotation(), BoardTools.Board.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); if (!DebugManager.DebugMovementShowTempBases) { foreach (var render in renderers) { render.enabled = false; } } result[i] = ShipStand; } return(result); }
public void InitializeRendering() { GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); ShipStand = MonoBehaviour.Instantiate(prefab, TheShip.GetPosition(), TheShip.GetRotation(), BoardTools.Board.GetBoard()); ShipStand.transform.position = new Vector3(ShipStand.transform.position.x, 0, ShipStand.transform.position.z); foreach (Renderer render in ShipStand.transform.Find("ShipBase").GetComponentsInChildren <Renderer>()) { render.enabled = false; } ShipStand.transform.Find("ShipBase").Find("ObstaclesStayDetector").gameObject.AddComponent <ObstaclesStayDetectorForced>(); obstaclesStayDetectorBase = ShipStand.GetComponentInChildren <ObstaclesStayDetectorForced>(); obstaclesStayDetectorBase.TheShip = TheShip; Roster.SetRaycastTargets(false); }
public override GameObject[] PlanFinalPosition() { //Temporary MovementTemplates.ApplyMovementRuler(TheShip); GameObject[] result = new GameObject[1]; float distance = ProgressTarget; Vector3 position = TheShip.GetPosition(); GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, TheShip.GetRotation(), BoardTools.Board.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); if (!DebugManager.DebugMovementShowTempBases) { foreach (var render in renderers) { render.enabled = false; } } float turningDirection = (Direction == ManeuverDirection.Right) ? 1 : -1; ShipStand.transform.RotateAround(TheShip.TransformPoint(new Vector3(turningAroundDistance * turningDirection, 0, 0)), new Vector3(0, 1, 0), turningDirection * distance); UpdatePlanningRotation(ShipStand); position = ShipStand.transform.position; distance = TheShip.ShipBase.GetShipBaseDistance(); ShipStand.transform.position = Vector3.MoveTowards(position, position + ShipStand.transform.TransformDirection(Vector3.forward), distance); UpdatePlanningRotationFinisher(ShipStand); result[0] = ShipStand; ShipStand.name = "Finishing"; MovementTemplates.HideLastMovementRuler(); return(result); }
public override GameObject[] PlanMovement() { GameObject[] result = new GameObject[1]; Vector3 position = TheShip.GetPosition(); GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, TheShip.GetRotation(), BoardTools.Board.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); foreach (var render in renderers) { render.enabled = false; } result[0] = ShipStand; return(result); }
// PLANNING public override GameObject[] PlanMovement() { //Temporary MovementTemplates.ApplyMovementRuler(TheShip); GameObject[] result = new GameObject[101]; float distancePart = ProgressTarget / 80; Vector3 position = TheShip.GetPosition(); GameObject lastShipStand = null; for (int i = 0; i <= 80; i++) { float step = (float)i * distancePart; GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, TheShip.GetRotation(), Board.BoardManager.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); if (!DebugManager.DebugMovement) { foreach (var render in renderers) { render.enabled = false; } } if (i > 0) { float turningDirection = (Direction == ManeuverDirection.Right) ? 1 : -1; ShipStand.transform.RotateAround(TheShip.TransformPoint(new Vector3(turningAroundDistance * turningDirection, 0, 0)), new Vector3(0, 1, 0), turningDirection * step); UpdatePlanningRotation(ShipStand); if (i == 80) { lastShipStand = ShipStand; } } result[i] = ShipStand; ShipStand.name = "Main" + i; } GameObject savedShipStand = MonoBehaviour.Instantiate(lastShipStand); savedShipStand.transform.localEulerAngles -= new Vector3(0f, lastPlanningRotation, 0f); position = lastShipStand.transform.position; distancePart = TheShip.ShipBase.GetShipBaseDistance() / 20; for (int i = 1; i <= 20; i++) { position = Vector3.MoveTowards(position, position + savedShipStand.transform.TransformDirection(Vector3.forward), distancePart); GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); GameObject ShipStand = MonoBehaviour.Instantiate(prefab, position, savedShipStand.transform.rotation, Board.BoardManager.GetBoard()); Renderer[] renderers = ShipStand.GetComponentsInChildren <Renderer>(); if (!DebugManager.DebugMovement) { foreach (var render in renderers) { render.enabled = false; } } UpdatePlanningRotationFinisher(ShipStand); result[i + 80] = ShipStand; ShipStand.name = "Finishing" + i; } MonoBehaviour.Destroy(savedShipStand); MovementTemplates.HideLastMovementRuler(); return(result); }
private void ShowBoosterHelper() { SelectedBoostHelper = SelectedTemplate.Bearing + " " + ((SelectedTemplate.Speed == ManeuverSpeed.Speed1) ? "1" : "2") + ((SelectedDirectionSecondary == Direction.None) ? "" : " " + SelectedDirectionSecondary.ToString()); TheShip.GetBoosterHelper().Find(SelectedBoostHelper).gameObject.SetActive(true); Transform newBase = TheShip.GetBoosterHelper().Find(SelectedBoostHelper + "/Finisher/BasePosition"); GameObject prefab = (GameObject)Resources.Load(TheShip.ShipBase.TemporaryPrefabPath, typeof(GameObject)); TemporaryShipBase = MonoBehaviour.Instantiate(prefab, TheShip.GetPosition(), TheShip.GetRotation(), Board.GetBoard()); TemporaryShipBase.transform.position = new Vector3(newBase.position.x, 0, newBase.position.z); TemporaryShipBase.transform.rotation = newBase.rotation; GameManagerScript.Instance.StartCoroutine( CheckCollisionsOfTemporaryBoostElements(FinishBoost) ); }