private bool SaveRoute()
    {
        DATA_Route route = new DATA_Route();

        route.mName  = rRouteNamingUI.rRouteName.text;
        route.mSpots = new Vector2[mCurRoute.mNodes.Count];
        for (int i = 0; i < mCurRoute.mNodes.Count; i++)
        {
            Vector2 vConvertedSpot = new Vector2();
            vConvertedSpot  = mCurRoute.mNodes[i].transform.position;
            vConvertedSpot -= (Vector2)mCurRoute.mNodes[0].transform.position;
            vConvertedSpot *= 10f;          // hardcoding because 500 pixel field == 50 meters. - HACK

            vConvertedSpot.x = (float)System.Math.Round(vConvertedSpot.x, 0);
            vConvertedSpot.y = (float)System.Math.Round(vConvertedSpot.y, 0);

            route.mSpots[i] = vConvertedSpot;
        }

        if (IO_RouteList.FWRITE_ROUTE(route) == false)
        {
            Debug.Log("Route not saved properly");
            return(false);
        }

        // Don't change the state here.
        return(true);
    }
Exemple #2
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;
            }
        }
    }
Exemple #3
0
    public void BT_Save()
    {
        Debug.Log("Name: " + mNameField.text);
        if (mNameField.text == "")
        {
            Debug.Log("No valid name yet");
            return;
        }

        DATA_Route r = new DATA_Route();

        r.mName       = mNameField.text;
        r.mSpots      = new Vector2[mNodes.Count];
        r.mSpots[0].x = 0f;
        r.mSpots[0].y = 0f;
        // Now I need to convert these guys.
        for (int i = 1; i < r.mSpots.Length; i++)
        {
            Vector2 v    = new Vector2();
            int     xDif = mNodes[i].x - mNodes[i - 1].x;
            int     yDif = mNodes[i].y - mNodes[i - 1].y;

            v.x = xDif * 2f;
            v.y = yDif * -2f;
            Debug.Log(v);

            r.mSpots[i] = v;
        }

        IO_RouteList.FWRITE_GRID_ROUTE(r);
    }
 // save the current route to the disk.
 public void BT_RouteNamed()
 {
     Debug.Log("BT_ROuteNamed");
     if (mState != ROUTE_TOOL_STATE.SSAVING)
     {
         Debug.Log("Woah, not in saving state");
         return;
     }
     // If the route already exists, then we ask them if they want to overwrite.
     if (IO_RouteList.FCHECK_ROUTE_EXISTS(rRouteNamingUI.rRouteName.text))
     {
         rOverwriteRouteUI.SetActive(true);
     }
     else
     {
         if (SaveRoute() == false)
         {
             Debug.Log("Error saving route");
         }
         else
         {
             mState = ROUTE_TOOL_STATE.SCLOSED;
         }
     }
 }
    public void FDisplayJobs()
    {
        // Destroy existing jobs.
        PE_Route[] oldRoutes = FindObjectsOfType <PE_Route>();
        for (int i = 0; i < oldRoutes.Length; i++)
        {
            oldRoutes[i].FDestroySelf();
        }

        PE_BlockImg[] blockImages = FindObjectsOfType <PE_BlockImg>();
        for (int i = 0; i < blockImages.Length; i++)
        {
            Destroy(blockImages[i].gameObject);
        }

        // For all the receivers in the scene, spawn a route object.
        // actually, spawn THEIR route, on them.
        PE_Role[] roles = FindObjectsOfType <PE_Role>();
        foreach (PE_Role role in roles)
        {
            if (role.mRole == "Route")
            {
                DATA_Route route = IO_RouteList.FLOAD_ROUTE_BY_NAME(role.mDetails);
                if (route == null)
                {
                    Debug.Log("Woah, incorrect route: " + role.mDetails);
                    return;
                }
                else
                {
                    PE_Route rt = Instantiate(PF_Route);
                    rt.mTag = role.mTag;
                    foreach (Vector2 spot in route.mSpots)
                    {
                        Vector2 vSpot = spot;
                        vSpot /= 10f;           // manual conversion, hacky I know.
                        vSpot += (Vector2)role.transform.position;
                        // on the player who they belong to.
                        var node = Instantiate(PF_RouteSpot, vSpot, role.transform.rotation);
                        rt.mNodes.Add(node);
                        rt.mLineRenderer.positionCount = rt.mNodes.Count;
                        Vector3 lineSpot = node.transform.position; lineSpot.z = 0f;
                        rt.mLineRenderer.SetPosition(rt.mNodes.Count - 1, lineSpot);
                    }
                }
            }
            else if (role.mRole == "Pass Block" || role.mRole == "Run Block")
            {
                Vector2 vBlockSpot = role.transform.position;
                vBlockSpot.y -= 0.1f;           // manual fudge factor.
                Instantiate(PF_BlockImage, vBlockSpot, transform.rotation);
            }
        }
    }
