示例#1
0
        public static Directions2D GetCursorHoverOnBorders(
            this RectangleF me,
            Point2 p,
            float border_thickness
            )
        {
            var areas  = GetBorderArea(me, border_thickness);
            var result = new Directions2D();

            if (areas[0].Contains(p))
            {
                result.Up = true;
            }
            if (areas[1].Contains(p))
            {
                result.Right = true;
            }
            if (areas[2].Contains(p))
            {
                result.Down = true;
            }
            if (areas[3].Contains(p))
            {
                result.Left = true;
            }

            return(result);
        }
示例#2
0
    private void BranchBloom(Vector3 startPoint, float overshotBy = 0f, bool extraBranches = false)
    {
        Directions2D._directions newDir = NewBranchDirection(startPoint);
        Branch(startPoint, overshotBy, extraBranches, newDir);
        Branch(startPoint, overshotBy, extraBranches, Directions2D.OppositeDirection(newDir));

        Debug.Log("Bloom called");
    }
 GeneralVisualSettings(GeneralVisualSettings source)
 {
     VisualRole             = source.VisualRole;
     ColorScheme            = (BaseColorScheme)source.ColorScheme.Clone();
     ChangeColorOnMouseOver = source.ChangeColorOnMouseOver;
     DrawBackground         = source.DrawBackground;
     DrawOutline            = source.DrawOutline;
     OutlineSides           = source.OutlineSides;
 }
示例#4
0
    private Vector3 FrontBranchPoint()
    {
        Vector3 endPoint = transform.position + Directions2D.DirectionalVector(growDir, transform.lossyScale) / 2;

        //endPoint -= Directions2D.FlattenToDirection (growDir, startingScale) / 2;
        // ODOT, make positive
        endPoint -= Directions2D.DirectionalVector(growDir, startingScale) / 2;
        return(endPoint);
    }
 public static WidgetTransitionAnimation Slide(
     Direction2D direction,
     InterpolationSettings?interpolation = null
     ) =>
 new WidgetTransitionAnimation(
     InnerWidgetLocation.Outside(Directions2D.GetOppositeSide(direction)),
     InnerWidgetLocation.Outside(direction),
     interpolation ?? InterpolationSettings.Fast,
     interpolation ?? InterpolationSettings.Fast
     );
示例#6
0
    public static Vector3 DirectionalVector(Directions2D._directions direction, Vector3 rawVector)
    {
        Vector3 newVector = rawVector;

        if (direction == Directions2D._directions.numDirections)
        {
            Debug.Log("Warning: Directions2D.DirectionalVector was passed \"numDirections\" as reference direction.");
            newVector = Vector3.zero;
        }

        if ((int)direction < (int)Directions2D._directions.numDirections / 2)
        {
            newVector.x = 0f;
            Directions2D.MatchSign(direction, ref newVector.y);
        }
        else
        {
            newVector.y = 0f;
            Directions2D.MatchSign(direction, ref newVector.x);
        }

        return(newVector);
    }
示例#7
0
 void Awake()
 {
     pairDirection = Directions2D.FindDirection(gameObject.transform, pairedTrigger.transform);
     hallDirection = Directions2D.FindDirection(gameObject.transform, oppositeTrigger.transform);
 }
