Exemple #1
0
        private void satellite_fixed_update()
        {
            float   bearing = (internal_transform.localEulerAngles.z + 90) * Mathf.Deg2Rad;
            Vector2 input   = new Vector2(Mathf.Cos(bearing), Mathf.Sin(bearing)) * DebrisNoirsInput.get_accelerate();

            // add velocity based on input
            planetaria_rigidbody.relative_velocity += input * Time.fixedDeltaTime;
            Vector2 velocity = planetaria_rigidbody.relative_velocity;

            // drag in coincident direction varies from coefficient of 1->~0.8->~0.5
            float   similarity          = Vector2.Dot(velocity.normalized, input);
            float   drag_modifier       = Mathf.Lerp(0.6f, 1.0f, (similarity + 1f) / 2);
            Vector2 coincident_velocity = input != Vector2.zero ? (Vector2)Vector3.Project(velocity, input) : velocity;

            coincident_velocity *= Mathf.Pow(drag_modifier, Time.deltaTime);

            // get perpendicular velocity (unmodified)
            Vector2 perpendicular_velocity = input != Vector2.zero ? Vector3.ProjectOnPlane(velocity, input) : Vector3.zero;

            // apply velocity changes
            planetaria_rigidbody.relative_velocity = coincident_velocity + perpendicular_velocity;

            // apply unusued drag
            //planetaria_rigidbody.relative_velocity *= Mathf.Pow(0.8f, Time.deltaTime * (1f - input_direction.magnitude));
        }
Exemple #2
0
        private void LateUpdate()
        {
            Vector3 character_position  = main_character.forward;
            Vector3 controller_position = main_controller.forward;
            Vector3 crosshair_up        = Bearing.repeller(controller_position, character_position);

            crosshair_renderer.angle = Vector3.SignedAngle(main_controller.up, crosshair_up, main_controller.forward) * Mathf.Deg2Rad;
            crosshair_renderer.scale = Mathf.Lerp(0, crosshair_size, DebrisNoirsInput.get_axes().magnitude);
        }
Exemple #3
0
        private void satellite_update()
        {
            float rotation_input = DebrisNoirsInput.get_rotate();

            if (rotation_input != 0)
            {
                float current_angle = internal_transform.localEulerAngles.z;
                internal_transform.localEulerAngles = new Vector3(0, 0, current_angle + rotation_input * Time.deltaTime * 180f);
            }
        }
Exemple #4
0
        private void Update()
        {
            Vector3 rail_position    = turret.forward;
            Vector3 bullet_direction = turret.up;

            if (DebrisNoirsInput.firing() && satellite.alive()) // if firing and not dead
            {
                PlanetariaGameObject.Instantiate(projectile, rail_position, bullet_direction);
            }
        }
Exemple #5
0
        private void ghost_update()
        {
            Vector2 input_direction = DebrisNoirsInput.get_axes();

            if (input_direction.sqrMagnitude > 0)
            {
                float target_angle  = Mathf.Atan2(input_direction.y, input_direction.x) - Mathf.PI / 2;
                float current_angle = internal_transform.localEulerAngles.z;
                float delta_angle   = Mathf.Abs(Mathf.DeltaAngle(current_angle, target_angle * Mathf.Rad2Deg));
                float interpolator  = 360 * 3 / delta_angle * Time.deltaTime;
                float new_angle     = Mathf.LerpAngle(current_angle, target_angle * Mathf.Rad2Deg, interpolator);
                internal_transform.localEulerAngles = new Vector3(0, 0, new_angle);
            }
        }
Exemple #6
0
        private void Update()
        {
            if (!dead)
            {
                satellite_update();
            }
            else if (dead_time < 0)
            {
                ghost_update();
            }
            else if (dead_time >= 0)
            {
                dead_update();
            }

            if (dead)
            {
                if (dead_time < 0)
                {
                    ghost_renderer.enabled  = true;
                    crosshair_dot.enabled   = false;
                    crosshair_arrow.enabled = true;
                }
                dead_time    -= Time.deltaTime;
                respawn_time += Time.deltaTime / 2;
                if (DebrisNoirsInput.get_axes().magnitude > 0.3f)
                {
                    respawn_time = 0;
                }
                if (dead_time < 0)
                {
                    if (DebrisNoirsInput.get_axes().magnitude > 0.3f)
                    {
                        satellite_renderer.enabled = false;
                        ghost_renderer.enabled     = true;
                    }
                    else
                    {
                        satellite_renderer.enabled = true;
                        ghost_renderer.enabled     = false; // essentially an OnMouseHover() event where the ship looks like it is alive
                    }
                }
                loading_disc.fillAmount = respawn_time;
                if (respawn_time >= 1)
                {
                    respawn();
                }
            }
        }
Exemple #7
0
        public Vector2 acceleration_direction()
        {
            float   current_angle = internal_transform.localEulerAngles.z;
            Vector2 direction     = new Vector2(Mathf.Cos(current_angle * Mathf.Deg2Rad), Mathf.Sin(current_angle * Mathf.Deg2Rad));

            if (DebrisNoirsInput.get_accelerate() == 1)
            {
                fuel += Time.deltaTime;
            }
            else
            {
                fuel -= Time.deltaTime;
            }
            fuel = Mathf.Clamp01(fuel);
            return(direction * fuel);
        }
Exemple #8
0
        private void Update()
        {
            Vector3 rail_position    = turret.forward;
            Vector3 bullet_direction = turret.up;

            if (DebrisNoirsInput.firing() && satellite.alive()) // if firing and not dead
            {
                if (projectiles_on_screen.Count < 14)           // FIXME: MAGIC NUMBER - number of bullets spawned per second
                {
                    PlanetariaGameObject spawned_projectile = PlanetariaGameObject.Instantiate(projectile, rail_position, bullet_direction);
                    projectiles_on_screen.Add(spawned_projectile.internal_game_object.GetComponent <Projectile>());
                }
                else
                {
                    projectiles_on_screen[next_projectile_to_reuse].respawn(rail_position, bullet_direction);
                    next_projectile_to_reuse += 1;
                    if (next_projectile_to_reuse >= 14)
                    {
                        next_projectile_to_reuse -= 14;
                    }
                }
            }
        }
Exemple #9
0
        private void ghost_fixed_update()
        {
            Vector2 input = DebrisNoirsInput.get_axes(); // HACK: double counting inside function call

            // add velocity based on input
            planetaria_rigidbody.relative_velocity += input * Time.deltaTime;
            Vector2 velocity = planetaria_rigidbody.relative_velocity;

            // drag in coincident direction varies from coefficient of 1->~0.8->~0.5
            float   similarity          = Vector2.Dot(velocity.normalized, input);
            float   drag_modifier       = Mathf.Lerp(0.6f, 1.0f, (similarity + 1f) / 2);
            Vector2 coincident_velocity = input != Vector2.zero ? (Vector2)Vector3.Project(velocity, input) : velocity;

            coincident_velocity *= Mathf.Pow(drag_modifier, Time.deltaTime);

            // get perpendicular velocity (unmodified)
            Vector2 perpendicular_velocity = input != Vector2.zero ? Vector3.ProjectOnPlane(velocity, input) : Vector3.zero;

            // apply velocity changes
            planetaria_rigidbody.relative_velocity = coincident_velocity + perpendicular_velocity;

            // apply unusued drag
            //planetaria_rigidbody.relative_velocity *= Mathf.Pow(0.8f, Time.deltaTime * (1f - input_direction.magnitude));
        }