Exemple #6
0
    void Start()
    {
        IO_DefPlays.FLOAD_PLAYS();
        IO_PlayList.FLOAD_PLAYS();
        IO_RouteList.FLOAD_ROUTES();
        IO_Settings.FLOAD_SETTINGS();
        IO_ZoneList.FLOAD_ZONES();

        mDebugText.text = "Loading in stuffs";

        // IO_RouteList.FWRITE_ALL_ROUTES_AS_TEXT();
        DeleteOldFilesFromPlayArtDirectories();
        TransferCurrentFormationsAndPlaysIntoPlayArtDirectories();

        mDebugText.text = "Should have transfered text files with formation and plays";

        mState = SplashState.SLOGO;
        mAudioMixer.SetFloat("MASTER_VOLUME", IO_Settings.mSet.lMasterVolume);

        ENTER_Logo();
    }
Exemple #7
0
    void Start()
    {
        cPlaySetter  = GetComponent <PRAC_SetUpPlay>();
        cShowDefence = GetComponent <PRAC_ShowDefense>();

        mState         = PRAC_STATE.SPOST_PLAY;
        mPreSnapState  = PRESNAP_STATE.SREADYTOSNAP;
        mPickPlayState = PICKPLAY_STATE.SOFFENSE;
        IO_PlayList.FLOAD_PLAYS();
        IO_DefPlays.FLOAD_PLAYS();
        IO_ZoneList.FLOAD_ZONES();

        IO_RouteList.FLOAD_ROUTES();

        PRS_AssignMan.FLOAD_PRIORITIES();

        // Won't affect the build, but will affect the editor.
        IO_Settings.FLOAD_SETTINGS();
        // IO_RouteList.FCONVERT_TO_TEXT_FILES();
        // IO_PlayList.FCONVERT_TO_TEXT_FILES();
        // IO_DefPlays.FCONVERT_TO_TEXT_FILES();
        // IO_ZoneList.FCONVERT_TO_TEXT_FILES();
        MN_PauseScreen.SetActive(false);
    }
Exemple #8
0
 void Start()
 {
     IO_RouteList.FLOAD_ROUTES();
     IO_PlayList.FLOAD_PLAYS();
 }
