Beispiel #1
0
    // I've settled on the first prototype being a trail of evenly spaced VERY small dots.
    private void RenderRoute(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        Vector3 vPos = role.mStart;

        vPos.z = vPos.y - 1f;
        vPos.y = 1f;
        vPos  += snapSpot.transform.position;

        DATA_Route rt = IO_RouteList.FLOAD_ROUTE_BY_NAME(role.mDetail);

        for (int i = 0; i + 1 < rt.mSpots.Length; i++)
        {
            // render a bunch of spots, along the path from a -> b.
            Vector3 vStartPos = vPos + UT_VecConversion.ConvertVec2(rt.mSpots[i]);
            Vector3 vFinalPos = vPos + UT_VecConversion.ConvertVec2(rt.mSpots[i + 1]);

            Vector3 vIterPos = vStartPos;
            Vector3 vDir     = Vector3.Normalize(vFinalPos - vStartPos);
            while (Vector3.Dot(vDir, vFinalPos - vIterPos) > 0f)
            {
                Instantiate(GFX_RouteTrail, vIterPos, transform.rotation);
                vIterPos += vDir * 1f;
            }
        }
    }
Beispiel #2
0
    // Loads in all plays.
    public static void FLOAD_PLAYS()
    {
        string path = Application.dataPath + "/FILE_IO/Plays/";

        string[] fPathNames = Directory.GetFiles(path, "*.bin");
        foreach (string sName in fPathNames)
        {
            Debug.Log(sName);
        }

        mPlays = new DATA_Play[fPathNames.Length];
        for (int i = 0; i < fPathNames.Length; i++)
        {
            BinaryReader br = new BinaryReader(new FileStream(fPathNames[i], FileMode.Open));
            mPlays[i]       = new DATA_Play();
            mPlays[i].mName = br.ReadString();
            // Debug.Log("Play Name: " + mPlays[i].mName);
            mPlays[i].mPlayerRoles = new DT_PlayerRole[br.ReadInt32()];         // read in the number of players
            for (int j = 0; j < mPlays[i].mPlayerRoles.Length; j++)
            {
                DT_PlayerRole temp = new DT_PlayerRole();
                temp.mTag     = br.ReadString();
                temp.mRole    = br.ReadString();
                temp.mDetail  = br.ReadString();
                temp.mStart.x = br.ReadSingle();
                temp.mStart.y = br.ReadSingle();

                mPlays[i].mPlayerRoles[j] = temp;
            }
        }
    }
Beispiel #3
0
    public void BT_SavePlay()
    {
        if (rPlayInputText.text == string.Empty)
        {
            Debug.Log("Please enter a play name");
            return;
        }

        // gather up all the defenders in the scene.
        PE_Role[] roles = FindObjectsOfType <PE_Role>();
        DATA_Play ply   = new DATA_Play();

        ply.mName        = rPlayInputText.text;
        ply.mPlayerRoles = new DT_PlayerRole[roles.Length];     // Should always be 11.
        Debug.Log("Should be 11: " + ply.mPlayerRoles.Length);
        for (int i = 0; i < ply.mPlayerRoles.Length; i++)
        {
            DT_PlayerRole dtRole = new DT_PlayerRole();
            dtRole.mTag         = roles[i].mTag;
            dtRole.mRole        = roles[i].mRole;
            dtRole.mDetail      = roles[i].mDetails;
            dtRole.mStart       = roles[i].mStartPos;
            ply.mPlayerRoles[i] = dtRole;
        }
        IO_DefPlays.FWRITE_PLAY(ply);
    }
Beispiel #4
0
    // Fun fact, scriptable objects created at runtime will not be kept.

    public DATA_Play FConvertPlayToDATA(string sName)
    {
        DATA_Play play = new DATA_Play();

        play.mName = sName;

        // get array of all ED_Roles? Then save them.
        PE_Role[] roles = FindObjectsOfType <PE_Role>();
        play.mPlayerRoles = new DT_PlayerRole[roles.Length];
        for (int i = 0; i < roles.Length; i++)
        {
            DT_PlayerRole temp = new DT_PlayerRole();
            temp.mRole = roles[i].mRole;
            // temp.mStart = roles[i].mStartPos;
            temp.mTag = roles[i].mTag;

            // find the position from the field position.
            float fMetersToPixels = 50f / rField.GetComponent <RectTransform>().rect.width;      // field is 50 meters
            temp.mStart.x = (roles[i].transform.position.x - rField.transform.position.x) / fMetersToPixels;
            // adjust for starting on 10.
            temp.mStart.y = (roles[i].transform.position.y - rField.transform.position.y) / fMetersToPixels + 15f;

            // oh lol, forgot to add detail.
            temp.mDetail = roles[i].mDetails;

            play.mPlayerRoles[i] = temp;
        }

        return(play);
    }
