// MOVEMENT EXECUTION public override void UpdateMovementExecution() { float progressDelta = AnimationSpeed * Time.deltaTime; progressDelta = Mathf.Clamp(progressDelta, 0, Mathf.Abs(ProgressTarget - ProgressCurrent)); ProgressCurrent += progressDelta; if (!movementFinisherLaunched) { float turningDirection = (Direction == ManeuverDirection.Right) ? 1 : -1; int progressDirection = 1; TheShip.RotateAround(TheShip.TransformPoint(new Vector3(turningAroundDistance * turningDirection, 0, 0)), turningDirection * progressDelta * progressDirection); if (ProgressTarget != 0) { TheShip.RotateModelDuringTurn((ProgressCurrent / ProgressTarget) * (1 - 0.2f * finisherTargetSuccess)); } UpdateRotation(); } else { Vector3 progressDirection = Vector3.forward; TheShip.SetPosition(Vector3.MoveTowards(TheShip.GetPosition(), TheShip.GetPosition() + TheShip.TransformDirection(progressDirection), progressDelta)); if (finisherTargetSuccess != 0) { TheShip.RotateModelDuringTurn((1 - 0.2f * finisherTargetSuccess) + (ProgressCurrent / ProgressTarget) * 0.2f); } UpdateRotationFinisher(); } base.UpdateMovementExecution(); }
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 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 void UpdateMovementExecution() { float progressDelta = AnimationSpeed * Time.deltaTime; progressDelta = Mathf.Clamp(progressDelta, 0, Mathf.Abs(ProgressTarget - ProgressCurrent)); ProgressCurrent += progressDelta; TheShip.SetPosition(Vector3.MoveTowards(TheShip.GetPosition(), TheShip.GetPosition() + TheShip.TransformDirection(Vector3.forward), progressDelta)); base.UpdateMovementExecution(); }
private void StartBarrelRollExecution() { Rules.Collision.ClearBumps(TheShip); progressCurrent = 0; progressTarget = Vector3.Distance(TheShip.GetPosition(), TemporaryShipBase.transform.position); initialRotation = (TheShip.GetAngles().y < 180) ? TheShip.GetAngles().y : -(360 - TheShip.GetAngles().y); plannedRotation = (TemporaryShipBase.transform.eulerAngles.y - initialRotation < 180) ? TemporaryShipBase.transform.eulerAngles.y : -(360 - TemporaryShipBase.transform.eulerAngles.y); Sounds.PlayFly(TheShip); performingAnimation = true; }
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); }
private void DoBarrelRollAnimation() { float progressStep = 2.5f * Time.deltaTime * Options.AnimationSpeed; progressStep = Mathf.Min(progressStep, progressTarget - progressCurrent); progressCurrent += progressStep; TheShip.SetPosition(Vector3.MoveTowards(TheShip.GetPosition(), TemporaryShipBase.transform.position, progressStep)); TheShip.RotateModelDuringBarrelRoll(progressCurrent / progressTarget, HelperDirection); TheShip.SetRotationHelper2Angles(new Vector3(0, progressCurrent / progressTarget * (plannedRotation - initialRotation), 0)); TheShip.MoveUpwards(progressCurrent / progressTarget); if (progressCurrent >= progressTarget) { performingAnimation = false; GameMode.CurrentGameMode.FinishBarrelRoll(); } }
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); }
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) ); }
private void DoBarrelRollAnimation() { float progressStep = Time.deltaTime * 0.2f * (0.5f + Options.AnimationSpeed * 10f); progressStep = Mathf.Min(progressStep, progressTarget - progressCurrent); progressCurrent += progressStep; TheShip.SetPosition(Vector3.MoveTowards(TheShip.GetPosition(), TemporaryShipBase.transform.position, progressStep)); if (!IsTractorBeamBarrelRoll && !TheShip.IsLandedModel) { TheShip.RotateModelDuringBarrelRoll(progressCurrent / progressTarget, (Direction == Direction.Left) ? -1 : 1); TheShip.SetRotationHelper2Angles(new Vector3(0, progressCurrent / progressTarget * (plannedRotation - initialRotation), 0)); TheShip.MoveUpwards(progressCurrent / progressTarget); } if (progressCurrent >= progressTarget) { performingAnimation = false; FinishReposition(); } }
// 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); }