Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time - createdTime < 0.2f)
        {
            return;
        }
        if (finished)
        {
            return;
        }

        if (physics.currentSpeed < 3 && !finished)
        {
            metrics.boostLeft = 0.0f;
            physics.ResetSpeed();
            GameController.instance.EndGame();
            finished = true;
        }

        transform.forward = Vector3.SmoothDamp(transform.forward, interactor.getInputForwardDirection(), ref velocity, baseTurnRate * physics.turnRateMultiplier);


        float scale = physics.currentSpeed;

        ParticleSystem.ShapeModule shape = system.shape;
        shape.scale = new Vector3(2, 0, scale);
        system.transform.localPosition = (Vector3.forward * -scale) * 0.75f;

        trail.time = 0.1f + (physics.currentSpeed / physics.maximumSpeed) * 2f;

        ParticleSystem.EmissionModule emission = system.emission;
        emission.rateOverTimeMultiplier = scale * 0.5f;

        if (interactor.getInputBoosting() && boostEnabled)
        {
            float boostAmount = Time.deltaTime * 20.0f;
            if (metrics.boostLeft > Time.deltaTime)
            {
                metrics.boostLeft -= Time.deltaTime;
                physics.AddSpeed(boostAmount);
            }
            else if (metrics.boostLeft > 0)
            {
                metrics.boostLeft = 0;
                physics.AddSpeed(boostAmount);
            }
            else
            {
                metrics.boostLeft = 0;
            }
        }
    }
Example #2
0
    void OnTriggerStay(Collider other)
    {
        PlayerPhysics physics     = other.GetComponent <PlayerPhysics>();
        PlayerAudio   playerAudio = other.GetComponent <PlayerAudio>();

        if (physics && gravityEnabled && parentNode.sunState == SunNode.SunState.ENABLED)
        {
            float sunTypeMultiplier = 1f;
            float timeMultiplier    = 1f;
            if (parentNode.sunType == SunNode.SunType.YELLOW)
            {
                sunTypeMultiplier = 1f;
            }
            else if (parentNode.sunType == SunNode.SunType.BLUE)
            {
                sunTypeMultiplier = 10;
            }
            else if (parentNode.sunType == SunNode.SunType.RED)
            {
                sunTypeMultiplier = 0.6f;
                timeMultiplier    = 2f;
            }


            Vector3 distanceVector = transform.position - other.transform.position;
            distanceVector.y = 0;
            float distance = distanceVector.magnitude;
            if (distance < innerRadius)
            {
                distance = innerRadius;
            }
            distance -= innerRadius;

            float force = 1 / Mathf.Pow(distance, 2);
            if (parentNode.sunState == SunNode.SunState.ENABLED)
            {
                force *= 1 + (((Time.time - enterTime) / 4) * timeMultiplier);
                force *= 1 + (parentNode.nodeRadius / 3);
                force *= 0.05f;
                force *= sunTypeMultiplier;
                force  = Mathf.Clamp(force, 0, mass);
                physics.AddSpeed(force * Time.deltaTime);
            }

            if (IsNodeDepleted())
            {
                if (playerAudio != null)
                {
                    playerAudio.PlayActivateSfx(this.gameObject);
                }

                PlayerMetrics.instance.MarkPoint(10, this.gameObject);
            }
        }
    }
Example #3
0
    void OnCollisionExit(Collision collision)
    {
        PlayerPhysics physics = collision.gameObject.GetComponent <PlayerPhysics>();

        if (physics)
        {
            physics.ResetSpeed();
            physics.AddSpeed(3);
        }

        if (nodeGravityEnabler != null)
        {
            StopCoroutine(nodeGravityEnabler);
        }
        nodeGravityEnabler = StartCoroutine(EnableNodeGravity());
    }
Example #4
0
    void OnCollisionEnter(Collision collision)
    {
        PlayerPhysics physics = collision.gameObject.GetComponent <PlayerPhysics>();

        if (physics)
        {
            physics.ResetSpeed();
            physics.AddSpeed(3);

            PlayerMetrics.instance.MarkPoint(-5, null);
        }

        if (nodeGravityEnabler != null)
        {
            StopCoroutine(nodeGravityEnabler);
        }
        nodeGravity.gravityEnabled = false;
    }
Example #5
0
    void OnTriggerStay(Collider other)
    {
        PlayerPhysics physics     = other.GetComponent <PlayerPhysics>();
        PlayerAudio   playerAudio = other.GetComponent <PlayerAudio>();

        if (physics && gravityEnabled)
        {
            Vector3 distanceVector = transform.position - other.transform.position;
            distanceVector.y = 0;
            float distance = distanceVector.magnitude;
            if (distance < innerRadius)
            {
                distance = innerRadius;
            }
            distance -= innerRadius;

            float force = 1 / Mathf.Pow(distance, 2);
            parentNode.remainingEnergy -= Time.deltaTime;
            if (parentNode.remainingEnergy > 0)
            {
                force = Mathf.Clamp(force, 0, mass);
                physics.AddSpeed(force * Time.deltaTime * 3);
            }

            if (IsNodeDepleted())
            {
                if (playerAudio != null)
                {
                    playerAudio.PlayActivateSfx(this.gameObject);
                }

                PlayerMetrics.instance.MarkPoint(10, this.gameObject);
            }
        }


        if (playerAudio != null)
        {
            playerAudio.PlaySpinSfx(this.gameObject);
        }
    }