Beispiel #5
0
    private void RenderPassBlock(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        // Make it just behind the player.
        Vector3 vPos = role.mStart;

        vPos.z = vPos.y - 1f;
        vPos.y = 1f;
        vPos  += snapSpot.transform.position;
        Instantiate(GFX_PassBlock, vPos, transform.rotation);
    }
Beispiel #6
0
    private void RenderRush(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        // Make it just behind the player.
        Vector3 vPos = UT_VecConversion.ConvertVec2(role.mStart);

        vPos.z -= 1f;
        vPos.y  = 1f;
        vPos   += snapSpot.transform.position;
        Instantiate(GFX_Rush, vPos, transform.rotation);
    }
Beispiel #7
0
    private void RenderRole(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        switch (role.mRole)
        {
        case "Zone": RenderZone(role, snapSpot); break;

        case "Man": RenderManCover(role, snapSpot); break;

        case "Pass Rush": RenderRush(role, snapSpot); break;

        case "Pass Block": RenderPassBlock(role, snapSpot); break;

        case "Route": RenderRoute(role, snapSpot); break;
        }
    }
Beispiel #8
0
    private void RenderZone(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        // get the zone details.
        DATA_Zone zn = IO_ZoneList.FLOAD_ZONE_BY_NAME(role.mDetail);
        GFX_Zone  zoneGFX;

        if (zn.mSpot.y > 19f)
        {
            // render using the "deep zone" version.
            zoneGFX = GFX_DeepZone;
        }
        else if (zn.mSpot.y > 9f)
        {
            // render using mid zone version
            zoneGFX = GFX_MidZone;
        }
        else
        {
            // render using shallow zone version.
            zoneGFX = GFX_ShallowZone;
        }

        Vector3 vZonePos = snapSpot.transform.position;

        vZonePos.z += zn.mSpot.y;
        vZonePos.x += zn.mSpot.x;
        Instantiate(zoneGFX, vZonePos, transform.rotation);

        Vector3 vStartPos = UT_VecConversion.ConvertVec2(role.mStart);

        vStartPos += snapSpot.transform.position;
        Vector3 vIterPos = vStartPos;
        Vector3 vDir     = Vector3.Normalize(vZonePos - vStartPos);

        while (Vector3.Dot(vDir, vZonePos - vIterPos) > 0f)
        {
            Instantiate(GFX_ZoneTrail, vIterPos, transform.rotation);
            vIterPos += vDir * 0.5f;
        }
    }
Beispiel #9
0
    // We're now doing something similar to the zone trail, just spawning little dots to
    // a spot in front of the guy we're covering.
    // Problem is we're no longer where the play says we should be, since we may have man aligned.
    private void RenderManCover(DT_PlayerRole role, PLY_SnapSpot snapSpot)
    {
        Vector3 vPos = new Vector3();

        Vector3 vManSpot = new Vector3();

        // Need to get references for all the offensive players in the scene, as well as all the defenders.
        PRAC_Off[] offs = FindObjectsOfType <PRAC_Off>();
        PRAC_Def[] defs = FindObjectsOfType <PRAC_Def>();

        for (int i = 0; i < defs.Length; i++)
        {
            if (defs[i].mJob.mTag == role.mTag)
            {
                vPos = defs[i].transform.position;
                Instantiate(GFX_ZoneTrail, vPos, transform.rotation);
                for (int j = 0; j < offs.Length; j++)
                {
                    if (offs[j].mJob.mTag == defs[i].GetComponent <DEF_ManLog>().rMan.mJob.mTag)
                    {
                        vManSpot = offs[j].transform.position;
                    }
                }
            }
        }

        vManSpot.z += 2f;

        // So we have our starting and ending position, now make a trail between them.
        Vector3 vDir     = Vector3.Normalize(vManSpot - vPos);
        Vector3 vIterPos = vPos;

        while (Vector3.Dot(vDir, vManSpot - vIterPos) > 0f)
        {
            Instantiate(GFX_ZoneTrail, vIterPos, transform.rotation);
            vIterPos += vDir * 1f;
        }
    }