Exemple #9
0
 void Awake()
 {
     IO_Settings.FLOAD_SETTINGS();
     IO_RouteList.FLOAD_ROUTES();
     TDC_EventManager.FRemoveAllHandlers();
 }
    // For now we are ignoring the defensive play name.
    public void FSetUpPlay(string sOffName, string sDefName, PLY_SnapSpot rSnapSpot)
    {
        // ------------------------------- LOAD IN PLAYERS
        DATA_Play playToRun = IO_PlayList.FLOAD_PLAY_BY_NAME(sOffName);

        if (playToRun == null)
        {
            Debug.Log("No play of that name");
        }

        // Now we just pretend there were no issues, so we put our players in their spots.
        for (int i = 0; i < playToRun.mPlayerRoles.Length; i++)
        {
            Vector3 vPlayerSpot = new Vector3();
            vPlayerSpot.x = playToRun.mPlayerRoles[i].mStart.x;
            vPlayerSpot.z = playToRun.mPlayerRoles[i].mStart.y;
            vPlayerSpot  += rSnapSpot.transform.position;
            var clone = Instantiate(PF_OffensivePlayer, vPlayerSpot, transform.rotation);
            clone.mJob.mTag    = playToRun.mPlayerRoles[i].mTag;
            clone.mJob.mRole   = playToRun.mPlayerRoles[i].mRole;
            clone.mJob.mDetail = playToRun.mPlayerRoles[i].mDetail;
        }

        int randomDefPlay = Random.Range(0, IO_DefPlays.mPlays.Length);
        // DATA_Play defPlay = IO_DefPlays.mPlays[randomDefPlay];
        DATA_Play defPlay = IO_DefPlays.FLOAD_PLAY_BY_NAME(sDefName);
        PRAC_UI   ui      = FindObjectOfType <PRAC_UI>();

        ui.mDefensivePlayName.text = defPlay.mName;

        // spawn a defensive player according to the play.
        for (int i = 0; i < defPlay.mPlayerRoles.Length; i++)
        {
            Vector3 vPlayerSpot = new Vector3();
            vPlayerSpot.x = defPlay.mPlayerRoles[i].mStart.x;
            vPlayerSpot.z = defPlay.mPlayerRoles[i].mStart.y;
            vPlayerSpot  += rSnapSpot.transform.position;
            var clone = Instantiate(PF_DefensivePlayer, vPlayerSpot, transform.rotation);
            clone.mJob.mTag    = defPlay.mPlayerRoles[i].mTag;
            clone.mJob.mRole   = defPlay.mPlayerRoles[i].mRole;
            clone.mJob.mDetail = defPlay.mPlayerRoles[i].mDetail;
        }

        // --------------------------------------------- Set all athletes to waiting for snap.
        PRAC_Ath[] athletes = FindObjectsOfType <PRAC_Ath>();
        foreach (PRAC_Ath athlete in athletes)
        {
            athlete.mState = PRAC_Ath.PRAC_ATH_STATE.SPRE_SNAP;
        }


        // --------------------------------------------- Re-arrange offensive and defensive player pointers left->right.
        PRAC_Off[] offenders = FindObjectsOfType <PRAC_Off>();
        PRAC_Def[] defenders = FindObjectsOfType <PRAC_Def>();
        SortPlayersLeftToRight(offenders);
        SortPlayersLeftToRight(defenders);


        // -------------------------------------- For route runners, load in their routes.
        IO_RouteList.FLOAD_ROUTES();
        for (int i = 0; i < offenders.Length; i++)
        {
            if (offenders[i].mJob.mRole == "Route")
            {
                // Yep, memory not allocated error if we don't do this here.
                offenders[i].GetComponent <OFF_RouteLog>().mRouteSpots = new List <Vector3>();

                DATA_Route rt = IO_RouteList.FLOAD_ROUTE_BY_NAME(offenders[i].mJob.mDetail);
                foreach (Vector2 routeSpot in rt.mSpots)
                {
                    Vector3 vSpot = offenders[i].transform.position;
                    vSpot.x += routeSpot.x; vSpot.z += routeSpot.y;
                    // Also, shove the spot into the receiver, just for now.
                    offenders[i].GetComponent <OFF_RouteLog>().mRouteSpots.Add(vSpot);
                    // Instantiate(PF_RouteNode, vSpot, transform.rotation);
                }
            }
        }

        // ---------------------------------------------------------- Shove the player "into" the QB character.
        for (int i = 0; i < offenders.Length; i++)
        {
            if (offenders[i].mJob.mTag == "QB")
            {
                Vector3 vSpot = offenders[i].transform.position;
                vSpot.y = 1f;
                FindObjectOfType <PC_Controller>().transform.position = vSpot;
            }
        }

        // ------------------------------------------ Now we're assigning the man for man coverage.
        // An offense has 5 eligible receivers on every play, so we actually SHOULD go by that, not their routes.
        // Update, we've added PRS_AssignMan which globally stores the order that tags should be covered, and the same for defense.

        List <PRAC_Off> elibibleRecs = new List <PRAC_Off>();

        foreach (PRAC_Off off in offenders)
        {
            if (PRS_AssignMan.FELIGIBLE_RECEIVER(off.mJob.mTag))
            {
                elibibleRecs.Add(off);
            }
        }

        elibibleRecs = PRS_AssignMan.FSORT_RECEIVER_IMPORTANCE(elibibleRecs);

        List <PRAC_Def> defsInMan = new List <PRAC_Def>();

        foreach (PRAC_Def def in defenders)
        {
            if (def.mJob.mRole == "Man")
            {
                Debug.Log("Added");
                defsInMan.Add(def);
            }
        }

        defsInMan = PRS_AssignMan.FSORT_DEFENDER_IMPORTANCE(defsInMan);

        // Now we finally start assigning man coverage responsibility.
        for (int i = 0; i < defsInMan.Count; i++)
        {
            if (elibibleRecs.Count <= 0)
            {
                break;
            }

            defsInMan[i].GetComponent <DEF_ManLog>().rMan = elibibleRecs[0];
            elibibleRecs.RemoveAt(0);
        }

        // ---------- ALIGN MAN DEFENDERS TO THE GUY THEY'RE COVERING
        for (int i = 0; i < defsInMan.Count; i++)
        {
            Vector3 vManPos = defsInMan[i].GetComponent <DEF_ManLog>().rMan.transform.position;
            vManPos.z += 7f;
            defsInMan[i].transform.position = vManPos;
        }
    }