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);
        }
Exemple #2
0
        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);
        }
        // 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 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();
        }