Example #1
0
 private void OrderHandler(ElementBox otherBox)
 {
     if (otherBox.element == Element.Chaos)
     {
         Object.Destroy(otherBox.gameObject);
     }
 }
Example #2
0
 private void VoidHandler(ElementBox otherBox)
 {
     if (otherBox.category != Category.Void && otherBox.category != Category.Balance)
     {
         Object.Destroy(otherBox.gameObject);
     }
 }
Example #3
0
    private void OnCollisionEnter(Collision collision)
    {
        ElementBox box = collision.gameObject.GetComponent <ElementBox>();

        if (box)
        {
            handler(box);
        }
    }
        public void SetBoxVisibility(ElementBox elementBox, bool isVisible)
        {
            Control box = GetElementBox(elementBox);

            if (box != null)
            {
                box.Visibility = isVisible ? Visibility.Visible : Visibility.Hidden;
            }
        }
Example #5
0
 private void LifeHandler(ElementBox otherBox)
 {
     if (otherBox.element == Element.Death)
     {
         Object.Destroy(otherBox.gameObject);
     }
     else if (otherBox.element == Element.Chaos)
     {
         spawnElementManifest(otherBox);
     }
 }
Example #6
0
 private void DeathHandler(ElementBox otherBox)
 {
     if (otherBox.element == Element.Life)
     {
         Object.Destroy(otherBox.gameObject);
     }
     else if (otherBox.element == Element.Order)
     {
         spawnElementManifest(otherBox);
     }
 }
Example #7
0
    private void spawnElementManifest(ElementBox otherBox)
    {
        // -- Start at average position between boxes.
        Vector3 startPosition = (transform.position + otherBox.transform.position) / 2;

        // -- Use highest magnitude velocity to decide on direction.
        Vector3 thisVelocity  = GetComponentInParent <Rigidbody>().velocity;
        Vector3 otherVelocity = otherBox.GetComponentInParent <Rigidbody>().velocity;

        Vector3 manifestDirection = (thisVelocity.magnitude >= otherVelocity.magnitude) ? thisVelocity : otherVelocity;

        // -- Prevent manifestObject from spawning at a weird angle if ElementBoxes are falling, rising, or at different heights.
        manifestDirection.y = 0;
        manifestDirection   = Vector3.Normalize(manifestDirection);

        // -- Align parallel to any nearby ground surface
        RaycastHit hit;
        Vector3    hitNormal = Vector3.up;

        if (Physics.Raycast(startPosition, Vector3.down, out hit, groundScanDistance, ~ElementBoxesLayer) && hit.normal != Vector3.up)
        {
            hitNormal         = hit.normal;
            manifestDirection = Vector3.Normalize(manifestDirection + Vector3.Reflect(manifestDirection, hitNormal));
        }

        Quaternion manifestRotation = Quaternion.LookRotation(manifestDirection, hitNormal);

        // -- The center of one bottom-corner of manifestObject should start at startPosition.
        Vector3 manifestSize = manifestObject.GetComponent <Renderer>().bounds.size;
        Vector3 elementSize  = GetComponentInParent <Renderer>().bounds.size;

        // -- Move away from ground the proper amount.
        startPosition += hitNormal * (manifestSize.y / 2 - elementSize.y / 2 + manifestGroundSpacing);
        // --  Move away from collision point the proper amount.
        startPosition += (manifestDirection * manifestSize.z / 2);

        Instantiate(manifestObject, startPosition, manifestRotation);

        Object.Destroy(otherBox.gameObject);
        Object.Destroy(gameObject);
    }
        private MathBox GetElementBox(ElementBox elementBox)
        {
            MathBox box = null;

            switch (elementBox)
            {
            case ElementBox.Main:
                box = main;
                break;

            case ElementBox.Sub:
                box = sub;
                break;

            case ElementBox.Sup:
                box = sup;
                break;
            }

            return(box);
        }
Example #9
0
 private void BalanceHandler(ElementBox otherBox)
 {
     // -- Balance intentionally does nothing.
 }
        public void FocusBox(ElementBox elementBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Default)
        {
            MathBox mathBox = GetElementBox(elementBox);

            FocusBox(mathBox, boxCaretPosition);
        }