示例#8
0
    private void HallwayTriggers(Collider other)
    {
        if (DEBUGHALL)
        {
            //Debug.Log ("HallwayTriggers called for trigger = " + other.gameObject.tag + "   object = " + other.gameObject.name);
        }

        if (other.gameObject.CompareTag("Hall Start Trigger") && !other.GetComponent <HallwayTrigger> ().hall.pinkHasTraversed)
        {
            if (DEBUGHALL)
            {
                Debug.Log("hit hall start trigger");
            }

            HallwayTrigger hallTrig = other.GetComponent <HallwayTrigger> ();

            if (hallwayMode == _hallwayMode.off)
            {
                if (DEBUGHALL)
                {
                    Debug.Log("hallway mode was off when hit");
                }

                if (growDir == hallTrig.hallDirection)
                {
                    // confirmed pink is growing in same direction as the length of the hallway


                    float otherPos   = Directions2D.FlattenToDirection(Directions2D.OppositeAxis(growDir), other.transform.position);
                    float pairPos    = Directions2D.FlattenToDirection(Directions2D.OppositeAxis(growDir), hallTrig.pairedTrigger.transform.position);
                    float thisPos    = Directions2D.FlattenToDirection(Directions2D.OppositeAxis(growDir), transform.position);
                    float otherScale = Directions2D.FlattenToDirection(Directions2D.OppositeAxis(growDir), other.transform.lossyScale);
                    float thisScale  = Directions2D.FlattenToDirection(Directions2D.OppositeAxis(growDir), transform.lossyScale);

                    float triggerDistance = Mathf.Abs(pairPos - otherPos);
                    float midpoint        = triggerDistance / 2 + otherPos;
                    float allowance       = thisScale - (triggerDistance - otherScale);

                    if (DEBUGHALL)
                    {
                        Debug.Log("growdir same as hallway, triggerDistance = " + triggerDistance + "   midpoint = " + midpoint + "   allowance = " + allowance);
                    }

                    if (thisPos > midpoint - allowance && thisPos < midpoint + allowance)
                    {
                        // confirmed pink is centered enough that it has hit both hall triggers
                        // it will clear the hallway walls and only needs to be extended
                        if (DEBUGHALL)
                        {
                            Debug.Log("start traversing");
                        }
                        float hallLength = Directions2D.FlattenToDirection(growDir, other.transform.position - hallTrig.oppositeTrigger.transform.position);
                        maxScaling += Mathf.Abs(hallLength);
                        hallwayMode = _hallwayMode.traversing;
                        hallTrig.hall.pinkHasTraversed = true;
                    }
                    else
                    {
                        // pink is not centered enough and needs to branch to align
                        // create connecting branch
                        Pink newBranch = Branch(FrontBranchPoint(), 0f, true, hallTrig.pairDirection, _hallwayMode.connecting);
                    }
                }
                else if (growDir == hallTrig.pairDirection)
                {
                    // confirmed pink is growing in direction of paired hallway trigger
                    float connectionLength = Directions2D.FlattenToDirection(growDir, other.transform.position - hallTrig.pairedTrigger.transform.position);
                    maxScaling += Mathf.Abs(connectionLength);
                    hallwayMode = _hallwayMode.connecting;
                }
            }
            else if (hallwayMode == _hallwayMode.connecting && hallStartTriggersHit % 2 == 1)
            {
                // create traversing branch
                Pink newBranch = Branch(FrontBranchPoint(), 0f, true, hallTrig.hallDirection, _hallwayMode.traversing);

                float hallLength = Directions2D.FlattenToDirection(hallTrig.hallDirection, other.transform.position - hallTrig.oppositeTrigger.transform.position);
                newBranch.maxScaling += Mathf.Abs(hallLength);

                hallwayMode = _hallwayMode.off;
                hallTrig.hall.pinkHasTraversed = true;
            }

            hallStartTriggersHit++;
        }
        else if (other.gameObject.CompareTag("Hall End Trigger") && !hallTriggersHit.Contains(other))
        {
            // hit end point

            if (hallwayMode == _hallwayMode.traversing && hallTriggersHit.Count > 0)
            {
                // branch both directions
                if (DEBUGHALL)
                {
                    Debug.Log("hit hall end trigger while traversing");
                }

                BranchBloom(FrontBranchPoint(), 0f, true);
                hallwayMode = _hallwayMode.off;
            }
            hallTriggersHit.Add(other);
        }
    }
示例#9
0
 public static RectanglePart Uniform(float indent, Directions2D directions, float others) =>
 new RectanglePart(
     directions.Up ? indent : others,
     directions.Down ? indent : others,
     directions.Left ? indent : others,
     directions.Right ? indent : others);