Example #1
0
    /// <summary>
    /// initializes two player setup
    /// </summary>
    void InstantTwoPlayerSetup(Border borderA, Border borderB)
    {
        // grab target points
        Vector2 targetPoint1, targetPoint2;
        Vector2 targetDir = GetTwoPlayerSplitDirection(borderA, borderB, out targetPoint1, out targetPoint2);

        // assign targets based on who's closest to what
        Vector2 aDir, bDir;
        aDir = (borderA.outerPoint - ScreenUtilities.screenCenter).normalized;
        bDir = (borderB.outerPoint - ScreenUtilities.screenCenter).normalized;
        if (Vector3.Dot(targetDir, aDir) > Vector3.Dot(targetDir, bDir))
        {
            borderA.outerPointTarget = targetPoint1;
            borderB.outerPointTarget = targetPoint2;
        }
        else
        {
            borderA.outerPointTarget = targetPoint2;
            borderB.outerPointTarget = targetPoint1;
        }

        borderA.centerPointTarget = ScreenUtilities.screenCenter;
        borderB.centerPointTarget = ScreenUtilities.screenCenter;
        borderA.centerPoint = ScreenUtilities.screenCenter;
        borderB.centerPoint = ScreenUtilities.screenCenter;

        borderA.ResetPoints(true, true);
        borderB.ResetPoints(true, true);

        TwoPlayerSetupSpecifics(borderA, borderB, targetDir, true);
    }