Beispiel #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (restlessness == BallRestlessness.Normal && IsTimeToWarn())
        {
            //Debug.Log("adh'em DEES");
            restlessness = BallRestlessness.StoppingPuff;
            var sr = GetComponent <SpriteRenderer>();
            preAngerColor = sr.color;
            sr.color      = God.redFull;
            changeDelay   = noChangeTime - noChangeWarnTime;
            //Debug.Log("WHOA BURSTS!");
            var g = God.SpawnAt(burstEffect, transform.position);
            Destroy(g, changeDelay);
        }

        if (restlessness == BallRestlessness.StoppingPuff && IsTimeToFuckOff())
        {
            //Debug.Log("adderall ruined my life");
            FuckOff(1.0f, true);
        }

        AccumulateStaleness();

        // Update last logical position for comparison.
        lastPos = transform.position;
    }
Beispiel #2
0
    public virtual void FuckOff(float howFast = 1.0f, bool doShout = false)
    {
        var sr = GetComponent <SpriteRenderer>();

        sr.color = preAngerColor;

        if (doShout)
        {
            //God.main.Speak(gameObject, "NOPE");
            nope.Play();
        }

        timerUnchanged.x = 0.0f;
        timerUnchanged.y = 0.0f;

        // Get a random angle.

        /*
         * Vector2 v = Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.forward) * Vector3.up;
         * v.x *= rigid.velocity.normalized.x;
         * v.y *= rigid.velocity.normalized.y;
         *
         * rigid.AddForce(v * nopeSpeedFactor);
         */


        // Get a random angle.
        Vector3 v = Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.forward) * Vector3.up;

        rigid.AddForce(v * 300.0f);


        restlessness = BallRestlessness.Normal;
    }
Beispiel #3
0
    public virtual void FixedUpdate()
    {
        if (God.haggleLogic.IsRoundActive())
        {
            // Ensure we're active.
            if (rigid.constraints == RigidbodyConstraints2D.FreezeAll)
            {
                rigid.constraints = RigidbodyConstraints2D.None;
            }

            if (gravitizationTime <= 0.0f)
            {
                if (isGravitized)
                {
                    Degravitize();
                }

                AccumulateStaleness();

                if (restlessness == BallRestlessness.Normal && IsTimeToWarn())
                {
                    restlessness = BallRestlessness.StoppingPuff;
                    var sr = GetComponent <SpriteRenderer>();
                    preAngerColor = sr.color;
                    sr.color      = God.redFull;
                    changeDelay   = noChangeTime - noChangeWarnTime;
                    Debug.Log("WHOA BURSTS!");
                    var g = God.SpawnAt(burstEffect, transform.position);
                    Destroy(g, changeDelay);
                }

                if (restlessness == BallRestlessness.StoppingPuff && IsTimeToFuckOff())
                {
                    FuckOff(1.0f, true);
                }

                // Stay within min/max speed.
                if (rigid.velocity.magnitude < ballMinSpeed)
                {
                    rigid.velocity = rigid.velocity.normalized * ballMinSpeed;
                }
                else if (rigid.velocity.magnitude > ballMaxSpeed)
                {
                    rigid.velocity = rigid.velocity.normalized * ballMaxSpeed;
                }
            }
            else
            {
                gravitizationTime -= Time.fixedDeltaTime;
            }

            // Magnetization
            if (isMagnetized && magnetizeTarget)
            {
                var     tPos = magnetizeTarget.transform.position;
                Vector3 magDirection;
                if (isMagnetizedTowards)
                {
                    magDirection = Vector3.Normalize(tPos - transform.position);
                }
                else
                {
                    magDirection = Vector3.Normalize(transform.position - tPos);
                }
                rigid.AddForce(magDirection * magnetizeForce);
            }

            // Update last logical position for comparison.
            lastPos = transform.position;
        }
        else
        {
            rigid.constraints = RigidbodyConstraints2D.FreezeAll;
        }
    }